我正在使用颤振构建一个桌面应用程序,我需要从本地存储播放音频文件,为此我使用just_audio颤振包,因为它支持 Windows。但我找不到任何适用于 Windows 的示例。我编写了这样的代码-
import 'package:just_audio/just_audio.dart';
...
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
final _player = AudioPlayer();
@override
void initState() {
super.initState();
...
_init();
}
Future<void> _init() async {
await _Player.setFilePath('C:/Users/Admin/Downloads/test.wav', preload: true);
}
...
await 调用永远不会结束,我收到以下错误:
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method init on channel com.ryanheise.just_audio.methods)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
<asynchronous suspension>
#1 MethodChannelJustAudio.init (package:just_audio_platform_interface/method_channel_just_audio.dart:13:5)
<asynchronous suspension>
#2 AudioPlayer._setPlatformActive.setPlatform (package:just_audio/just_audio.dart:1255:13)
<asynchronous suspension>
#3 AudioPlayer.load (package:just_audio/just_audio.dart:708:26)
<asynchronous suspension>
#4 AudioPlayer.setAudioSource (package:just_audio/just_audio.dart:683:18)
<asynchronous suspension>