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

本文介绍如何在iOS 6.0之后更新AVAudioSession的中断处理方式,从使用委托方法转为利用NSNotification进行中断开始与结束的通知,并提供了具体的代码示例。


参考官方的说明文档, 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];

}


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


- (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!"];

}

    



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值