MPMoviePlayerController interrupts audio playback

I am developing an application for the iPhone that can play online video and first I want to play the ad when the video data is uploaded.
First, I request the AdColony Ad video and start playing it, and then use MPMoviePlayerController to download the video data. But when the video is ready for playback, it interrupts the previous sound of the ad and stops the ad.

Here are the Im codes using:

 // 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
// 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 

The official dock said that “a call to prepareToPlay could interrupt the movie audio player session,” so the announcement was interrupted. If I delete prepareToPlay , the video data will not be preloaded
I tried to put [AdColony playVideoAdForSlot:1 withDelegate:self]; below [moviePlayer prepareToPlay];

but that will not work. Does anyone know how to solve it?

+4
source share

All Articles