iOS Developer Library

Developer

MediaPlayer Framework Reference MPRemoteCommandCenter Class Reference

Options
Deployment Target:

On This Page
Language:

MPRemoteCommandCenter

Inherits From


Conforms To


Import Statement


Swift

import MediaPlayer

Objective-C

@import MediaPlayer;

Availability


Available in iOS 7.1 and later

The MPRemoteCommandCenter class vends objects for handling remote control events sent by external accessories and system transport controls. Do not create instances of this class yourself. Instead, use the sharedCommandCenter method to retrieve the shared command center object. The properties of the shared command center object contain MPRemoteCommand objects for each type of remote control event supported by iOS. To respond to a particular event, register a handler with the appropriate MPRemoteCommand object.

The remote command center object provides command objects for many different types of events. If your app does not support a particular type of event, you can disable the corresponding MPRemoteCommand object by setting its enabled property to NOfalse. Registering a handler with a command object lets the system know that your app is ready to receive events. Event delivery occurs only while your app is the Now Playing app.

  • Returns the shared object you use to access the system’s remote command objects.

    Declaration

    Swift

    class func sharedCommandCenter() -> MPRemoteCommandCenter!

    Objective-C

    + (MPRemoteCommandCenter *)sharedCommandCenter

    Return Value

    The shared instance of the MPRemoteCommandCenter class.

    Discussion

    After using this method to retrieve the shared command center, use its properties to access the corresponding MPRemoteCommand objects and register your handlers. You might also access those command objects so that you can disable the ones that your app does not support.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for pausing playback of the current item. (read-only)

    Declaration

    Swift

    var pauseCommand: MPRemoteCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPRemoteCommand *pauseCommand

    Discussion

    Use the object in this property to register your app’s handler for pausing the currently playing track. In your handler, pause playback of the current item but maintain the current play position. You can disable the command if your app does not support it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for starting playback of the current item. (read-only)

    Declaration

    Swift

    var playCommand: MPRemoteCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPRemoteCommand *playCommand

    Discussion

    Use the object in this property to register your app’s handler for pausing the currently playing track. In your handler, play the current item from the point at which the track was paused, or from the beginning if the item was not paused. You can disable the command if your app does not support it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for stopping playback of the current item. (read-only)

    Declaration

    Swift

    var stopCommand: MPRemoteCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPRemoteCommand *stopCommand

    Discussion

    Use the object in this property to register your app’s handler for stopping playback of the current track. In your handler, stop playback the current item. You can disable the command if your app does not support it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for toggling between playing and pausing the current item. (read-only)

    Declaration

    Swift

    var togglePlayPauseCommand: MPRemoteCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPRemoteCommand *togglePlayPauseCommand

    Discussion

    Use the object in this property to register your app’s handler for toggling between playing and pausing the current track. In your handler, perform the appropriate task based on the current state of the media item. If the item is currently playing, pause it. If it is paused, resume playing it. You can disable the command if your app does not support it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for selecting the next track. (read-only)

    Declaration

    Swift

    var nextTrackCommand: MPRemoteCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPRemoteCommand *nextTrackCommand

    Discussion

    Use the object in this property to register your app’s handler for selecting the next track. In your handler, select the media item that follows the current media item. You can disable the command if your app does not support it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for selecting the previous track. (read-only)

    Declaration

    Swift

    var previousTrackCommand: MPRemoteCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPRemoteCommand *previousTrackCommand

    Discussion

    Use the object in this property to register your app’s handler for selecting the previous track. In your handler, select the media item that precedes the current media item. You can disable the command if your app does not support it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for changing the playback rate of the current media item. (read-only)

    Declaration

    Swift

    var changePlaybackRateCommand: MPChangePlaybackRateCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPChangePlaybackRateCommand *changePlaybackRateCommand

    Discussion

    Use the object in this property to register your app’s handler for changing the playback rate of the current track. In your handler, change the playback rate to the new value. The current playback rate cannot be negative. You can disable the command if your app does not support it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for seeking backward through a single media item. (read-only)

    Declaration

    Swift

    var seekBackwardCommand: MPRemoteCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPRemoteCommand *seekBackwardCommand

    Discussion

    Use the object in this property to register your app’s handler for seeking backward in the current track. In your handler, begin seeking backward through the current media item. You can disable the command if your app does not support it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for seeking forward through a single media item. (read-only)

    Declaration

    Swift

    var seekForwardCommand: MPRemoteCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPRemoteCommand *seekForwardCommand

    Discussion

    Use the object in this property to register your app’s handler for seeking forward in the current track. In your handler, begin seeking forward through the current media item. You can disable the command if your app does not support it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for playing a previous point in a media item. (read-only)

    Declaration

    Swift

    var skipBackwardCommand: MPSkipIntervalCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPSkipIntervalCommand *skipBackwardCommand

    Discussion

    Use the object in this property to register your app’s handler for jumping to a previous point in the current track. In your handler, skip backwards by the amount specified in the event’s interval property. You can disable the command if your app does not support it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for playing a future point in a media item. (read-only)

    Declaration

    Swift

    var skipForwardCommand: MPSkipIntervalCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPSkipIntervalCommand *skipForwardCommand

    Discussion

    Use the object in this property to register your app’s handler for jumping to a future point in the current track. In your handler, skip forward by the amount specified in the event’s interval property. You can disable the command if your app does not support it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for rating a media item. (read-only)

    Declaration

    Swift

    var ratingCommand: MPRatingCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPRatingCommand *ratingCommand

    Discussion

    Use the object in this property to register your app’s handler for rating the current track. In your handler, apply the specified rating to the track. You can disable the command if your app does not support it.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for indicating that a user likes what is currently playing. (read-only)

    Declaration

    Swift

    var likeCommand: MPFeedbackCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPFeedbackCommand *likeCommand

    Discussion

    Use the object in this property to register your app’s handler for liking an item. Use your handler to register the user’s preference for a track, artist, or whatever is appropriate for your app. You can disable the command if your app does not support it.

    In addition to registering a handler, you can use the command object to provide a localized string to communicate what is being liked to the user.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for indicating that a user dislikes what is currently playing. (read-only)

    Declaration

    Swift

    var dislikeCommand: MPFeedbackCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPFeedbackCommand *dislikeCommand

    Discussion

    Use the object in this property to register your app’s handler for disliking the current track. Use your handler to register the user’s dislike for a track, artist, or whatever is appropriate for your app. You can disable the command if your app does not support it.

    In addition to registering a handler, you can use the command object to provide a localized string to communicate what is being liked to the user.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later

  • The command object for indicating that a user wants to remember a media item. (read-only)

    Declaration

    Swift

    var bookmarkCommand: MPFeedbackCommand! { get }

    Objective-C

    @property(nonatomic, readonly) MPFeedbackCommand *bookmarkCommand

    Discussion

    Use the object in this property to register your app’s handler for bookmarking the current track. In your handler, add the track to the user’s list of bookmarks. You can disable the command if your app does not support it.

    In addition to registering a handler, you can use the command object to provide a localized string to communicate what is being bookmarked to the user.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later