iOS Developer Library

Developer

MediaPlayer Framework Reference MPNowPlayingInfoCenter Class Reference

Options
Deployment Target:

On This Page
Language:

MPNowPlayingInfoCenter

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.

Inheritance


Conforms To


Import Statement


Swift

import MediaPlayer

Objective-C

@import MediaPlayer;

Availability


Available in iOS 5.0 and later.
  • Returns the singleton now playing info center.

    Declaration

    Swift

    class func defaultCenter() -> MPNowPlayingInfoCenter!

    Objective-C

    + (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.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 5.0 and later.

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

    Declaration

    Swift

    var nowPlayingInfo: [NSObject : AnyObject]!

    Objective-C

    @property(copy) NSDictionary *nowPlayingInfo

    Discussion

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

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 5.0 and later.

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

    Declaration

    Swift

    let MPNowPlayingInfoPropertyElapsedPlaybackTime: NSString! let MPNowPlayingInfoPropertyPlaybackRate: NSString! let MPNowPlayingInfoPropertyPlaybackQueueIndex: NSString! let MPNowPlayingInfoPropertyPlaybackQueueCount: NSString! let MPNowPlayingInfoPropertyChapterNumber: NSString! let MPNowPlayingInfoPropertyChapterCount: NSString!

    Objective-C

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

    Constants

    • MPNowPlayingInfoPropertyElapsedPlaybackTime

      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.

    • MPNowPlayingInfoPropertyPlaybackRate

      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.

    • MPNowPlayingInfoPropertyPlaybackQueueIndex

      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.

    • MPNowPlayingInfoPropertyPlaybackQueueCount

      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.

    • MPNowPlayingInfoPropertyChapterNumber

      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.

    • MPNowPlayingInfoPropertyChapterCount

      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.