参考官方的说明文档, IOS6.0以后的取消了AVAudioSession的委托,改成了发送消息的方法,仔细看看委托中实现的方法 有
[self endInterruption]; 和 [self beginInterruption]方法有在linphone中实现。
现在6.0后,改成了发送消息的方式,修改如下
1. //[audioSession setDelegate:self]; //把他改成下面的代码
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(interruption:)
name: AVAudioSessionInterruptionNotification
object: [AVAudioSession sharedInstance]];
2.重新添加一个@selector(interruption:)的实现函数
- (void) interruption:(NSNotification*)notification
{
NSDictionary *interuptionDict = notification.userInfo;
NSUInteger interuptionType = (NSUInteger)[interuptionDict valueForKey:AVAudioSessionInterruptionTypeKey];
if(interuptionType == AVAudioSessionInterruptionTypeBegan)
[self beginInterruption];
else if (interuptionType == AVAudioSessionInterruptionTypeEnded)
[self endInterruption];
}
- (void)beginInterruption {
LinphoneCall* c = linphone_core_get_current_call(theLinphoneCore);
[LinphoneLogger logc:LinphoneLoggerLog format:"Sound interruption detected!"];
if (c) {
linphone_core_pause_call(theLinphoneCore, c);
}
}
- (void)endInterruption {
[LinphoneLogger logc:LinphoneLoggerLog format:"Sound interruption ended!"];
}