Aleksandar Aleksandar - 1 year ago 81
iOS Question

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

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?

Answer Source

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];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download