Protocol

MPMediaPlayback

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

Declaration

protocol MPMediaPlayback

Overview

This protocol supports basic transport operations including start, stop, and pause, and also lets you seek forward and back through media or to a specific point in its timeline.

Topics

Starting and Stopping Playback

func play()

Initiates playback of the current item.

Required.

func pause()

Pauses playback of the current item.

Required.

func stop()

Ends playback of the current item.

Required.

func prepareToPlay()

Prepares a media player for playback.

Required.

var isPreparedToPlay: Bool

A Boolean value indicating whether a media player is ready to play.

Required.

Seeking Within Media

func beginSeekingBackward()

Begins seeking backward through the media content.

Required.

func beginSeekingForward()

Begins seeking forward through the media content.

Required.

func endSeeking()

Ends forward and backward seeking through the media content.

Required.

Accessing Playback Attributes

var currentPlaybackRate: Float

The current playback rate for the player.

Required.

var currentPlaybackTime: TimeInterval

The current position of the playhead.

Required.

Notifications

static let MPMediaPlaybackIsPreparedToPlayDidChange: NSNotification.Name

Indicates that the prepared to play status of the media player has changed.

Deprecated

Relationships

See Also

Built-In Music Playback

Playing Audio Using the Built-In Music Player

Create a media player inside your app to play audio from the user's media library.

class MPMusicPlayerController

An object used to play audio media items from the device's Music app library.

protocol MPSystemMusicPlayerController

A protocol for playing videos in the Music app.