play audio in flutter

1,677

can any one help me to resolve this error?

The only way to resolve the error would be to write an implementation of that plugin for Windows; the reason it's telling you that the plugin is missing is that the plugin doesn't have Windows support (which you can tell because there's no windows folder in the plugin repository, or windows: entry in the pubspec.yaml).

its work fine in [...] linux desktop

That's surprising, given that the plugin you are using doesn't support Linux either.

It's unlikely that you're going to find a plugin that has Windows support at the moment given that the official documentation currently says:

Note: Windows and Linux plugin APIs and tooling are not yet stable, so any plugin written now will need frequent updates for breaking changes. Because of this, publishing Windows and/or Linux plugins to pub.dev at this stage is strongly discouraged.

Share:
1,677
hio
Author by

hio

SOreadytohelp

Updated on December 19, 2022

Comments

  • hio
    hio over 1 year

    i made one demo in flutter its work fine in Android, iphone, linux desktop and mac desktop but in windows desktop it give me error

    [ERROR:c:\b\s\w\ir\cache\builder\src\flutter\lib\ui\ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method stop on channel xyz.luan/audioplayers)
    

    can any one help me to resolve this error?

    in this demo i used audioplayers 0.14.2 to play local audio file in flutter.

    here is my code:-

          void main() {
            debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
            runApp(new MaterialApp(home: new ExampleApp()));
          }
    
          class ExampleApp extends StatefulWidget {
            @override
            _ExampleAppState createState() => new _ExampleAppState();
          }
    
          class _ExampleAppState extends State<ExampleApp> {
            AudioPlayer advancedPlayer;
            AudioCache audioCache;
    
            @override
            void initState() {
              super.initState();
              initPlayer();
            }
    
            void initPlayer() {
              advancedPlayer = new AudioPlayer();
              audioCache = new AudioCache(fixedPlayer: advancedPlayer);
            }
    
            void playfirst() {
              audioCache.play('audio1.mp3');
            }
    
            void stop() {
              advancedPlayer.stop();
            }
    
            @override
            Widget build(BuildContext context) {
              return DefaultTabController(
                length: 1,
                child: Scaffold(
                  appBar: AppBar(
                    title: Text('Audio file demo'),
                  ),
                  body: Center(
                    child: Column(
                      children: <Widget>[
                        ButtonTheme(
                            minWidth: 48.0,
                            child: RaisedButton(child: Text("play"), onPressed: playfirst)),
                        ButtonTheme(
                            minWidth: 48.0,
                            child: RaisedButton(child: Text("stop"), onPressed: stop))
                      ],
                    ),
                  )
                ),
              );
            }
          }