这是我第一次发帖问一个问题,因为我通常不需要帮助,但我不知道这是否可能。我需要的是在这两类avaudiosession之间切换
当应用程序从允许混音切换到不混音时,请收回控制中心 Remote 的控制权。
我找到了一个适合我的解决方案,其中涉及调用
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents]
[[UIApplication sharedApplication] endReceivingRemoteControlEvents]
NSUInteger options = ... // determine your options
// it seems that calls to beginReceivingRemoteControlEvents and endReceivingRemoteControlEvents
// need to be balanced, so we keep track of the current state in _isReceivingRemoteControlEvents
BOOL shouldBeReceivingRemoteControlEvents = ( 0 == (options & AVAudioSessionCategoryOptionMixWithOthers) );
if(_isReceivingRemoteControlEvents != shouldBeReceivingRemoteControlEvents) {
if(shouldBeReceivingRemoteControlEvents) {
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
_isReceivingRemoteControlEvents=YES;
} else {
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
_isReceivingRemoteControlEvents=NO;
}
}
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptionsptions error:&error];
...
[[AVAudioSession sharedInstance] setActive:YES error:&error]
关于ios - 切换 avaudiosession 类别然后重新控制远程控制中心控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24625510/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) | Powered by Discuz! X3.4 |