Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPMoviePlayerController vs. MPMoviePlayerViewController

I'm new to iPhone development. Just wondering what the difference is between the MPMoviePlayerController and the MPMoviePlayerViewController. Also, more generally, what is the difference between a controller and a view controller? I know that you use a controller to construct a view (as with MPMoviePlayerController.view), so what does a ViewController create?

like image 274
zaius Avatar asked Oct 30 '10 01:10

zaius


2 Answers

The MPMoviePlayerController is just a movie player, it provides a way for you to play movies on the iPhone, a MPMoviePlayerViewController is an actual view controller subclass that takes care of presentation of the MPMoviePlayerController...as documentation at apple puts it "An MPMoviePlayerController instance, or movie player, manages the playback of a movie from a file or a network stream. Playback occurs either in full-screen mode or in a custom view that is vended by the movie player. You can incorporate the view into your own view hierarchies or use an MPMoviePlayerViewController object to manage the presentation for you."

There is no relation between a viewControler and a controller, this class just happens to be named MPMoviePlayerController because it gives you control over the movie player. Actually before (4.0 i think) there was no view controller and just the movie player, later apple decided to incorporate the movie player view controller too.

like image 170
Daniel Avatar answered Nov 09 '22 13:11

Daniel


Zaius,

In the simplest terms, MPMoviePlayerViewController displays the movie/video using the MPMoviePlayerController.

hence, MPMoviePlayerController is a property in MPMoviePlayerViewController that you can access.

MPMoviePlayerViewController.moviePlayer is the property that you'd use to access MPMoviePlayerController properties.

Hope anyone hitting this thread will find this useful!

Example:

MyMoviePlayerViewController  * moviePlayerVC = [[MPMoviePlayerViewController alloc]initWithContentURL:movieURL];
moviePlayerVC.moviePlayer.allowsAirPlay = YES;
like image 33
Nitin Alabur Avatar answered Nov 09 '22 13:11

Nitin Alabur