<!--
{
  "availability" : [
    "iOS: 3.2.0 - 9.0.0",
    "iPadOS: 3.2.0 - 9.0.0",
    "macCatalyst: 13.1.0 - 13.1.0"
  ],
  "documentType" : "symbol",
  "framework" : "MediaPlayer",
  "identifier" : "/documentation/MediaPlayer/MPMoviePlayerController",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Media Player"
    ],
    "preciseIdentifier" : "c:objc(cs)MPMoviePlayerController"
  },
  "title" : "MPMoviePlayerController"
}
-->

# MPMoviePlayerController

A type of movie player that manages the playback of a movie from a file or a network stream.

```
class MPMoviePlayerController
```

## Overview> Important:
> The ``doc://com.apple.mediaplayer/documentation/MediaPlayer/MPMoviePlayerController`` class is formally deprecated in iOS 9. (The ``doc://com.apple.mediaplayer/documentation/MediaPlayer/MPMoviePlayerViewController`` class is also formally deprecated.) To play video content in iOS 9 and later, instead use the <doc://com.apple.documentation/documentation/AVKit/AVPictureInPictureController> or <doc://com.apple.documentation/documentation/AVKit/AVPlayerViewController> class from the AVKit framework, or the <doc://com.apple.documentation/documentation/WebKit/WKWebView> class from WebKit.

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 [`allowsAirPlay`](/documentation/MediaPlayer/MPMoviePlayerController/allowsAirPlay) property to <doc://com.apple.documentation/documentation/Swift/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:

```objc
MPMoviePlayerController *player =
        [[MPMoviePlayerController alloc] initWithContentURL: myURL];
[player prepareToPlay];
[player.view setFrame: myView.bounds];  // player's frame must match parent's
[myView addSubview: player.view];
// ...
[player play];
```

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 [`backgroundView`](/documentation/MediaPlayer/MPMoviePlayerController/backgroundView) 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 [`MPMoviePlayerWillEnterFullscreenNotification`](/documentation/MediaPlayer/MPMoviePlayerWillEnterFullscreenNotification) and [`MPMoviePlayerWillExitFullscreenNotification`](/documentation/MediaPlayer/MPMoviePlayerWillExitFullscreenNotification) 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 [`MPMediaPlayback`](/documentation/MediaPlayer/MPMediaPlayback) 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 [`controlStyle`](/documentation/MediaPlayer/MPMoviePlayerController/controlStyle) 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 [`shouldAutoplay`](/documentation/MediaPlayer/MPMoviePlayerController/shouldAutoplay) property for network-based content to start automatically.

You typically specify the movie you want to play when you create a new `MPMoviePlayerController` object. However, you can also change the currently playing movie by changing the value in the [`contentURL`](/documentation/MediaPlayer/MPMoviePlayerController/contentURL) 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.

> Note:
> Although you can create multiple `MPMoviePlayerController` objects and present their views in your interface, only one movie player at a time can play its movie.

To facilitate the creation of video bookmarks or chapter links for a long movie, the `MPMoviePlayerController` class defines methods for generating thumbnail images at specific times within a movie. You can request a single thumbnail image using the [`thumbnailImage(atTime:timeOption:)`](/documentation/MediaPlayer/MPMoviePlayerController/thumbnailImage(atTime:timeOption:)) method or request multiple thumbnail images using the [`requestThumbnailImages(atTimes:timeOption:)`](/documentation/MediaPlayer/MPMoviePlayerController/requestThumbnailImages(atTimes:timeOption:)) method.

To play a network stream whose URL requires access credentials, first create an appropriate <doc://com.apple.documentation/documentation/Foundation/URLCredential> object. Do this by calling, for example, the <doc://com.apple.documentation/documentation/Foundation/URLCredential/init(user:password:persistence:)> method, as shown here:

```objc
NSURLCredential *credential = [[NSURLCredential alloc]
                        initWithUser: @"userName"
                            password: @"password"
                         persistence: NSURLCredentialPersistenceForSession];
 
self.credential = credential;
[credential release];
```

In addition, create an appropriate <doc://com.apple.documentation/documentation/Foundation/URLProtectionSpace> object, as shown here. Make appropriate modifications for the realm you are accessing:

```objc
NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc]
                            initWithHost: "@streams.mydomain.com"
                                    port: 80
                                protocol: @"http"
                                   realm: @"mydomain.com"
                    authenticationMethod: NSURLAuthenticationMethodDefault];
 
self.protectionSpace = protectionSpace;
[protectionSpace release];
```

Add the URL credential and the protection space to the [Singleton](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/Singleton.html#//apple_ref/doc/uid/TP40008195-CH49) <doc://com.apple.documentation/documentation/Foundation/URLCredentialStorage> object. Do this by calling, for example, the <doc://com.apple.documentation/documentation/Foundation/URLCredentialStorage/set(_:for:)> method, as shown here:

```objc
[[NSURLCredentialStorage sharedCredentialStorage]
                    setDefaultCredential: credential
                      forProtectionSpace: protectionSpace];
```

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.

## Topics

### Creating and initializing the object

[`init(contentURL:)`](/documentation/MediaPlayer/MPMoviePlayerController/init(contentURL:))

Returns a `MPMoviePlayerController` object initialized with the movie at the specified URL.

### Accessing movie properties

[`contentURL`](/documentation/MediaPlayer/MPMoviePlayerController/contentURL)

The URL that points to the movie file.

[`movieSourceType`](/documentation/MediaPlayer/MPMoviePlayerController/movieSourceType)

The playback type of the movie.

[`movieMediaTypes`](/documentation/MediaPlayer/MPMoviePlayerController/movieMediaTypes)

The types of media available in the movie.

[`allowsAirPlay`](/documentation/MediaPlayer/MPMoviePlayerController/allowsAirPlay)

Specifies whether the movie player allows AirPlay movie playback.

[`isAirPlayVideoActive`](/documentation/MediaPlayer/MPMoviePlayerController/isAirPlayVideoActive)

Indicates whether the movie player is currently playing video via AirPlay.

[`naturalSize`](/documentation/MediaPlayer/MPMoviePlayerController/naturalSize)

The width and height of the movie frame.

[`isFullscreen`](/documentation/MediaPlayer/MPMoviePlayerController/isFullscreen)

A Boolean that indicates whether the movie player is in full-screen mode.

[`setFullscreen(_:animated:)`](/documentation/MediaPlayer/MPMoviePlayerController/setFullscreen(_:animated:))

Causes the movie player to enter or exit full-screen mode.

[`scalingMode`](/documentation/MediaPlayer/MPMoviePlayerController/scalingMode)

The scaling mode to use when displaying the movie.

[`controlStyle`](/documentation/MediaPlayer/MPMoviePlayerController/controlStyle)

The style of the playback controls.

[`useApplicationAudioSession`](/documentation/MediaPlayer/MPMoviePlayerController/useApplicationAudioSession)

A Boolean value that indicates whether the movie player should use the app’s audio session.

### Accessing the movie duration

[`duration`](/documentation/MediaPlayer/MPMoviePlayerController/duration)

The duration of the movie, measured in seconds.

[`playableDuration`](/documentation/MediaPlayer/MPMoviePlayerController/playableDuration)

The amount of currently playable content.

### Accessing the view

[`view`](/documentation/MediaPlayer/MPMoviePlayerController/view)

The view containing the movie content and controls.

[`backgroundView`](/documentation/MediaPlayer/MPMoviePlayerController/backgroundView)

A customizable view that is displayed behind the movie content.

### Controlling and monitoring playback

See also the methods of the [`MPMediaPlayback`](/documentation/MediaPlayer/MPMediaPlayback)

A protocol that defines the interface for controlling audio media playback. protocol.

[`loadState`](/documentation/MediaPlayer/MPMoviePlayerController/loadState)

The network load state of the movie player.

[`playbackState`](/documentation/MediaPlayer/MPMoviePlayerController/playbackState)

The current playback state of the movie player.

[`initialPlaybackTime`](/documentation/MediaPlayer/MPMoviePlayerController/initialPlaybackTime)

The time, specified in seconds within the video timeline, when playback should start.

[`endPlaybackTime`](/documentation/MediaPlayer/MPMoviePlayerController/endPlaybackTime)

The end time (measured in seconds) for playback of the movie.

[`shouldAutoplay`](/documentation/MediaPlayer/MPMoviePlayerController/shouldAutoplay)

A Boolean that indicates whether a movie should begin playback automatically.

[`readyForDisplay`](/documentation/MediaPlayer/MPMoviePlayerController/readyForDisplay)

A Boolean that indicates whether the first video frame of the movie is ready to be displayed.

[`repeatMode`](/documentation/MediaPlayer/MPMoviePlayerController/repeatMode)

Determines how the movie player repeats the playback of the movie.

[`timedMetadata`](/documentation/MediaPlayer/MPMoviePlayerController/timedMetadata)

Obtains the most recent time-based metadata provided by the streamed movie.

### Generating thumbnail images

[`thumbnailImage(atTime:timeOption:)`](/documentation/MediaPlayer/MPMoviePlayerController/thumbnailImage(atTime:timeOption:))

Captures and returns a thumbnail image from the current movie.

[`requestThumbnailImages(atTimes:timeOption:)`](/documentation/MediaPlayer/MPMoviePlayerController/requestThumbnailImages(atTimes:timeOption:))

Captures one or more thumbnail images asynchronously from the current movie.

[`cancelAllThumbnailImageRequests()`](/documentation/MediaPlayer/MPMoviePlayerController/cancelAllThumbnailImageRequests())

Cancels all pending asynchronous thumbnail image requests.

### Retrieving movie logs

[`accessLog`](/documentation/MediaPlayer/MPMoviePlayerController/accessLog)

A snapshot of the network playback log for the movie player if it is playing a network stream.

[`errorLog`](/documentation/MediaPlayer/MPMoviePlayerController/errorLog)

A snapshot of the playback failure error log for the movie player if it is playing a network stream.

### Constants

[`MPMovieLoadState`](/documentation/MediaPlayer/MPMovieLoadState)

Constants describing the network load state of the movie player.

[`MPMovieControlStyle`](/documentation/MediaPlayer/MPMovieControlStyle)

Constants describing the style of the playback controls.

[`MPMovieFinishReason`](/documentation/MediaPlayer/MPMovieFinishReason)

Constants describing the reason that playback ended.

[`MPMoviePlaybackState`](/documentation/MediaPlayer/MPMoviePlaybackState)

Constants describing the current playback state of the movie player.

[`MPMovieRepeatMode`](/documentation/MediaPlayer/MPMovieRepeatMode)

Constants describing how the movie player repeats content at the end of playback.

[`MPMovieScalingMode`](/documentation/MediaPlayer/MPMovieScalingMode)

Constants describing how the movie content is scaled to fit the frame of its view.

[`MPMovieTimeOption`](/documentation/MediaPlayer/MPMovieTimeOption)

Constants describing which frame to use when generating thumbnail images.

[`MPMovieMediaTypeMask`](/documentation/MediaPlayer/MPMovieMediaTypeMask)

The types of content available in the movie file.

[`MPMovieSourceType`](/documentation/MediaPlayer/MPMovieSourceType)

Specifies the type of the movie file.

[Thumbnail notification user info keys](/documentation/MediaPlayer/thumbnail-notification-user-info-keys)

The following keys may be found in the `userInfo` dictionary of a [`MPMoviePlayerThumbnailImageRequestDidFinishNotification`](/documentation/MediaPlayer/MPMoviePlayerThumbnailImageRequestDidFinishNotification) notification.

[Fullscreen notification keys](/documentation/MediaPlayer/fullscreen-notification-keys)

The following keys may be found in the `userInfo` dictionary of notifications for transitioning in or out of full-screen mode.

[Playback finished notification key](/documentation/MediaPlayer/playback-finished-notification-key)

The following key may be found in the userInfo dictionary of a [`MPMoviePlayerPlaybackDidFinishNotification`](/documentation/MediaPlayer/MPMoviePlayerPlaybackDidFinishNotification) notification.

### Notifications

[`MPMoviePlayerDidEnterFullscreenNotification`](/documentation/MediaPlayer/MPMoviePlayerDidEnterFullscreenNotification)

Posted when a movie player has entered full-screen mode. There is no `userInfo` dictionary.

[`MPMoviePlayerDidExitFullscreenNotification`](/documentation/MediaPlayer/MPMoviePlayerDidExitFullscreenNotification)

Posted when a movie player has exited full-screen mode. There is no `userInfo` dictionary.

[`MPMoviePlayerIsAirPlayVideoActiveDidChangeNotification`](/documentation/MediaPlayer/MPMoviePlayerIsAirPlayVideoActiveDidChangeNotification)

Posted when a movie player has started or ended playing a movie via AirPlay. There is no `userInfo` dictionary.

[`MPMoviePlayerLoadStateDidChangeNotification`](/documentation/MediaPlayer/MPMoviePlayerLoadStateDidChangeNotification)

Posted when a movie player’s network buffering state has changed. There is no `userInfo` dictionary.

[`MPMoviePlayerNowPlayingMovieDidChangeNotification`](/documentation/MediaPlayer/MPMoviePlayerNowPlayingMovieDidChangeNotification)

Posted when the currently playing movie has changed. There is no `userInfo` dictionary.

[`MPMoviePlayerPlaybackDidFinishNotification`](/documentation/MediaPlayer/MPMoviePlayerPlaybackDidFinishNotification)

Posted when a movie has finished playing. The `userInfo` dictionary of this notification contains the [`MPMoviePlayerPlaybackDidFinishReasonUserInfoKey`](/documentation/MediaPlayer/MPMoviePlayerPlaybackDidFinishReasonUserInfoKey) key, which indicates the reason that playback finished. This notification is also sent when playback fails because of an error.

[`MPMoviePlayerPlaybackStateDidChangeNotification`](/documentation/MediaPlayer/MPMoviePlayerPlaybackStateDidChangeNotification)

Posted when a movie player’s playback state has changed. There is no `userInfo` dictionary.

[`MPMoviePlayerReadyForDisplayDidChangeNotification`](/documentation/MediaPlayer/MPMoviePlayerReadyForDisplayDidChangeNotification)

Posted when the ready for display state changes.

[`MPMoviePlayerScalingModeDidChangeNotification`](/documentation/MediaPlayer/MPMoviePlayerScalingModeDidChangeNotification)

Posted when the scaling mode of a movie player has changed. There is no `userInfo` dictionary.

[`MPMoviePlayerThumbnailImageRequestDidFinishNotification`](/documentation/MediaPlayer/MPMoviePlayerThumbnailImageRequestDidFinishNotification)

Posted when a request to capture a thumbnail from a movie has finished whether the request succeeded or failed. Upon successful capture of a thumbnail, the `userInfo` dictionary contains values for the following keys:

[`MPMoviePlayerTimedMetadataUpdatedNotification`](/documentation/MediaPlayer/MPMoviePlayerTimedMetadataUpdatedNotification)

Posted when new timed metadata arrives.

[`MPMoviePlayerWillEnterFullscreenNotification`](/documentation/MediaPlayer/MPMoviePlayerWillEnterFullscreenNotification)

Posted when a movie player is about to enter full-screen mode.

[`MPMoviePlayerWillExitFullscreenNotification`](/documentation/MediaPlayer/MPMoviePlayerWillExitFullscreenNotification)

Posted when a movie player is about to exit full-screen mode.

[`MPMovieDurationAvailableNotification`](/documentation/MediaPlayer/MPMovieDurationAvailableNotification)

Posted when the duration of a movie has been determined. There is no `userInfo` dictionary.

[`MPMovieMediaTypesAvailableNotification`](/documentation/MediaPlayer/MPMovieMediaTypesAvailableNotification)

Posted when the available media types in a movie are determined. There is no `userInfo` dictionary.

[`MPMovieNaturalSizeAvailableNotification`](/documentation/MediaPlayer/MPMovieNaturalSizeAvailableNotification)

Posted when the natural frame size of a movie is first determined or subsequently changes. There is no `userInfo` dictionary.

[`MPMovieSourceTypeAvailableNotification`](/documentation/MediaPlayer/MPMovieSourceTypeAvailableNotification)

Posted when the source type of a movie was previously unknown and is newly available. There is no `userInfo` dictionary.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)