When using the flutter audioplayers package, the music I play in the application stops the music of another application

31 Views Asked by At

I am using audioplayers: ^5.2.1 package.

It works smoothly. But there is a problem for me.

For example, while playing a song from YouTube Music, even when I press a button click sound in my own application, the song playing on YouTube Music stops. I don't want it to stop the sound playing in another application.

I don't know if I need to make any settings. How can i fix this?

Code:

    AudioPlayer bgMusic1 = AudioPlayer()
      ..setSourceAsset('audios/bgmusic1.mp3')
      ..setVolume(0.02)
      ..setReleaseMode(ReleaseMode.loop);
    
    playBackgroundMusic() {
      try {
        bgMusic1.play(AssetSource('audios/bgmusic1.mp3'));
      } catch (exception) {
        debugPrint(exception.toString());
      }

    }
0

There are 0 best solutions below