简体   繁体   中英

MPMoviePlayerController interrupting playing audio

I'm developing an iPhone app that can play online videos and I want to play an ad first when the video data is loading.
First, I request an AdColony video Ad and begin to play it, then use MPMoviePlayerController to load video data, But when the video is prepared to play, it interrupts the previous Ad sound, and causes the ad to stop.

Here are the codes Im 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

The offical doc said "calling prepareToPlay may interrupt the movie player's audio session", so the Ad was interrupted. If I remove prepareToPlay , the video data will not be preloaded
I have tried to put [AdColony playVideoAdForSlot:1 withDelegate:self]; below [moviePlayer prepareToPlay];

but it does not work. Does anyone know how to resolve it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM