<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NowPlaying",
  "identifier" : "/documentation/NowPlaying/MediaCommand",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Now Playing"
    ],
    "preciseIdentifier" : "s:10NowPlaying12MediaCommandV"
  },
  "title" : "MediaCommand"
}
-->

# MediaCommand

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

```
struct MediaCommand
```

## Overview

Use static factory methods to create commands for your session:

```swift
var commands: [MediaCommand] {[
    .play { await self.play() },
    .pause { await self.pause() },
    .next { await self.nextTrack() }.enabled(self.hasNextTrack),
]}
```

## Topics

### Instance Methods

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

Sets the enabled state for this command.

### Type Methods

[`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.

[`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.

[`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 pause(() async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/pause(_:))

Creates a command that pauses media playback.

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

Creates a command that starts media playback.

[`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 seekBackward(beginAction: () async throws -> Void, endAction: () async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/seekBackward(beginAction:endAction:))

Creates a command that rewinds through 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 seekToPosition((TimeInterval) async throws -> Void) -> MediaCommand`](/documentation/NowPlaying/MediaCommand/seekToPosition(_:))

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

[`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.

[`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 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.

### Enumerations

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

The feedback status for a media item.

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

The repeat mode for media playback.

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

The shuffle mode for media playback.

---

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)