Flutter-AssetsAudioPlayer
Flutter-AssetsAudioPlayer copied to clipboard
Remove multiple instance of network audio playing at the same time
Flutter version :- 3.3.1 Tools • Dart 2.18.0 • DevTools 2.15.0 assets_audio_player : latest_version
The problem that I am facing while playing network audio is that it is playing sometimes the multiple instance of songs or audio at the same time , one of the audio being controllable and the other is not. It just keeps playing in the background and there is no way to stop it rather than closing the app itself.
I guess if there is some way to check if multiple instances are running or how to disable multiple audio playback.
It would be great if there was an option to select if it is multiple playback or single playback of song.
I have this at audio_service.dart
final audio_player.AssetsAudioPlayer audioPlayer = audio_player.AssetsAudioPlayer.withId('musicplayer');
@override
Future
Flutter version :- 3.3.1 Tools • Dart 2.18.0 • DevTools 2.15.0 assets_audio_player : latest_version
The problem that I am facing while playing network audio is that it is playing sometimes the multiple instance of songs or audio at the same time , one of the audio being controllable and the other is not. It just keeps playing in the background and there is no way to stop it rather than closing the app itself.
I guess if there is some way to check if multiple instances are running or how to disable multiple audio playback.
It would be great if there was an option to select if it is multiple playback or single playback of song.
I have this at audio_service.dart
final audio_player.AssetsAudioPlayer audioPlayer = audio_player.AssetsAudioPlayer.withId('musicplayer');
@OverRide Future playAtIndex(int index) async { if (audioPlayer.isPlaying.value) { log("Stopping player"); await _player.stop(); } await audioPlayer.open( audio_player.Playlist( audios: audios, startIndex: index, ), showNotification: false, audioFocusStrategy: const AudioFocusStrategy.request( resumeAfterInterruption: true, resumeOthersPlayersAfterDone: true, ), ); }
Does the song keep playing in the background? Even when exiting the app by clicking the back button? Please do reply.
yes I'm also getting this error while playing network audio