【问题标题】:MissingPluginException(No implementation found for method init on channel com.ryanheise.just_audio.methods)MissingPluginException(在通道 com.ryanheise.just_audio.methods 上找不到方法 init 的实现)
【发布时间】:2021-12-17 02:59:54
【问题描述】:

我正在使用颤振构建一个桌面应用程序,我需要从本地存储播放音频文件,为此我使用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);
  }
  ...

等待调用永远不会结束,我收到以下错误:

[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>

【问题讨论】:

    标签: flutter dart flutter-desktop just-audio flutter-windows


    【解决方案1】:

    你好,如果你使用了一些包,那么在 pub get 之后尝试重启应用程序(不是热重启,重新构建它)然后它会工作。

    【讨论】:

    • 它没有帮助。我得到了同样的结果。
    • 尝试更改您正在使用的音频包。
    • 或者你可以尝试更新版本
    【解决方案2】:

    just_audio 不包括 Windows 实现。因为它是 says in the README,您需要包含另一个包,例如 just_audio_libwinmedia,它提供了该包的 Windows 实现。

    【讨论】:

    • 是的。添加just_audio_libwinmedia和libwinmedia后,之前的错误已经解决了
    猜你喜欢
    • 2020-12-09
    • 1970-01-01
    • 2020-10-20
    • 2023-03-20
    • 2020-08-14
    • 1970-01-01
    • 2021-11-25
    • 2021-12-21
    相关资源
    最近更新 更多