MPNowPlayingInfoCenter Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/MediaPlayer.framework
Availability
Available in iOS 5.0 and later.
Declared in
MPNowPlayingInfoCenter.h

Overview

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

The system displays now-playing information on the device lock screen and in the multimedia controls in the multitasking UI. If the user directs playback of your media to Apple TV via AirPlay, the now-playing information appears on the television screen. If the user connects a device to an iPod accessory, such as in a car, the accessory may display now-playing information.

The information you can specify includes a subset of the properties available in the media item class (MPMediaItem), as well as some properties specific to this class. In iOS 5.0, the now playing info center supports the following media item property keys:

Additional properties you can set are described in this document in “Additional Metadata Properties.”

You do not have direct control over which information is displayed, or its formatting. You set the values of the now playing info center dictionary according to the information you want to provide to the system. The system, or the connected accessory, handles the information’s display in a consistent manner for all apps.

Tasks

Working with the Default Now Playing Info Center

Properties

nowPlayingInfo

The current now-playing information for the default now playing info center.

@property (copy) NSDictionary *nowPlayingInfo
Discussion

To clear the now playing info center dictionary, set it to nil.

Availability
  • Available in iOS 5.0 and later.
Declared In
MPNowPlayingInfoCenter.h

Class Methods

defaultCenter

Returns the singleton now playing info center.

+ (MPNowPlayingInfoCenter *)defaultCenter
Discussion

The default now playing info center holds now-playing information for the app that is designated as the receiver for remote-control events. For information on how to configure your app to receive remote-control events, see “Remote Control of Multimedia”.

Availability
  • Available in iOS 5.0 and later.
Declared In
MPNowPlayingInfoCenter.h

Constants

Additional Metadata Properties

These properties for the now playing info center dictionary supplement the available media item properties, as described in the Overview in this document.

NSString *const MPNowPlayingInfoPropertyElapsedPlaybackTime
NSString *const MPNowPlayingInfoPropertyPlaybackRate;
NSString *const MPNowPlayingInfoPropertyPlaybackQueueIndex;
NSString *const MPNowPlayingInfoPropertyPlaybackQueueCount;
NSString *const MPNowPlayingInfoPropertyChapterNumber;
NSString *const MPNowPlayingInfoPropertyChapterCount;
Constants
MPNowPlayingInfoPropertyElapsedPlaybackTime

The elapsed time of the now playing item, in seconds.

Value is an NSNumber object configured as a double. Elapsed time is automatically calculated, by the system, from the previously provided elapsed time and the playback rate. Do not update this property frequently—it is not necessary.

Available in iOS 5.0 and later.

Declared in MPNowPlayingInfoCenter.h.

MPNowPlayingInfoPropertyPlaybackRate

The playback rate of the now-playing item, with a value of 1.0 indicating the normal playback rate.

Value is an NSNumber object configured as a double. The default value is 1.0. A playback rate value of 2.0 means twice the normal playback rate; a piece of media played at this rate would take half as long to play to completion. A value of 0.5 means half the normal playback rate; a piece of media played at this rate would take twice as long to play to completion.

Available in iOS 5.0 and later.

Declared in MPNowPlayingInfoCenter.h.

MPNowPlayingInfoPropertyPlaybackQueueIndex

The index of the now-playing item in the app’s playback queue.

Value is an NSNumber object configured as an NSUInteger. The playback queue uses zero-based indexing. If you want the first item in the queue to be displayed as “item 1 of 10,” for example, set the item’s index to 0.

Available in iOS 5.0 and later.

Declared in MPNowPlayingInfoCenter.h.

MPNowPlayingInfoPropertyPlaybackQueueCount

The total number of items in the app’s playback queue.

Value is an NSNumber object configured as an NSUInteger.

Available in iOS 5.0 and later.

Declared in MPNowPlayingInfoCenter.h.

MPNowPlayingInfoPropertyChapterNumber

The number corresponding to the chapter currently being played.

Value is an NSNumber object configured as an NSUInteger. Chapter numbering uses zero-based indexing. If you want the first chapter in the now-playing item to be displayed as “Chapter 1,” for example, set the chapter number to 0.

Available in iOS 5.0 and later.

Declared in MPNowPlayingInfoCenter.h.

MPNowPlayingInfoPropertyChapterCount

The total number of chapters in the now-playing item.

Value is an NSNumber object configured as an NSUInteger.

Available in iOS 5.0 and later.

Declared in MPNowPlayingInfoCenter.h.