I have an application that can play audio while the application is in the background with the entry in the plist and everything work fine. But I would like to give the option to the user to setup the background play on and off I use this method to activate the player
moviePlayer.useApplicatio开发者_如何学CnAudioSession = YES;
[moviePlayer play];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:NULL];
[[AVAudioSession sharedInstance] setActive:YES error:NULL];
I would like to change this option on run time and without any interruptions to the audio play. Any ideas if this can happen?
Thanks for your time
I will post the solution here to make it better
if (backgroundSwitch.on) {
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:NULL];
}else {
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategorySoloAmbient error:NULL];
}
精彩评论