A type of movie player that manages the playback of a movie from a file or a network stream.
- iOS 2.0–9.0Deprecated
- Media Player
Playback occurs in a view owned by the movie player and takes place either fullscreen or inline. You can incorporate a movie player’s view into a view hierarchy owned by your app, or use an MPMoviePlayerViewController object to manage the presentation for you.
Movie players support wireless movie playback to AirPlay-enabled hardware such as Apple TV. AirPlay playback is enabled by default. To disable AirPlay in your app, set the
allows property to
false. In iOS 8.0 and later, users access AirPlay compatible hardware through the Control Panel; no AirPlay control is displayed by the movie player.
When you add a movie player’s view to your app’s view hierarchy, be sure to size the frame correctly, as shown here:
Consider a movie player view to be an opaque structure. You can add your own custom subviews to layer content on top of the movie but you must never modify any of its existing subviews.
In addition to layering content on top of a movie, you can provide custom background content by adding subviews to the view in the
background property. Custom subviews are supported in both inline and fullscreen playback modes but you must adjust the positions of your views when entering or exiting fullscreen mode. Use the
MPMovie notifications to detect changes to and from fullscreen mode.
This class supports programmatic control of movie playback, and user-based control via buttons supplied by the movie player. You can control most aspects of playback programmatically using the methods and properties of the
MPMedia protocol, to which this class conforms. The methods and properties of that protocol let you start and stop playback, seek forward and backward through the movie’s content, and even change the playback rate. In addition, the
control property of this class lets you display a set of standard system controls that allow the user to manipulate playback. You can also set the
should property for network-based content to start automatically.
You typically specify the movie you want to play when you create a new
MPMovie object. However, you can also change the currently playing movie by changing the value in the
content property. Changing this property lets you reuse the same movie player controller object in multiple places. For performance reasons you may want to play movies as local files. Do this by first downloading them to a local directory.
To facilitate the creation of video bookmarks or chapter links for a long movie, the
MPMovie class defines methods for generating thumbnail images at specific times within a movie. You can request a single thumbnail image using the
thumbnail method or request multiple thumbnail images using the
To play a network stream whose URL requires access credentials, first create an appropriate
URLCredential object. Do this by calling, for example, the
init(user: method, as shown here:
In addition, create an appropriate
URLProtection object, as shown here. Make appropriate modifications for the realm you are accessing:
With the credential and protection space information in place, you can then play the protected stream.
Movie Player Notifications
A movie player generates notifications to keep your app informed about the state of movie playback. In addition to being notified when playback finishes, your app can be notified in the following situations:
When the movie player begins playing, is paused, or begins seeking forward or backward
When AirPlay playback starts or ends
When the scaling mode of the movie changes
When the movie enters or exits fullscreen mode
When the load state for network-based movies changes
When meta-information about the movie itself becomes available
For more information, see the Notifications section in this document.