adrianstevens / Xamarin-Plugins

Cross-platform Plugins for Xamarin, Xamarin.Forms and Windows
https://www.nuget.org/packages/Xam.Plugin.SimpleAudioPlayer/
MIT License
132 stars 53 forks source link

iOS: Pauses other audio on Play() #108

Closed DanielGlick closed 2 years ago

DanielGlick commented 2 years ago

When I call Play() on iOS, any other media that was playing pauses. Is there a way to make it not pause the audio?

DanielGlick commented 2 years ago

After some research, I found that there are iOS settings that you can configure. In my AppDelegate, in the FinishedLaunching method, I use this code.

` var currentSession = AVAudioSession.SharedInstance(); currentSession.SetCategory(AVAudioSessionCategory.Ambient, AVAudioSessionCategoryOptions.DuckOthers); currentSession.SetActive(true);

`

This fixed the issue for me. I can have music playinng, call Play(), and it ducks my music, then continues when the sound is finished