[英]Flutter - Play sound files from platform specific folders (e.g. android/app/src/main/res/raw for Android)
In my Flutter app, I've some custom sound files placed in android/app/src/main/res/raw
to be used as notification tones.在我的 Flutter 应用程序中,我在
android/app/src/main/res/raw
中放置了一些自定义声音文件,用作通知音。 Now I want to play these sounds when user selects using Just audio package.现在我想在用户选择使用Just audio package 时播放这些声音。 Not sure how to reference and play these files (or any resources from platform folders, for that matter).
不确定如何引用和播放这些文件(或平台文件夹中的任何资源,就此而言)。 For now I had to copy them to assets folder and play from there which is not a good solution obviously.
现在我不得不将它们复制到资产文件夹并从那里播放,这显然不是一个好的解决方案。
For a raw resource, you can use:对于原始资源,您可以使用:
AudioSource.uri(Uri('rawresource:///resourceId'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.