我实际上是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 个或更多视频?
谢谢