Is it possible to play 2 video file simultaneously in the same view?

爷,独闯天下 提交于 2019-12-04 13:12:10

apple's document said:

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.

so,you know...

Play 2 video's at a time is possible..

STEPS:

1.create 2 instance of MPMoviePlayer

2.set frame for 2 player by using CGRectMake

3.Add 2 players to the view(self.view)

I hope above steps are helpful for u.

setting frame for player only supported in iOS 3.2 and above versions.

Let me know you have any doubt.

Sample Code:

player1.view.frame = CGRectMake(0, 0, 320, 240);
[self.view addSubview:player1.view];
[[NSNotificationCenter defaultCenter]addObserver:self 
                                        selector:@selector(movieFinishedCallback:)
                                            name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:player1];
[player1 play];
player2.view.frame = CGRectMake(0, 241, 320, 220);
[self.view addSubview:player2.view];
[[NSNotificationCenter defaultCenter]addObserver:self 
                                        selector:@selector(movieFinishedCallback:)
                                            name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:player2];
[player2 play];

You can use AVPlayer to play two video simultaneously seeting frame of Layer you can get the required frame Please follow following link.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!