开发者

iphone background audio on/off

开发者 https://www.devze.com 2023-03-31 09:42 出处:网络
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.

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];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消