linphone 6.0 [audioSession setDelegate:self] 委托不能用

来源:互联网 发布:博弈树搜索算法 编辑:程序博客网 时间:2024/05/22 14:50


参考官方的说明文档, IOS6.0以后的取消了AVAudioSession的委托,改成了发送消息的方法,仔细看看委托中实现的方法 有


[selfendInterruption]; 和 [self beginInterruption]方法有在linphone中实现。


现在6.0后,改成了发送消息的方式,修改如下


   

1.   //[audioSession setDelegate:self]; //把他改成下面的代码

    [[NSNotificationCenterdefaultCenter] addObserver:self

                                             selector@selector(interruption:)

                                                 name:      AVAudioSessionInterruptionNotification

                                               object:      [AVAudioSessionsharedInstance]];


2.重新添加一个@selector(interruption:)的实现函数


- (void) interruption:(NSNotification*)notification

{

    NSDictionary *interuptionDict = notification.userInfo;

   NSUInteger interuptionType = (NSUInteger)[interuptionDictvalueForKey:AVAudioSessionInterruptionTypeKey];

   if(interuptionType ==AVAudioSessionInterruptionTypeBegan)

        [selfbeginInterruption];

   else if (interuptionType ==AVAudioSessionInterruptionTypeEnded)

        [selfendInterruption];

}


其中 beginInterruption 和 endInterruption 是linphoneManager.m中已经实现的函数


- (void)beginInterruption {


   LinphoneCall* c =linphone_core_get_current_call(theLinphoneCore);

    [LinphoneLoggerlogc:LinphoneLoggerLogformat:"Sound interruption detected!"];

    if (c) {

       linphone_core_pause_call(theLinphoneCore, c);

    }

    

}


- (void)endInterruption {

    [LinphoneLoggerlogc:LinphoneLoggerLogformat:"Sound interruption ended!"];

}