MPMoviePlayerController中断播放音频

时间:2012-11-29 17:46:02

标签: iphone ios audio mpmovieplayercontroller

我正在开发一款可以播放在线视频的iPhone应用程序 我想在加载视频数据时首先播放广告 首先,我请求AdColony视频广告并开始播放,然后使用MPMoviePlayerController加载视频数据,但是当视频准备播放时,它会中断之前的广告声音,并导致广告停止。< / p>

以下是我使用的代码:

// Play Ad first
[AdColony playVideoAdForSlot:1 withDelegate:self]; // It also use MPMoviePlayerController to play video

// Load video for playing
moviePlayer = [[MPMoviePlayerController alloc]
               init];
moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.shouldAutoplay = NO;
moviePlayer.view.frame = CGRectMake(0,44,320,320);
moviePlayer.view.userInteractionEnabled = YES;
[moviePlayer prepareToPlay]; // Interrupt Ad playing

官方文件称“呼叫prepareToPlay可能会中断电影播放器​​的音频会话”,因此广告被中断。如果我删除prepareToPlay,视频数据将不会被预加载 我试过放 [AdColony playVideoAdForSlot:1 withDelegate:self];以下[moviePlayer prepareToPlay];

但它不起作用。有谁知道如何解决它?