我正在制作一个iphone Live无线电应用程序。我的应用程序在后台模式下工作得很好。但是,如果在后台模式下播放收音机应用程序时电话响起,我的收音机就会停止。
MP AVAudioSessionDelegateMediaPlayerOnly end interruption. Interruptor <Phone> category <completed> resumable <0>, _state = 6
2013-01-02 10:26:24.487 Radio99[2527:707] MP endInterruptionFromInterruptor :: resuming playback at 1.000000发布于 2013-01-04 13:48:08
仅使用AudioStreamer。(切勿使用AVAudioPlayer或MPMoviePlayerController,因为这不是在通话后播放广播)。
NSURL *url =[NSURL URLWithString:@"http://y1.eoews.com/assets/ringtones/2012/5/18/34049/oiuxsvnbtxks7a0tg6xpdo66exdhi8h0bplp7twp.mp3"];
AudioStreamer *tempStreamer = [[AudioStreamer alloc] initWithURL:url];
self.streamer = tempStreamer;
[tempStreamer release]; [streamer start];在后台添加此代码
- (void)applicationDidEnterBackground:(UIApplication *)application
{
CTCallCenter *_center = [[CTCallCenter alloc] init];
_center.callEventHandler = ^(CTCall *call)
{
if ([call.callState isEqualToString:CTCallStateIncoming])
{
NSLog(@"Pause");
[streamPlayer pause];
}
if ([call.callState isEqualToString:CTCallStateDisconnected])
{
NSLog(@"call:%@", call.callState);
NSLog(@"Play");
[streamPlayer start];
}
};
}
}https://stackoverflow.com/questions/14117030
复制相似问题