gpt4 book ai didi

iphone - 后台 MPMoviePlayerController/AVAudioSession 来电后不会重新开始播放

转载 作者:行者123 更新时间:2023-12-03 18:45:23 26 4
gpt4 key购买 nike

我对 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;

它被设计为当应用程序进入后台时播放,并且一切正常。

问题是当它在后台时我接到来电。在这种情况下,流会暂停,但在通话结束后不会返回。事实上,控制台说

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!

应用程序确实将流显示为MPMoviePlaybackStatePlaying,但声音似乎停止了。我尝试过这样做

[[AVAudioSession sharedInstance] setActive: YES error: &err]

但似乎失败了。

有人知道吗?

谢谢!

最佳答案

看来我需要

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

在我的viewController的viewDidAppear中......

关于iphone - 后台 MPMoviePlayerController/AVAudioSession 来电后不会重新开始播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4668548/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com