MPMoviePlayerController

An MPMoviePlayerController vends and controls a view, its view property; you assign it a movie described by a URL, its contentURL, which it will present in that view. You are responsible for instantiating and retaining the MPMoviePlayerController, and you’ll provide the contentURL in its initializer, initWithContentURL:. The movie URL can be a local file URL, so that the player can show, for example, a movie stored as a file in the app’s bundle, or obtained from the Camera Roll / Saved Photos group in the user’s photo library (see Chapter 30); or it can be a resource (possibly streamed) to be fetched over the Internet, in which case the MPMoviePlayerController initiates the download automatically as soon as it has the contentURL.

You are also responsible for placing the MPMoviePlayerController’s view into your interface. (MPMoviePlayerController is not a UIViewController, so you can put its view directly into your interface.) No law says you have to put the MPMoviePlayerController’s view into your interface, but if you don’t, the user won’t be able to see the movie or the controls that accompany it by default. An MPMoviePlayerController’s view is a real view; you can set its frame, its autoresizingMask, and so forth, and you can give it subviews. An MPMoviePlayerController also has a backgroundView which automatically appears behind its view; you can give the backgroundView subviews as well.

Before you can display a movie in your interface with an MPMoviePlayerController, ...

Get Programming iOS 6, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.