Ant*_*nio 6 iphone mpmovieplayercontroller avaudiosession
我有一个MPMoviePlayerController的问题.我用一个实例来播放m3u8音频源:
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *setCategoryError = nil;
[audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError];
if (setCategoryError) {
}
NSError *activationError = nil;
[audioSession setActive:YES error:&activationError];
if (activationError) {
}
self.player =
[[MPMoviePlayerController alloc] initWithContentURL: [NSURL URLWithString:url]];
player.view.hidden = YES;
player.shouldAutoplay = YES;
[player release];
[btnContainer addSubview: player.view];
player.useApplicationAudioSession = NO;
Run Code Online (Sandbox Code Playgroud)
它被设计为在应用程序进入后台时播放,一切正常.
问题是当它在后台时我收到来电.在这种情况下,流暂停,但在呼叫结束后不会返回.事实上,控制台说
2011-01-12 12:02:27.729 RAC1[1571:307] MP _playbackInterruptionDidEndNotification :: NSConcreteNotification 0x155890 {name = AVController_PlaybackInterruptionDidEndNotification; object = <AVController: 0x180d50>; userInfo = {
"AVController_InterruptionStatusNotificationParameter" = "call.declined";
"AVController_InterruptorNameNotificationParameter" = Phone;
}}, _state = 6
2011-01-12 12:02:27.730 RAC1[1571:307] MP _playbackInterruptionDidEndNotification :: resuming playback!
Run Code Online (Sandbox Code Playgroud)
并且应用程序确实显示了流MPMoviePlaybackStatePlaying,但声音似乎停止了.我试过了
[[AVAudioSession sharedInstance] setActive: YES error: &err]
Run Code Online (Sandbox Code Playgroud)
但它似乎失败了.
有人有线索吗?
谢谢!
看来我需要
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
Run Code Online (Sandbox Code Playgroud)
在viewDidAppear我的 viewController 中......