1

我实际上是MPMoviePlayerController在我的 iPad 应用程序中使用播放视频。

实际上,我可以轻松播放 1 个视频,但我正在尝试同时播放 2 个视频,这是我的代码:

// 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");

第一个视频正确启动,但不是第二个。(顺便说一句,第二个视频在第一个完成后没有发布)

这是我的输出:

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

有没有办法同时MPMoviePlayerController播放 2 个或更多视频?

谢谢

4

3 回答 3

1

如果您想同时播放多个视频,则必须使用AVPlayer框架。MPMovie一次只能播放一个视频。

请参阅AVPlayer 文档

于 2012-06-27T07:54:43.063 回答
0

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:

http://www.sdkboy.com/?p=66

Hope this helps!

于 2012-06-27T08:12:13.330 回答
0

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 !

于 2012-07-04T11:00:55.113 回答