I'm actually using the MPMoviePlayerController
for play video in my iPad app.
Actually, I can easly play 1 video but I'm trying to play in the same time 2 video, here is my code :
// Look for the video in the main bundle
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"3idiots.mov" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
NSString *urlStr2 = [[NSBundle mainBundle] pathForResource:@"3idiots.mov" ofType:nil];
NSURL *url2 = [NSURL fileURLWithPath:urlStr2];
videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:videoPlayer.view];
videoPlayer.view.frame = CGRectMake(0, 0,200, 200);
videoPlayer2 = [[MPMoviePlayerController alloc] initWithContentURL:url2];
[self.view addSubview:videoPlayer2.view];
videoPlayer2.view.frame = CGRectMake(0, 300,200, 200);
[videoPlayer2 play];
NSLog(@"Video 1 playing");
[videoPlayer play];
NSLog(@"Video 2 playing");
The first video is correctly launched but not the second. (and btw the second video does not lauch after the first finished)
Here is my output :
2012-06-18 13:47:23.015 testMosaique[2498:11f03] Video 1 playing
2012-06-18 13:47:23.016 testMosaique[2498:11f03] Video 2 playing
Is there a way while using MPMoviePlayerController
to play 2 or more videos at the same time?
Thank's
If you want to play more than one video at the same time you have to use AVPlayer
frameworks. MPMovie
only allowed you play one video at a time.
See AVPlayer
documentation.
As Safecase mentioned, MPMovieplayerController will only allow one video to be played at a time. But here is an example to play two simultaneously with the use of AVFoundation:
Hope this helps!
What I did is display 4 videos using AVPlayer, but those video are made from 4 another video (I create each videos with AVFoundation). Si I'm able the display thousand and thousand videos in only 4 players, pretty good performances when you play the videos !
来源:https://stackoverflow.com/questions/11082206/play-multiple-videos