开发者

Is it possible to play multiple video files simultaneously on an iPad in either HTML5 or Native App?

开发者 https://www.devze.com 2023-03-10 09:03 出处:网络
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

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 A开发者_运维百科VController. Others including Apple state,

"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."

Reference: MPMoviePlayerController

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>

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.

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];

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.

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.

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

From MPMoviePlayerController Class Reference

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号