TechnologiesAudio

MediaPlayer

iOSmacOStvOSwatchOSvisionOS

MediaPlayer gives your app access to the user's media library and to music playback. Query the library with MPMediaQuery and MPMediaPredicate to find MPMediaItem, MPMediaItemCollection, and MPMediaPlaylist objects, present MPMediaPickerController so the user can choose songs, and check access with MPMediaLibraryAuthorizationStatus before reading MPMediaLibrary. The framework also publishes Now Playing information and a remote command center for audio and video, controls movie playback through MPMoviePlayerController and the MPMediaPlayback protocol, and manages a music player's queue with MPMusicPlayerControllerQueue and MPMusicPlayerControllerMutableQueue.

Media Items and Collections 6

The model objects that represent songs and other media in the user's library and how they are grouped.

  • Cl
    MPMediaEntityiOS 4.2+
    The abstract base class for media library objects that have queryable properties.
  • Cl
    MPMediaItemiOS 3.0+
    A single piece of media, such as a song or audiobook, in the user's media library.
  • Cl
    MPMediaItemCollectioniOS 3.0+
    An ordered collection of media items from the user's library.
  • Cl
    MPMediaItemArtworkiOS 3.0+
    An object that provides the cover art associated with a media item.
  • Cl
    MPMediaItemAnimatedArtworkiOS 26.0+
    An animated image, such as an animated music album cover art, for a media item.
  • St
    MPMediaTypeiOS 3.0+
    An option set that identifies the types of media an item can represent.

The Media Library 2

Accessing the user's media library and confirming authorization to read it.

  • Cl
    MPMediaLibraryiOS 3.0+
    An object that represents the user's collection of media and reports changes to it.
  • En
    MPMediaLibraryAuthorizationStatusiOS 9.3+
    Constants that indicate an app's authorization to access the media library.

Querying the Library 6

Constructing queries and predicates to find media items and organize results into sections.

  • Cl
    MPMediaQueryiOS 3.0+
    An object that specifies a set of media items from the library through filter predicates.
  • Cl
    MPMediaQuerySectioniOS 4.2+
    An object that describes a range of items grouped within a media query's results.
  • Cl
    MPMediaPredicateiOS 3.0+
    The abstract base class for predicates used to filter a media query.
  • Cl
    MPMediaPropertyPredicateiOS 3.0+
    A predicate that filters media items by comparing a property against a value.
  • En
    MPMediaGroupingiOS 3.0+
    Constants that specify how a media query groups and sorts its results.
  • En
    MPMediaPredicateComparisoniOS 3.0+
    Constants that specify how a property predicate compares its value.

Playlists 3

Representing and creating playlists in the user's library.

  • Cl
    MPMediaPlaylistiOS 3.0+
    A media item collection that represents a playlist in the user's library.
  • Cl
    MPMediaPlaylistCreationMetadataiOS 9.3+
    An object that describes the attributes used when creating a new playlist.
  • St
    MPMediaPlaylistAttributeiOS 3.0+
    An option set that describes the attributes of a playlist.

Picking Media 2

Presenting a system interface that lets the user choose media items from their library.

  • Cl
    MPMediaPickerControlleriOS 3.0+
    A view controller that lets the user choose media items from their library.
  • Pr
    MPMediaPickerControllerDelegate
    Methods for responding to the user's selection in a media picker controller.

Music Playback 6

Controlling the system or application music player and the items it plays.

  • Cl
    MPMusicPlayerControlleriOS 3.0+
    An object that plays media items from the user's library and controls playback.
  • Cl
    MPMusicPlayerApplicationControlleriOS 10.3+
    A music player that plays media within your app and maintains its own playback state.
  • Pr
    MPSystemMusicPlayerController
    A protocol that identifies a music player that controls the systemwide Music app.
  • En
    MPMusicPlaybackStateiOS 3.0+
    Constants that describe the current playback state of a music player.
  • En
    MPMusicRepeatModeiOS 3.0+
    Constants that specify how a music player repeats playback.
  • En
    MPMusicShuffleModeiOS 3.0+
    Constants that specify how a music player shuffles playback.

Managing the Playback Queue 7

Building and describing the queue of items a music player will play.

  • Cl
    MPMusicPlayerControllerQueueiOS 10.3+
    An object that represents the read-only playback queue of a music player.
  • Cl
    MPMusicPlayerControllerMutableQueueiOS 10.3+
    An object that represents a music player queue you can rearrange and modify.
  • Cl
    MPMusicPlayerQueueDescriptoriOS 10.1+
    The abstract base class for objects that describe the contents of a music player queue.
  • Cl
    MPMusicPlayerMediaItemQueueDescriptoriOS 10.1+
    A queue descriptor that builds a playback queue from a media query or item collection.
  • Cl
    MPMusicPlayerStoreQueueDescriptoriOS 10.1+
    A queue descriptor that builds a playback queue from store identifiers.
  • Cl
    MPMusicPlayerPlayParametersiOS 11.0+
    An object that encapsulates the parameters needed to play a piece of catalog content.
  • Cl
    MPMusicPlayerPlayParametersQueueDescriptoriOS 11.0+
    A queue descriptor that builds a playback queue from play parameters objects.

Movie Playback 13

The legacy movie player interface, its playback protocol, and presentation options.

  • Cl
    MPMoviePlayerController
    A legacy object that manages the playback of a movie from a file or network stream.
  • Cl
    MPMoviePlayerViewController
    A legacy view controller that presents full-screen movie playback.
  • Pr
    MPMediaPlaybackiOS 3.0+
    A protocol that defines the basic transport controls for an object that plays media.
  • Cl
    MPTimedMetadata
    An object that represents a piece of timed metadata delivered during playback.
  • St
    MPMovieLoadState
    An option set that indicates the network load state of a movie player.
  • St
    MPMovieMediaTypeMask
    An option set that indicates which media types are present in a movie.
  • En
    MPMovieScalingMode
    Constants that specify how a movie's video is scaled to fit its view.
  • En
    MPMoviePlaybackState
    Constants that describe the current playback state of a movie player.
  • En
    MPMovieRepeatMode
    Constants that specify how a movie player repeats playback.
  • En
    MPMovieControlStyle
    Constants that specify the style of the onscreen controls of a movie player.
  • En
    MPMovieFinishReason
    Constants that describe why movie playback ended.
  • En
    MPMovieSourceType
    Constants that specify whether a movie is a file or a streaming source.
  • En
    MPMovieTimeOption
    Constants that specify how a movie player resolves a requested playback time.

Movie Playback Logs 5

Diagnostic logs that record playback access and error events for a movie player.

  • Cl
    MPMovieAccessLog
    A log that records the playback access events for a movie player.
  • Cl
    MPMovieErrorLog
    A log that records the playback error events for a movie player.
  • Cl
    MPMovieAccessLogEvent
    An object that describes a single playback access event in a movie access log.
  • Cl
    MPMovieErrorLogEvent
    An object that describes a single playback error event in a movie error log.
  • Cl
    MPAdTimeRangeiOS 16.0+
    An object that describes the time range of an advertisement within playback content.

Now Playing Information 8

Publishing the currently playing item's metadata and managing a now playing session.

  • Cl
    MPNowPlayingInfoCenteriOS 5.0+
    An object that publishes information about the currently playing item to the system.
  • Cl
    MPNowPlayingSessioniOS 16.0+
    An object that coordinates now playing information and remote commands for a set of players.
  • Pr
    MPNowPlayingSessionDelegateiOS 16.0+
    Methods for responding to changes in a now playing session.
  • Cl
    MPNowPlayingInfoLanguageOptioniOS 9.0+
    Represents a single language option option.
  • Cl
    MPNowPlayingInfoLanguageOptionGroupiOS 9.0+
    An object that groups mutually exclusive language options for selection.
  • En
    MPNowPlayingInfoMediaTypeiOS 10.0+
    Constants that identify the media type reported in now playing information.
  • En
    MPNowPlayingPlaybackStateiOS 11.0+
    Constants that describe the playback state reported in a now playing session.
  • En
    MPNowPlayingInfoLanguageOptionTypeiOS 9.0+
    Constants that identify the type of a now playing language option.

Remote Command Center 10

Registering handlers for remote control commands sent from the Control Center, headphones, and other accessories.

  • Cl
    MPRemoteCommandCenteriOS 7.1+
    A central object that vends the remote control commands your app responds to.
  • Cl
    MPRemoteCommandiOS 7.1+
    An object that responds to a specific remote control command from an external accessory.
  • Cl
    MPSkipIntervalCommandiOS 7.1+
    A remote command that skips playback forward or backward by a set interval.
  • Cl
    MPFeedbackCommandiOS 7.1+
    A remote command that submits like, dislike, or bookmark feedback for the current item.
  • Cl
    MPRatingCommandiOS 7.1+
    A remote command that sets a numeric rating for the current item.
  • Cl
    MPChangePlaybackRateCommandiOS 7.1+
    A remote command that changes the current playback rate.
  • Cl
    MPChangePlaybackPositionCommandiOS 9.0+
    Command for changing the current playback position in a now playing item.
  • Cl
    MPChangeShuffleModeCommandiOS 8.0+
    Command for changing the current shuffle mode to use during playback. To
  • Cl
    MPChangeRepeatModeCommandiOS 8.0+
    Command for changing the current repeat mode to use during playback. To
  • En
    MPRemoteCommandHandlerStatusiOS 7.1+
    Constants that a remote command handler returns to report the result of handling an event.

Remote Command Events 14

The event objects delivered to remote command handlers and the constants that describe them.

  • Cl
    MPRemoteCommandEventiOS 7.1+
    The base event object delivered when a remote command is invoked.
  • Cl
    MPSkipIntervalCommandEventiOS 7.1+
    An event delivered when a skip-interval remote command is invoked.
  • Cl
    MPSeekCommandEventiOS 7.1+
    An event delivered when a seek remote command begins or ends.
  • Cl
    MPRatingCommandEventiOS 7.1+
    An event delivered when a rating remote command is invoked, carrying the chosen rating.
  • Cl
    MPChangePlaybackRateCommandEventiOS 7.1+
    An event delivered when a change-playback-rate remote command is invoked.
  • Cl
    MPFeedbackCommandEventiOS 7.1+
    An event delivered when a feedback remote command is invoked.
  • Cl
    MPChangeLanguageOptionCommandEventiOS 9.0+
    An event delivered when a change-language-option remote command is invoked.
  • Cl
    MPChangePlaybackPositionCommandEventiOS 8.0+
    An event delivered when a change-playback-position remote command is invoked.
  • Cl
    MPChangeShuffleModeCommandEventiOS 8.0+
    An event delivered when a change-shuffle-mode remote command is invoked.
  • Cl
    MPChangeRepeatModeCommandEventiOS 8.0+
    An event delivered when a change-repeat-mode remote command is invoked.
  • En
    MPSeekCommandEventTypeiOS 7.1+
    Constants that indicate whether a seek command event is beginning or ending.
  • En
    MPShuffleTypeiOS 3.0+
    Constants that specify a shuffle mode for a remote command event.
  • En
    MPRepeatTypeiOS 3.0+
    Constants that specify a repeat mode for a remote command event.
  • En
    MPChangeLanguageOptionSettingiOS 9.3+
    Constants that specify the scope of a language option change request.

Playable Content 5

Exposing a hierarchy of playable content to external playback systems such as CarPlay.

  • Cl
    MPPlayableContentManager
    MPPlayableContentManager is a class that manages the interactions between a
  • Cl
    MPPlayableContentManagerContext
    MPPlayableContentManagerContext represents the current state of
  • Pr
    MPPlayableContentDataSource
    MPPlayableContentDataSource is a protocol that application objects conform to
  • Pr
    MPPlayableContentDelegate
    The MPPlayableContentDelegate is a protocol that allows for external media
  • Cl
    MPContentItemiOS 7.1+
    MPContentItem represents high-level metadata for a particular media item for

Volume Control 1

A standard view for adjusting system audio volume and choosing an output route.

  • Cl
    MPVolumeViewiOS 2.0+
    A view that presents controls for adjusting system audio volume and selecting an output route.

Errors 1

The error domain used by the framework.

  • St
    MPErroriOS 9.3+
    A structure that describes errors reported by the MediaPlayer framework.

Classes 1

  • Cl
    MPAppEntityIdentifieriOS 27.0+

Type Aliases 1

  • Ty
    MPMediaEntityPersistentID

Extends 6

AVMediaSelectionOptionAVMediaSelectionGroupAVPlayerItemNSNotificationUIViewControllerNSUserActivity
← Audio