xcode 在 iPad 上播放多个视频
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5208900/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Playing Multiple Videos on iPAD
提问by makboney
I am facing some problem in playing multiple videos on iPAD. I am trying to play multiple thumbnail videos on the same view. You can say its much like the CCTV camera.Well, i have no clue. Please help me. Thanks in advance...
我在 iPAD 上播放多个视频时遇到了一些问题。我正在尝试在同一视图上播放多个缩略图视频。你可以说它很像闭路电视摄像机。好吧,我不知道。请帮我。提前致谢...
回答by Stefan H
MPMoviePlayerController will allow multiple instances, but only one of them can be playing their movie at any given time.
MPMoviePlayerController 将允许多个实例,但在任何给定时间只有一个可以播放他们的电影。
It mentions it here: http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html
它在这里提到它:http: //developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html
From the article:
从文章:
Note: Although you may create multiple MPMoviePlayerController objects and present their views in your interface, only one movie player at a time may play its movie.
注意:虽然您可以创建多个 MPMoviePlayerController 对象并在您的界面中显示它们的视图,但一次只有一个电影播放器可以播放它的电影。
回答by Sam Keene
You can't use the MKMediaFramework to play multiple videos. You can however do this with the lower level AVFoundation Framework. It's not as hard as you might think and I've made a tutorial that goes over it here: http://www.sdkboy.com/?p=66
您不能使用 MKMediaFramework 播放多个视频。但是,您可以使用较低级别的 AVFoundation 框架来执行此操作。这并不像你想象的那么难,我已经在这里做了一个教程:http: //www.sdkboy.com/?p=66
Essentially what you need to do is extend UIView so it contains an AVPlayerLayer to which the output of an AVPlayer object is directed, then you can create multiple instances of this UIView that you feed video using AVPlayer instances.
本质上,您需要做的是扩展 UIView,使其包含一个 AVPlayerLayer,AVPlayer 对象的输出指向该 AVPlayerLayer,然后您可以创建此 UIView 的多个实例,您可以使用 AVPlayer 实例提供视频。
回答by Zebs
This is actually pretty simple to do on the iPad.
这实际上在 iPad 上很简单。
You basically need multiple MPMoviePlayerController
objects.
您基本上需要多个MPMoviePlayerController
对象。
Each MPMoviePlayerController
object has a view
property, you just need to set the frames of the views
on the different MPMoviePlayerController
objects to match what you want it to look like.
每个MPMoviePlayerController
对象都有一个view
属性,您只需要设置views
不同MPMoviePlayerController
对象上的框架以匹配您想要的外观。
Here is a simple example using two MPMoviePlayerController
objects ans 2 different frames
:
这是一个使用两个MPMoviePlayerController
对象 ans 2 different的简单示例frames
:
MPMoviePlayerController *player =
[[MPMoviePlayerController alloc] initWithContentURL: myURL];
[[player view] setFrame: yourFrame1];
[myView addSubview: [player view]];
// ...
[player play];
MPMoviePlayerController *player2 =
[[MPMoviePlayerController alloc] initWithContentURL: myURL2];
[[player2 view] setFrame: yourFrame2];
[myView addSubview: [player2 view]];
// ...
[player2 play];
回答by Khaldoun
May be When Creating a WebView and using a HTML5 Video instance you can run multiple videos at the same time
可能是在创建 WebView 并使用 HTML5 Video 实例时,您可以同时运行多个视频