An MPMoviePlayerViewController is, as its name implies, a view controller (a UIViewController subclass). It manages an MPMoviePlayerController (
moviePlayer) and automatically provides a fullscreen presentation of the MPMoviePlayerController’s view. Thus, an MPMoviePlayerViewController has some strong advantages of simplicity. You don’t have to put the MPMoviePlayerController’s view into your interface, and you don’t have to worry about the user toggling between fullscreen and nonfullscreen modes. The view is either present, occupying the entire screen, or it isn’t.
You can use an MPMoviePlayerViewController wherever you would use a UIViewController, pushing it onto a navigation stack, for example, or making it part of a tab bar interface, or presenting it as a modal view. Here’s a simple example:
NSURL* m = [[NSBundle mainBundle] URLForResource:@"Movie" withExtension:@"m4v"]; MPMoviePlayerViewController* mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL: m]; [self presentModalViewController:mpvc animated:YES]; [mpvc release];
An alternative method for presenting the view modally is
presentMoviePlayerViewControllerAnimated:. It uses a style of animation otherwise unavailable, in which the current view slides out to reveal the movie view.
If the MPMoviePlayerViewController’s view is presented modally, it is dismissed automatically when the user taps the Done button. If you use the MPMoviePlayerViewController in some other way, the Done button stops ...