我在资产文件夹中有 2 个文件夹,如下图所示,我想在不同的文件夹中使用图标和音乐,但音频播放器无法像以前那样工作,当所有内容都位于名为资产的单个文件夹中时,但一旦我将其更改为 2 个文件夹,它就停止工作。
我已附上音频播放器的代码 早些时候,所有图标和音乐都在资产文件夹中,在 pubspec.yaml 文件中我编写了资产/ 它工作正常,但当我想创建 2 个文件夹时,它就停止工作并给出错误
这里的毫秒是一个以毫秒为单位给出时间的函数,如果 widget.button_state 为“on”,那么我想从本地路径播放音乐。
代码->
AudioPlayer audioPlayer = AudioPlayer();
Future<void> playDelayedSound() async {
int delayInMilliseconds = miliseconds();
await Future.delayed(Duration(milliseconds: delayInMilliseconds),
() async {
if (widget.button_state == 'on') {
await audioPlayer.play(
AssetSource('assets/music/Luke-Bergs-Bliss.mp3'));
}
}
);
}
错误->
type here
Invalid depfile: C:\Users\shada\AndroidStudioProjects\clockw\.dart_tool\flutter_build\51129a8a9e24e7f0924f2f8bff077745\kernel_snapshot.d
Invalid depfile: C:\Users\shada\AndroidStudioProjects\clockw\.dart_tool\flutter_build\51129a8a9e24e7f0924f2f8bff077745\kernel_snapshot.d
Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:dart%3Ajs; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34:7)
#1 asFileUri (package:vm/kernel_front_end.dart:721:37)
#2 writeDepfile (package:vm/kernel_front_end.dart:861:21)
<asynchronous suspension>
#3 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:660:9)
<asynchronous suspension>
#4 starter (package:frontend_server/starter.dart:99:12)
<asynchronous suspension>
#5 main (file:///C:/b/s/w/ir/x/w/sdk/pkg/frontend_server/bin/frontend_server_starter.dart:13:14)
<asynchronous suspension>
Target kernel_snapshot failed: Exception
只想播放 asset/music 文件夹中的音乐 预先感谢。