How do I play simultaneous videos on iPhone

2019-06-24 12:32发布

问题:

Is it possible to play 2 different videos on the same time on the I phone? using MPMoviePlayerViewController, for example? I didn't find any solutions.

回答1:

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.



回答2:

I'm rolling this off the top of my head and I don't have Xcode installed on this computer to test, but it seems that it could be possible if you added the views inside an instance of MPMoviePlayerController as the two subviews of a parent view:

MPMoviePlayerController *firstMovieController = [[MPMoviePlayerController alloc] initWithContentURL:urlForFirstMovie];
[firstMovieController.view setFrame:CGRectMake(0.0,0.0,320.0,240.0)];

[self addSubview:firstMovieController.view];

MPMoviePlayerController *secondMovieController = [[MPMoviePlayerController alloc] initWithContentURL:urlForSecondMovie];
[firstMovieController.view setFrame:CGRectMake(0.0,240.0,320.0,240.0)];

[self addSubview:secondMovieController.view];

Keep in mind the above views takes up the whole screen with no statusbar, as evidenced by their beginning at offsets relative to 0.0,0.0. Also, this example uses network content.