MissingPluginException(No implementation found for method init on channel com.ryanheise.just\_audio.methods)

Issue

I am building a desktop application using flutter where I need to play audio files from local storage and for this I am using just_audio flutter package since it supports Windows. But I Couldn’t find any examples of it for windows. I have coded something like this-

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);
  }
  ...

The await call never finishes and I am getting the following error:

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

Solution

just_audio doesn’t include a Windows implementation. As it says in the README, you need to include another package such as just_audio_libwinmedia that provides a Windows implementation of the package.

Answered By – smorgan

Leave a Comment