English 中文(简体)
只支持一个单玩家实例, 无效, 无效
原标题:"just_audio_background supports only a single player instance, null, null"
I keep getting this error when I create an instance of AudioPlayer but I don t get it when I remove of instances of it from it from the code and when the check the plugins code I saw this method: _JustAudioPlayer? _player; @override Future init(InitRequest request) async { if (_player != null) { throw PlatformException( code: "error", message: "just_audio_background supports only a single player instance"); } _player = _JustAudioPlayer( initRequest: request, ); return _player!; } And that makes ZERO sense to me because what I m seeing here is if an instance of AudioPlayer exists then throw said error, but I need the instance to play audio(unless I m reading it wrong). Whenever there s an instance of AudioPlayer, in the widget I m using I get the error and then I can t play anything but without just_audio_background, everything works fine. The error just halts any use of AudioPlayer through out the app; it throws the same error anytime I load a widget that uses AudioPlayer. I tried using audioservice but I m having issues loading the song from network. All the soltuions I ve seen concerning this error message had a different and was fixed but not in this case.
问题回答
In the docs there is line: ... It supports the simple use case where an app has a single AudioPlayer instance. ... So, this is expected behaviour. If you need a few instance of the audio player you could implements just_audio + audio_service(and maybe even audio_session).




相关问题
Flutter App cannot be installed on Android TV

I m building a Flutter app that should support Android TV and Mobile devices. Despite Google Play shows that it is supported, I cannot install app on my MiBox device. While trying to install it, both ...

Moving the icon button to the right causes rendering issues

I am trying to align the icon button to the right of the Text field, I tried the row which made the icon button not centered vertically and now I am trying out the Stack widget. Here is my code - ...

热门标签