当前位置:编程学习 > wap >>

IOS播放音乐如何处理来电打断?

最近写了个音乐播放功能的软件,支持后台播放,里面有电话来电打断监听,当监听到来电结束后希望继续播放音乐
监听实现如下,
AudioSessionInitialize(NULL, NULL, interruptionListenner, (__bridge void*)self);

void interruptionListenner(void* inClientData, UInt32 inInterruptionState)
{
    ZTAppDelegate* pTHIS = (__bridge ZTAppDelegate*)inClientData;
    if (pTHIS) {
        NSLog(@"interruptionListenner %lu", inInterruptionState);
        if (kAudioSessionBeginInterruption == inInterruptionState) {
            NSLog(@"Begin interruption");
            [pTHIS.self.firstVC pause];
        }
        else
        {
            NSLog(@"Begin end interruption");
            [pTHIS.self.firstVC play];
            NSLog(@"End end interruption");
        }

    }
}

这样写在前台来电打断后可以正常播放,但是按home键切换到后台再来电打断就没音乐了,有知道怎么处理吗?谢谢大家的回复 IOS 后台来电打断 音乐播放 AVAudioPlayer --------------------编程问答-------------------- 捕捉事件重新播放 --------------------编程问答-------------------- 打酱油的
补充:移动开发 ,  iPhone
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,