Aleksandar Aleksandar - 7 months ago 45
iOS Question

iOS - Resuming music player from my app after recording session is done

I have a recording session in my app that cancels background music that is playing currently.

I want this music to resume as soon as my recording session is finished. I saw that system Camera app does that as soon as you leave if you were playing music in system Music app.

I saw Snapchat app doing even better thing with continuing with playing the background music while recording. Is there a way to achieve the same goal as snapchat does?


You can try the following code based on the framework you are using


[[AVAudioSession sharedInstance] setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:nil];


MPMusicPlayerController *mp = [MPMusicPlayerController systemMusicPlayer];
[mp play];