播放多个视频 [英] Play multiple videos

查看:102
本文介绍了播放多个视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm actually using the MPMoviePlayerController for play video in my iPad app.

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

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)

这是我的输出:

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个或更多视频?

Is there a way while using MPMoviePlayerController to play 2 or more videos at the same time?

谢谢

推荐答案

我所做的是使用AVPlayer显示4个视频,但这些视频是由另外4个视频制作的(我用AVFoundation制作每个视频)。 Si我只能在4个播放器中播放一千零一千个视频,播放视频时表现非常好!

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 !

这篇关于播放多个视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆