<!--
{
  "availability" : [
    "iOS: 7.1.0 -",
    "iPadOS: 7.1.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.2 -",
    "tvOS: 7.1.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaPlayer",
  "identifier" : "/documentation/MediaPlayer/MPRemoteCommand",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Media Player"
    ],
    "preciseIdentifier" : "c:objc(cs)MPRemoteCommand"
  },
  "title" : "MPRemoteCommand"
}
-->

# MPRemoteCommand

An object that responds to remote command events.

```
class MPRemoteCommand
```

## Overview

The Media Player framework defines a standard set of remote command objects for handling media-related events. When an accessory or iOS user interface generates a remote control event, the system notifies the corresponding command object on the shared [`MPRemoteCommandCenter`](/documentation/MediaPlayer/MPRemoteCommandCenter) instance. That command object executes any attached handlers.

To respond to a particular event, register a handler with the appropriate [`MPRemoteCommand`](/documentation/MediaPlayer/MPRemoteCommand) object.

Listing 1. Registering a remote control event handler

```swift
// Get the shared command center.
let commandCenter = MPRemoteCommandCenter.shared()

// Add a handler for the play command.
commandCenter.playCommand.addTarget { [unowned self] event in
    if self.player.rate == 0.0 {
        self.player.play()
        return .success
    }
    return .commandFailed
}
```

If you explicitly don’t want to enable a given command, fetch the command object and set its enabled property to <doc://com.apple.documentation/documentation/Swift/false>. Disabling a remote command lets the system know that it shouldn’t display any related UI for that command when your app is the Now Playing app.

The framework defines many subclasses to handle specific kinds of commands. Sometimes, these subclasses let you specify other information related to the command. For example, feedback commands let you specify a localized string that describes the meaning of the feedback. When supporting a particular command, be sure to look up the specific class used to handle those events.

## Topics

### Handling events

[`-  addTargetWithHandler:`](/documentation/MediaPlayer/MPRemoteCommand/addTarget(handler:))

Adds a block to be called when an event is received.

[`-  addTarget:action:`](/documentation/MediaPlayer/MPRemoteCommand/addTarget(_:action:))

Adds a target object to be called when an event is received.

[`-  removeTarget:`](/documentation/MediaPlayer/MPRemoteCommand/removeTarget(_:))

Removes a target from the remote command object.

[`-  removeTarget:action:`](/documentation/MediaPlayer/MPRemoteCommand/removeTarget(_:action:))

Removes a target and action from a remote command object.

[`MPRemoteCommandHandlerStatus`](/documentation/MediaPlayer/MPRemoteCommandHandlerStatus)

Constants indicating the status of a command.

### Enabling a command object

[`enabled`](/documentation/MediaPlayer/MPRemoteCommand/isEnabled)

A Boolean value that indicates whether a user can interact with the displayed element.

## Relationships

### Inherited By

[`MPSkipIntervalCommand`](/documentation/MediaPlayer/MPSkipIntervalCommand)

[`MPRatingCommand`](/documentation/MediaPlayer/MPRatingCommand)

[`MPChangeRepeatModeCommand`](/documentation/MediaPlayer/MPChangeRepeatModeCommand)

[`MPChangePlaybackRateCommand`](/documentation/MediaPlayer/MPChangePlaybackRateCommand)

[`MPChangePlaybackPositionCommand`](/documentation/MediaPlayer/MPChangePlaybackPositionCommand)

[`MPChangeShuffleModeCommand`](/documentation/MediaPlayer/MPChangeShuffleModeCommand)

[`MPFeedbackCommand`](/documentation/MediaPlayer/MPFeedbackCommand)

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)