Aleksandar
Aleksandar

Reputation: 1588

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?

Upvotes: 0

Views: 83

Answers (1)

Rijo Payyappilly
Rijo Payyappilly

Reputation: 801

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

AVFoundation

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

MediaPlayer

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

Upvotes: 1

Related Questions