是否可以在iPad上同时在HTML5或Native App中播放多个视频文件? [英] Is it possible to play multiple video files simultaneously on an iPad in either HTML5 or Native App?

查看:488
本文介绍了是否可以在iPad上同时在HTML5或Native App中播放多个视频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在HTML5中或在Objective-c中原生地编写,我需要生成一个视频缩略图网格,当页面或视图在iPad上加载时自动播放。我一直在多个论坛和StackOverflow上阅读。有些人表示AVController可以实现这一点。其他包括Apple州,

In either HTML5 or written natively in Objective-c, I need to generate a grid of video thumbnails that are automatically playing when the page or view loads on an iPad. I have been reading on multiple forums and StackOverflow. Some people indicate this is possible with AVController. Others including Apple state,

注意:虽然您可以创建多个MPMoviePlayerController对象并在界面中显示他们的视图,但一次只能有一个电影播放器​​可以播放其电影。

"Note: Although you can create multiple MPMoviePlayerController objects and present their views in your interface, only one movie player at a time can play its movie."

参考: MPMoviePlayerController

在HTML5中,它适用于所有9个视频正在播放的Macbook:

In HTML5, it works on a Macbook where all 9 videos are playing:

<video class="movie" src="videos/aerials.m4v" autoplay controls width="200" height="110"></video>

使用正确的链接粘贴此9x,一个漂亮的视频网格开始播放没有问题。然而,在iPad上,加载到webview中的HTML5产生相同的9格,但没有立即播放的视频。一次只能播放1个视频。

Paste this 9x with the proper links and a nice grid of videos starts playing no problem. On the iPad however, the HTML5 loaded into a webview yields the same 9 grid but with no videos playing immediately. Only 1 video is playable at a time.

现在我采用了Objective-c路径并尝试使用其他方法来测试之前引用的Apple声明:

Now I took the objective-c path and tried it with a different approach to test out Apple's statement referenced earlier:

moviePlayer1 = [[MPMoviePlayerController alloc]
initWithContentURL:videoURL];

moviePlayer1.view.frame = CGRectMake(0, 0, 200, 110);
[self.view addSubview:moviePlayer1.view];
[[NSNotificationCenter defaultCenter]addObserver:self 
                                        selector:@selector(movieFinishedCallback:)
                                            name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:moviePlayer1];
[moviePlayer1 play];

moviePlayer2 = [[MPMoviePlayerController alloc]
                initWithContentURL:videoURL];

moviePlayer2.view.frame = CGRectMake(0, 300, 200, 110);
[self.view addSubview:moviePlayer2.view];
[[NSNotificationCenter defaultCenter]addObserver:self 
                                        selector:@selector(movieFinishedCallback:)
                                            name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:moviePlayer2];
[moviePlayer2 play];

这确实会在视图上显示两个视频文件,但同样会出现与HTML5相同的问题,只有1个一次可播放的视频。

This indeed does show both video files on a view but again the same issue as with HTML5 and only 1 video playable at a time.

我认为这是因为解码的硬件限制可能是苹果公司在iPad上强制执行,以防止CPU使用量大幅增加和维持对框架中媒体部分的另一种严格控制。我是对还是错?如果错误,请帮助提供将启用我的任务的代码段。谢谢!

I believe this is because of a hardware limitation with decoding potentially that Apple is enforcing on the iPad to prevent CPU usage from sky rocketing and maintaining yet another strict level of control over the media portion in the framework. Am I right or wrong? If wrong, please help provide the code segment that will enable my task. Thanks!

推荐答案

您实际上已经通过给定的报价回答了您自己的问题。但只是为了让每个人都清楚,再一次从我对非常相似的问题

You actually answered your own question already by the given quote. But just to make it clear to everyone, once again from my answer to a very similar question.

这是不可能的。使用MPMoviePlayerController / MPMoviePlayerViewController时,一次只能播放一部电影/流。

That is not possible. Only one movie/stream can be played at a time when using MPMoviePlayerController / MPMoviePlayerViewController.

来自 MPMoviePlayerController类参考

注意:虽然您可以创建多个MPMoviePlayerController对象并在界面中显示其视图,但一次只能播放一个电影播放器​​。

这篇关于是否可以在iPad上同时在HTML5或Native App中播放多个视频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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