iOS Developer Library — Prerelease

Developer

Media Player Framework Reference MPMoviePlayerViewController Class Reference

Options
Deployment Target:

On This Page
Language:

MPMoviePlayerViewController

The MPMoviePlayerViewController class implements a simple view controller for displaying full-screen movies. Unlike using an MPMoviePlayerController object on its own to present a movie immediately, you can incorporate a movie player view controller wherever you would normally use a view controller. For example, you can present it using a tab bar or navigation bar-based interface, taking advantage of the transitions offered by those interfaces.

To present a movie player view controller modally, you typically use the presentMoviePlayerViewControllerAnimated: method. This method is part of a category on the UIViewController class and is implemented by the Media Player framework. The presentMoviePlayerViewControllerAnimated: method presents a movie player view controller using the standard transition animations for presenting video content. To dismiss a modally presented movie player view controller, call the dismissMoviePlayerViewControllerAnimated method.

  • init(contentURL:) - initWithContentURL: (iOS 9.0) Designated Initializer

    Returns a movie player view controller initialized with the specified movie.

    Declaration

    Swift

    init!(contentURL contentURL: NSURL!)

    Objective-C

    - (instancetype)initWithContentURL:(NSURL *)contentURL

    Parameters

    contentURL

    The URL that points to the content to be played.

    Return Value

    A movie player view controller initialized with the specified URL.

    Availability

    Available in iOS 3.2 and later.

    Deprecated in iOS 9.0.

  • moviePlayer moviePlayer (iOS 9.0) Property

    The movie player controller object used to present the movie. (read-only)

    Declaration

    Swift

    var moviePlayer: MPMoviePlayerController! { get }

    Objective-C

    @property(nonatomic, readonly) MPMoviePlayerController *moviePlayer

    Discussion

    The MPMoviePlayerController object in this property is created automatically by the receiver and cannot be changed. However, you can use the object to manage the presentation and configuration of the movie playback.

    Availability

    Available in iOS 3.2 and later.

    Deprecated in iOS 9.0.

  • - shouldAutorotateToInterfaceOrientation: Available in iOS 3.2 through iOS 6.1

    Returns a Boolean value indicating whether the view controller supports the specified orientation.

    Declaration

    Objective-C

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

    Parameters

    toInterfaceOrientation

    The orientation of the application’s user interface after the rotation. The possible values are described in UIInterfaceOrientation.

    Return Value

    YEStrue if the view controller supports the specified orientation or NOfalse if it does not.

    Discussion

    This method is an override that replaces the default behavior by returning YEStrue for the UIInterfaceOrientationPortrait, UIInterfaceOrientationLandscapeLeft, and UIInterfaceOrientationLandscapeRight orientations.

    Availability

    Available in iOS 3.2 through iOS 6.1.