Hi,
My company is developing an app which will play a spoken audio file (mp3) with a quiet music score as a background, triggered at specific geolocations and typically lasts 2-4 minutes. This also happens when the app is running in the background (locked screen or other app in front).
All this works fine, except for one thing. When user plays music from e.g. Spotify and the apps audio is trigged while running in the background, the music is "ducked". As such, Spotify's music and the apps background music is mixed, leading to a messy sound. Instead of ducking the music player, I need it to pause until audio from my app is finished.
My developers says this can't be done. But I really need to (try and) find a way around this.
The app is using the AVAudioSessionCategoryPlayback audio session category which by default should "Interrupts nonmixable app’s audio". I guess though that music players like Spotify don't fall under the category nonmixable audio, thus not being paused.
We have tried to use the option AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers, but find the documentation a little confusing. It reads:
"If you clear this option, audio from your audio session interrupts other sessions. If you set this option, the system mixes your audio with other audio sessions, but interrupts (and stops) audio sessions that use the AVAudioSessionModeSpokenAudio audio session mode. It pauses the audio from other apps as long as your session is active. After your audio session deactivates, the system resumes the interrupted app’s audio."
The first sentence would indicate that clearing this option would lead to any other audio session, both music and spoken, would be interrupted (paused). But presumably, I'm misunderstanding this?
Bottom line is, is there a way our app can pause any other app's media playing while our app is playing (and preferably resume these when done)?
Best regards,
Eirik
My company is developing an app which will play a spoken audio file (mp3) with a quiet music score as a background, triggered at specific geolocations and typically lasts 2-4 minutes. This also happens when the app is running in the background (locked screen or other app in front).
All this works fine, except for one thing. When user plays music from e.g. Spotify and the apps audio is trigged while running in the background, the music is "ducked". As such, Spotify's music and the apps background music is mixed, leading to a messy sound. Instead of ducking the music player, I need it to pause until audio from my app is finished.
My developers says this can't be done. But I really need to (try and) find a way around this.
The app is using the AVAudioSessionCategoryPlayback audio session category which by default should "Interrupts nonmixable app’s audio". I guess though that music players like Spotify don't fall under the category nonmixable audio, thus not being paused.
We have tried to use the option AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers, but find the documentation a little confusing. It reads:
"If you clear this option, audio from your audio session interrupts other sessions. If you set this option, the system mixes your audio with other audio sessions, but interrupts (and stops) audio sessions that use the AVAudioSessionModeSpokenAudio audio session mode. It pauses the audio from other apps as long as your session is active. After your audio session deactivates, the system resumes the interrupted app’s audio."
The first sentence would indicate that clearing this option would lead to any other audio session, both music and spoken, would be interrupted (paused). But presumably, I'm misunderstanding this?
Bottom line is, is there a way our app can pause any other app's media playing while our app is playing (and preferably resume these when done)?
Best regards,
Eirik