6

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]

しかし、それは失敗するようです。

誰か手がかりがありますか?

ありがとう!

4

2 に答える 2

3

する必要があったようです

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

私のviewDidAppearviewControllerの....

于 2011-01-12T15:48:54.523 に答える
1

このリンクを見て、オーディオの中断を処理しましたか。AVAudioSessionDelegate をセットアップし、割り込みを処理する必要があります。

于 2011-11-18T14:38:37.980 に答える