Thursday, 2 August 2018

AVAudioSession configuration to record and play with others

I want to configure AVAudioSession that I can record video with audio and also play music from Music app (or any other app that is producing sound, typically internet radios apps)

I configure session like this:

try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, with: .mixWithOthers)
try? AVAudioSession.sharedInstance().setActive(true, with: .notifyOthersOnDeactivation)

This works the way that when my recording app is running I can start playing audio from music app and record video (also record audio as well). So far good.

Now, I put my recording app to the background. Music app continues to play. It is fine. But, when my app is coming back from background music app stop its playback. I would like it to continue. So it basically behaves as build in camera app when shooting video. Is there a way to tell the system that I want other app to continue playback?



from AVAudioSession configuration to record and play with others

No comments:

Post a Comment