<!--
{
  "documentType" : "article",
  "framework" : "NowPlaying",
  "identifier" : "/documentation/NowPlaying/playback-commands",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Playback commands"
}
-->

# Playback commands

Declare the playback controls your app supports.

## Overview

Use [`MediaCommand`](/documentation/NowPlaying/MediaCommand) to define the controls available for your Now Playing session. The system displays these controls on the Lock Screen, Control Center, and connected accessories. Each command takes an action closure that the system invokes when someone interacts with a control.

Return an array of commands from your [`commands`](/documentation/NowPlaying/MediaSessionRepresentable/commands) property. Create each command with a static factory method on [`MediaCommand`](/documentation/NowPlaying/MediaCommand):

```swift
var commands: [MediaCommand] {
    [
        .play { self.play() },
        .pause { self.pause() },
        .next { self.next() }.enabled(hasNextTrack),
        .previous { self.previous() }.enabled(hasPreviousTrack),
        .seekToPosition { time in
            self.seek(to: time)
        },
    ]
}
```

Use [`enabled(_:)`](/documentation/NowPlaying/MediaCommand/enabled(_:)) to make a command available or unavailable based on your app’s state. Unavailable commands still appear in the interface, but the system doesn’t invoke their handler.

## Topics

### Creating commands

[`struct MediaCommand`](/documentation/NowPlaying/MediaCommand)

A command that describes a media control action for a Now Playing session.

[`func enabled(Bool) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/enabled(_:))

Sets the enabled state for this command.

### Controlling playback

[`static func play(() async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/play(_:))

Creates a command that starts media playback.

[`static func pause(() async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/pause(_:))

Creates a command that pauses media playback.

[`static func stop(() async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/stop(_:))

Creates a command that stops media playback.

[`static func togglePlayPause(() async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/togglePlayPause(_:))

Creates a command that toggles between play and pause states.

### Navigating commands

[`static func next(() async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/next(_:))

Creates a command that advances to the next track in the playback queue.

[`static func previous(() async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/previous(_:))

Creates a command that returns to the previous track in the playback queue.

[`static func skipForward(preferredIntervals: [TimeInterval], (TimeInterval) async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/skipForward(preferredIntervals:_:))

Creates a command that skips forward in the media by a specified time interval.

[`static func skipBackward(preferredIntervals: [TimeInterval], (TimeInterval) async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/skipBackward(preferredIntervals:_:))

Creates a command that skips backward in the media by a specified time interval.

### Seeking

[`static func seekToPosition((TimeInterval) async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/seekToPosition(_:))

Creates a command that seeks to a specific position in the media.

[`static func seekForward(beginAction: () async throws -> Void, endAction: () async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/seekForward(beginAction:endAction:))

Creates a command that fast-forwards through the media.

[`static func seekBackward(beginAction: () async throws -> Void, endAction: () async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/seekBackward(beginAction:endAction:))

Creates a command that rewinds through the media.

### Changing playback modes

[`static func changePlaybackRate(supported: [Float], (Float) async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/changePlaybackRate(supported:_:))

Creates a command that changes the playback rate of the media.

[`static func changeRepeatMode(current: MediaCommand.RepeatMode, supported: [MediaCommand.RepeatMode]?, (MediaCommand.RepeatMode) async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/changeRepeatMode(current:supported:_:))

Creates a command that changes the repeat mode for media playback.

[`static func changeShuffleMode(current: MediaCommand.ShuffleMode, supported: [MediaCommand.ShuffleMode]?, (MediaCommand.ShuffleMode) async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/changeShuffleMode(current:supported:_:))

Creates a command that changes the shuffle mode for media playback.

[`enum RepeatMode`](/documentation/NowPlaying/MediaCommand/RepeatMode)

The repeat mode for media playback.

[`enum ShuffleMode`](/documentation/NowPlaying/MediaCommand/ShuffleMode)

The shuffle mode for media playback.

### Providing feedback

[`static func feedback(title: String?, shortTitle: String?, status: MediaCommand.FeedbackStatus, (MediaCommand.FeedbackStatus) async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/feedback(title:shortTitle:status:_:))

Creates a command that handles user feedback (positive, neutral, or negative) for the current content.

[`enum FeedbackStatus`](/documentation/NowPlaying/MediaCommand/FeedbackStatus)

The feedback status for a media item.



---

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)