Flutter-AssetsAudioPlayer icon indicating copy to clipboard operation
Flutter-AssetsAudioPlayer copied to clipboard

Unable to play audio in background if spotify is playing in IOS.

Open aadesh93 opened this issue 3 years ago • 2 comments

Flutter Version

My version : 2.2.3

Lib Version

My version : 3.0.3+6

Platform (Android / iOS / web) + version

Platform : IOS

Describe the bug

My app triggers the audio player in the background after reaching a certain geofence. This works fine in android. But in IOS the player starts playing audio under normal circumstances. But if the app is running in background and a music player is playing then the player does not play audio.

The expected behaviour in IOS should be ducking of the audio that is currently playing for the duration our audio player plays the audio.

Small code to reproduce

await assetsAudioPlayer.open(
                  Audio.network(poi_list[index].audioUrl),
                  autoStart: true,
                  respectSilentMode: false,
                  showNotification: false,
                  forceOpen: true,
                  playInBackground: PlayInBackground.enabled,
                  audioFocusStrategy: AudioFocusStrategy.request(
                      resumeOthersPlayersAfterDone: true,
                      resumeAfterInterruption: true));

aadesh93 avatar Aug 09 '21 10:08 aadesh93

@kalismeras61 Can you give some insights on this?

aadesh93 avatar Aug 13 '21 17:08 aadesh93

Hello @aadesh93 , I am in a similar situation, My app is having a background process scanning stuff in bluetooth, and when I get a specific message, I would like the app to play a sound. So the playSound() function is triggered from my Background process (which is actually a forground service). It works well in android. But it doesn't work at all in IOS. Even when I have no music player.

Does it works for you for IOS when you don't have an audio player ?

If yes, car you tell me which background process do you use ? Thanks a lot.

GaelleJoubert avatar Jan 24 '23 15:01 GaelleJoubert