Framework

MediaPlayer

Find and play user-installed media items including songs, audio podcasts, and audio books. Play custom movie files, such as cut scenes in games.

Overview

The Media Player framework provides facilities for playing movie, music, audio podcast, and audio book files. This framework also gives your application access to the iPod library, letting you find and play audio-based media items synced from iTunes on the desktop. iPod library access is read-only.

This framework’s MPVolumeView class lets you present a control to let the user adjust system audio output volume and choose among the available output routes, such as for sending audio to an AirPlay-enabled device. The MPMoviePlayerController and MPTimedMetadata classes let you play streamed video content and respond to time-based metadata contained in the stream.

Apps can receive and respond to events sent by external media players using Media Player APIs. Use the MPPlayableContentManager class to control the interactions between the app and the external media player. A data source is provided to the content manager through the MPPlayableContentDataSource protocol. Playable media items are described by the MPContentItem class. Register and handle events received from an external media player through the various event APIs.

Symbols

Classes

MPChangeLanguageOptionCommandEventMPChangePlaybackPositionCommandMPChangePlaybackPositionCommandEvent
MPChangePlaybackRateCommand

The MPChangePlaybackRateCommand class provides additional information for the playback commands described in the MPRemoteCommandCenter class. Apps can change the current playback rate of a media item to one of the supported rates defined by the supportedPlaybackRates property.

MPChangePlaybackRateCommandEvent

The MPChangePlaybackRateCommandEvent class provides the playback rate for a media item when it is requested from an external media player.

MPChangeRepeatModeCommandMPChangeRepeatModeCommandEventMPChangeShuffleModeCommandMPChangeShuffleModeCommandEvent
MPContentItem

An MPContentItem object contains the information for a particular media item. An MPContentItem object can represent any media item—for example, a song, movie, radio station, or podcast episode. The information stored in an MPContentItem is consumed by the media player and displayed to the user.

MPFeedbackCommand

An MPFeedbackCommand object reflects the state of feedback for what your app is currently playing. The shared MPRemoteCommandCenter object vends feedback objects for liking, disliking, and bookmarking media items. Use these objects to register handlers for the types of feedback your app supports and to perform the appropriate tasks when that feedback changes. When the currently playing item changes, you can also use this object to set the feedback state for the new item.

MPFeedbackCommandEvent

The MPFeedbackCommandEvent class provides additional information for the feedback properties described in MPRemoteCommandCenter. The MPFeedbackCommandEvent class responds to a negative operation from an external media player.

MPMediaEntity

The MPMediaEntity class serves as the abstract superclass for MPMediaItem and MPMediaItemCollection instances, and in turn for MPMediaPlaylist instances. As the superclass, MPMediaEntity defines methods used by those subclasses.

MPMediaItem

A media item represents a single piece of media (such as one song or one video podcast) in the iPod library. A media item has an overall unique identifier, accessed using the MPMediaItemPropertyPersistentID property key, as well as specific identifiers for its metadata. These identifiers persists across application launches.

MPMediaItemArtwork

An MPMediaItemArtwork object, or media item artwork, represents a graphical image, such as music album cover art, associated with a media item. Media items are described in MPMediaItem.

MPMediaItemCollection

A media item collection is a sorted set of media items (instances of the MPMediaItem class) from the iPod library. Typically, you use this class by requesting an array of collections from a media query by way of its collections property. Media queries are described in MPMediaQuery.

MPMediaLibrary

An MPMediaLibrary object, or media library, represents the state of the set of synced media items (such as songs) on a device. The complete library of media items itself is called the iPod library.

MPMediaPickerController

An MPMediaPickerController object, or media item picker, is a specialized view controller that you employ to provide a graphical interface for selecting media items. To display a media item picker, present it modally on an existing view controller. Media items are described in MPMediaItem.

MPMediaPlaylist

A media playlist is a playable collection of related media items. (Media items are described in MPMediaItem.) Each playlist has a name, a set of attributes, and a unique identifier that persists across application launches.

MPMediaPlaylistCreationMetadata
MPMediaPredicate

Use this class’s concrete subclass, described in MPMediaPropertyPredicate, to define the filter in a media query to retrieve a subset of media items from the iPod library. Media queries are described in MPMediaQuery.

MPMediaPropertyPredicate

Use one or more MPMediaPropertyPredicate objects, or media property predicates, to define the filter in a media query to retrieve a subset of media items from the iPod library. A predicate in this context is a statement of a logical condition that you want to test each media item against. Those items that satisfy the condition are retrieved in the query result.

MPMediaQuery

A media query specifies a set of media items (instances of MPMediaItem) from the iPod library by way of a filter and a grouping type. Filter and grouping type are both optional; an unqualified query matches the entire library.

MPMediaQuerySection

A media query section represents a range of media items or media item collections from within an iPod library media query. You can use sections when displaying a query’s items or collections in your app’s user interface.

MPMovieAccessLog

A movie access log accumulates key metrics about network playback for an associated movie player that is playing streamed content. The log presents these metrics as a collection of MPMovieAccessLogEvent instances and also makes it available in a textual format. A movie access log describes one uninterrupted period of playback. A movie player (an instance of the MPMoviePlayerController class) can access this log from its accessLog property.

Deprecated
MPMovieAccessLogEvent

A movie access log event represents a single piece of information for a movie access log. For a description of movie access logs, see MPMovieAccessLog.

Deprecated
MPMovieErrorLog

A movie error log contains data describing network resource playback failures for the associated movie player. The data includes timestamps indicating when each failure occurred.

Deprecated
MPMovieErrorLogEvent

A movie error log event represents a single piece of information for a movie error log. For a description of movie error logs, see MPMovieErrorLog.

Deprecated
MPMoviePlayerController

A movie player (of type MPMoviePlayerController) manages the playback of a movie from a file or a network stream. 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.

Deprecated
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.

Deprecated
MPMusicPlayerController

Use an MPMusicPlayerController object, or music player, to play media items from the device Music library. There are two types of music player:

MPNowPlayingInfoCenter

Use a now playing info center to set now-playing information for media being played by your app.

MPNowPlayingInfoLanguageOptionMPNowPlayingInfoLanguageOptionGroup
MPPlayableContentManager

Use the MPPlayableContentManager class to control interactions between a media app and system-provided or external media player interfaces. Data is provided by the app to the content manager so that the media player can browse the content provided. A delegate provides the media player the ability to perform actions that manage the app’s playback queue.

MPPlayableContentManagerContext
MPRatingCommand

The MPRatingCommand class provides additional information for the rating commands described in MPRemoteCommandCenter class. Apps can define a maximum and minimum rating for a media item.

MPRatingCommandEvent

The MPRatingCommandEvent class provides the rating for an item requested by an external media player.

MPRemoteCommand

The MPRemoteCommand class provides methods for adding and removing target-action pairs. These target-action pairs allow the app to respond to events as they occur.

MPRemoteCommandCenter

The MPRemoteCommandCenter class vends objects for handling remote control events sent by external accessories and system transport controls. Do not create instances of this class yourself. Instead, use the shared() method to retrieve the shared command center object. The properties of the shared command center object contain MPRemoteCommand objects for each type of remote control event supported by iOS. To respond to a particular event, register a handler with the appropriate MPRemoteCommand object.

MPRemoteCommandEvent

The MPRemoteCommandEvent class provides the basic information for a command. It details the command sent and the time the command was sent by the external media player.

MPSeekCommandEvent

The MPSeekCommandEvent class provides additional information for the seek properties described in the MPRemoteCommandCenter class. The MPSeekCommandEvent responds to begin and end command requests from an external media player.

MPSkipIntervalCommand

The MPSkipIntervalCommand class provides additional information for the skip interval command properties described in the MPRemoteCommandCenter class. Apps can provide a set of available skip intervals for a particular media item using the preferredIntervals method.

MPSkipIntervalCommandEvent

The MPSkipIntervalCommandEvent class provides the time interval rate when requested from an external media player.

MPTimedMetadata

An instance of the MPTimedMetadata class, called a timed metadata object, carries time-based information within HTTP streamed media. Content providers can embed such objects when creating a stream. The properties and constants in this class let you extract the metadata as you play the stream using an MPMoviePlayerController object.

Deprecated
MPVolumeView

Use a volume view to present the user with a slider control for setting the system audio output volume, and a button for choosing the audio output route. When first displayed, the slider’s position reflects the current system audio output volume. As the user drags the slider, the changes update the volume. If the user presses the device volume buttons while sound is playing, the slider moves to reflect the new volume.

Protocols

MPMediaPickerControllerDelegate

The delegate for a media item picker can respond to a user making media item selections. The delegate is also responsible for dismissing the media item picker from the parent view controller. The methods in this protocol are optional.

MPMediaPlayback

The MPMediaPlayback protocol defines the interface adopted by the MPMoviePlayerController class for controlling media playback. This protocol supports basic transport operations including start, stop, and pause, and also lets you seek forward and back through a movie or to a specific point in its timeline.

MPPlayableContentDataSource

To support external media players, create a class that conforms to the MPPlayableContentDataSource protocol. When your app launches, create an instance of this class and assign it to the shared MPPlayableContentManagerdataSource property. This data source provides media metadata to external media players so that they can build user interfaces displaying your app’s content. It is best to set this data source as early as possible in your app’s lifecycle, as iOS may start asking for content right away.

MPPlayableContentDelegate

Use the MPPlayableContentDelegate protocol to let external media players send playback commands to an app. After the media player determines that a media item is to be played, the app’s content delegate requests for playback to be initiated.

Structures

MPError
MPMediaPlaylistAttribute

Playlist attributes, used as possible values for the MPMediaPlaylistPropertyPlaylistAttributes property.

MPMediaType
MPMovieLoadState

Constants describing the network load state of the movie player.

Deprecated
MPMovieMediaTypeMask

Specifies the types of content available in the movie file.

Deprecated

Extended Types

AVMediaSelectionGroup

An AVMediaSelectionGroup represents a collection of mutually exclusive options for the presentation of media within an asset.

AVMediaSelectionOption

An AVMediaSelectionOption object represents a specific option for the presentation of media within a group of options.

MPErrorName
UIViewController

The UIViewController class provides the infrastructure for managing the views of your iOS apps. A view controller manages a set of views that make up a portion of your app’s user interface. It is responsible for loading and disposing of those views, for managing interactions with those views, and for coordinating responses with any appropriate data objects. View controllers also coordinate their efforts with other controller objects—including other view controllers—and help manage your app’s overall interface.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software