MPMediaPlayback Protocol Reference

Framework
/System/Library/Frameworks/MediaPlayer.framework
Availability
Available in iOS 3.2 and later.
Declared in
MPMediaPlayback.h

Overview

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.

Tasks

Starting and Stopping Playback

Seeking Within Media

Accessing Playback Attributes

Properties

currentPlaybackRate

The current playback rate for the player. (required)

@property(nonatomic) float currentPlaybackRate
Discussion

This value represents a multiplier for the default playback rate of the current item. A value of 0.0 indicates that playback is stopped while a value of 1.0 indicates that playback is occurring at normal speed. Positive values indicate forward playback while negative values indicate reverse playback.

Setting the value of this property changes the playback rate accordingly.

Availability
  • Available in iOS 3.2 and later.
Declared In
MPMediaPlayback.h

currentPlaybackTime

The current position of the playhead. (required)

@property(nonatomic) NSTimeInterval currentPlaybackTime
Discussion

For video-on-demand or progressively downloaded content, this value is measured in seconds from the beginning of the current item. Changing the value of this property moves the playhead to the new location. For content streamed live from a server, this value represents the time from the beginning of the playlist when it was first loaded.

Availability
  • Available in iOS 3.2 and later.
Declared In
MPMediaPlayback.h

isPreparedToPlay

A Boolean value indicating whether a movie player is ready to play. (required) (read-only)

@property(nonatomic, readonly) BOOL isPreparedToPlay
Availability
  • Available in iOS 3.2 and later.
Declared In
MPMediaPlayback.h

Instance Methods

beginSeekingBackward

Begins seeking backward through the media content. (required)

- (void)beginSeekingBackward
Discussion

Use this method to move the current playback position backward in time at an accelerated rate. Seeking begins when you call this method and continues until you call the endSeeking method.

If the underlying content is streamed, this method has no effect.

Availability
  • Available in iOS 3.2 and later.
Declared In
MPMediaPlayback.h

beginSeekingForward

Begins seeking forward through the media content. (required)

- (void)beginSeekingForward
Discussion

Use this method to move the current playback position forward in time at an accelerated rate. Seeking begins when you call this method and continues until you call the endSeeking method.

If the underlying content is streamed, this method has no effect.

Availability
  • Available in iOS 3.2 and later.
Declared In
MPMediaPlayback.h

endSeeking

Ends forward and backward seeking through the media content. (required)

- (void)endSeeking
Discussion

You must call this method to end a seeking operation begun by calling either the beginSeekingBackward or beginSeekingForward method. After calling this method, the player returns to the same state it was in prior to seeking. In other words, if the item was playing before seeking began, it continues playing from the new playhead position after calling this method.

If the underlying content is streamed, this method has no effect.

Availability
  • Available in iOS 3.2 and later.
Declared In
MPMediaPlayback.h

pause

Pauses playback of the current item. (required)

- (void)pause
Discussion

If playback is not currently underway, this method has no effect. To resume playback of the current item from the pause point, call the play method.

Availability
  • Available in iOS 3.2 and later.
Declared In
MPMediaPlayback.h

play

Initiates playback of the current item. (required)

- (void)play
Discussion

If playback was previously paused, this method resumes playback where it left off; otherwise, this method plays the first available item, from the beginning.

If a movie player is not prepared for playback when you call this method, this method first prepares the movie player and then starts playback. To minimize playback delay, call the prepareToPlay method before you call this method.

To be notified when a movie player is ready to play, register for the MPMoviePlayerLoadStateDidChangeNotification notification. You can then check load state by accessing the movie player’s loadState property.

Availability
  • Available in iOS 3.2 and later.
Declared In
MPMediaPlayback.h

prepareToPlay

Prepares a movie player for playback. (required)

- (void)prepareToPlay
Discussion

If a movie player is not already prepared to play when you call the play method, that method automatically calls this method. However, to minimize playback delay, call this method before you call play.

Calling this method may interrupt the movie player’s audio session. For information on interruptions and how to resond to them, see Audio Session Programming Guide.

Availability
  • Available in iOS 3.2 and later.
Declared In
MPMediaPlayback.h

stop

Ends playback of the current item. (required)

- (void)stop
Discussion

This method stops playback of the current item and resets the playhead to the start of the item. Calling the play method again initiates playback from the beginning of the item.

Availability
  • Available in iOS 3.2 and later.
Related Sample Code
Declared In
MPMediaPlayback.h

Notifications

MPMediaPlaybackIsPreparedToPlayDidChangeNotification

Posted upon change in the prepared-to-play state of an object conforming to the MPMediaPlayback protocol. The object whose state has changed is available as the object associated with the notification.
Availability
Declared In
MPMediaPlayback.h