One Logo Pool Ball
NowPlaying · IOS API REFERENCE

MediaCommand

struct · iOS 27.0+ · SDK 27.1

struct MediaCommand

A command that describes a media control action for a Now Playing session. 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), ]} ```

Members (16)

static · iOS 27.0+

seekForward

TypeScript
static seekForward(beginAction: (() => Promise<void>), endAction: (() => Promise<void>)): MediaCommand
Swift declaration
static func seekForward(beginAction: @escaping () async throws -> Void, endAction: @escaping () async throws -> Void) -> MediaCommand

Creates a command that fast-forwards through the media. The system calls `beginAction` when the user starts fast-forwarding (for example, by pressing and holding a fast-forward button), and calls `endAction` when the user stops. Use these paired actions to start and stop any rate change or scrubbing behavior. - Parameters: - beginAction: The closure the system calls to begin fast-forwarding. - endAction: The closure the system calls to end fast-forwarding.

static · iOS 27.0+

skipForward

TypeScript
static skipForward(preferredIntervals: Array<number>, action: ((arg0: number) => Promise<void>)): MediaCommand
Swift declaration
static func skipForward(preferredIntervals: [TimeInterval] = [10], _ action: @escaping (TimeInterval) async throws -> Void) -> MediaCommand

Creates a command that skips forward in the media by a specified time interval. - Parameters: - preferredIntervals: An array of preferred time intervals, in seconds. Defaults to 10 seconds. - action: The closure the system calls to skip forward. Receives the selected interval.

static · iOS 27.0+

seekBackward

TypeScript
static seekBackward(beginAction: (() => Promise<void>), endAction: (() => Promise<void>)): MediaCommand
Swift declaration
static func seekBackward(beginAction: @escaping () async throws -> Void, endAction: @escaping () async throws -> Void) -> MediaCommand

Creates a command that rewinds through the media. The system calls `beginAction` when the user starts rewinding (for example, by pressing and holding a rewind button), and calls `endAction` when the user stops. Use these paired actions to start and stop any rate change or scrubbing behavior. - Parameters: - beginAction: The closure the system calls to begin rewinding. - endAction: The closure the system calls to end rewinding.

static · iOS 27.0+

skipBackward

TypeScript
static skipBackward(preferredIntervals: Array<number>, action: ((arg0: number) => Promise<void>)): MediaCommand
Swift declaration
static func skipBackward(preferredIntervals: [TimeInterval] = [10], _ action: @escaping (TimeInterval) async throws -> Void) -> MediaCommand

Creates a command that skips backward in the media by a specified time interval. - Parameters: - preferredIntervals: An array of preferred time intervals, in seconds. Defaults to 10 seconds. - action: The closure the system calls to skip backward. Receives the selected interval.

static · iOS 27.0+

seekToPosition

TypeScript
static seekToPosition(action: ((arg0: number) => Promise<void>)): MediaCommand
Swift declaration
static func seekToPosition(_ action: @escaping (TimeInterval) async throws -> Void) -> MediaCommand

Creates a command that seeks to a specific position in the media. - Parameter action: The closure the system calls to seek to a position. Receives the target position in seconds.

static · iOS 27.0+

togglePlayPause

TypeScript
static togglePlayPause(action: (() => Promise<void>)): MediaCommand
Swift declaration
static func togglePlayPause(_ action: @escaping () async throws -> Void) -> MediaCommand

Creates a command that toggles between play and pause states. - Parameter action: The closure the system calls to toggle playback.

static · iOS 27.0+

changeRepeatMode

TypeScript
static changeRepeatMode(current: MediaCommand_RepeatMode, supported: (Array<MediaCommand_RepeatMode>) | null, action: ((arg0: MediaCommand_RepeatMode) => Promise<void>)): MediaCommand
Swift declaration
static func changeRepeatMode(current: MediaCommand.RepeatMode, supported: [MediaCommand.RepeatMode]? = nil, _ action: @escaping (MediaCommand.RepeatMode) async throws -> Void) -> MediaCommand

Creates a command that changes the repeat mode for media playback. - Parameters: - current: The current repeat mode. - supported: The supported repeat modes. Pass `nil` to support all modes. - action: The closure the system calls to change the repeat mode.

static · iOS 27.0+

changeShuffleMode

TypeScript
static changeShuffleMode(current: MediaCommand_ShuffleMode, supported: (Array<MediaCommand_ShuffleMode>) | null, action: ((arg0: MediaCommand_ShuffleMode) => Promise<void>)): MediaCommand
Swift declaration
static func changeShuffleMode(current: MediaCommand.ShuffleMode, supported: [MediaCommand.ShuffleMode]? = nil, _ action: @escaping (MediaCommand.ShuffleMode) async throws -> Void) -> MediaCommand

Creates a command that changes the shuffle mode for media playback. - Parameters: - current: The current shuffle mode. - supported: The supported shuffle modes. Pass `nil` to support all modes. - action: The closure the system calls to change the shuffle mode.

static · iOS 27.0+

changePlaybackRate

TypeScript
static changePlaybackRate(supported: Array<number>, action: ((arg0: number) => Promise<void>)): MediaCommand
Swift declaration
static func changePlaybackRate(supported: [Float], _ action: @escaping (Float) async throws -> Void) -> MediaCommand

Creates a command that changes the playback rate of the media. - Parameters: - supported: An array of playback rates your app can play at. - action: The closure the system calls to change the playback rate.

static · iOS 27.0+

next

TypeScript
static next(action: (() => Promise<void>)): MediaCommand
Swift declaration
static func next(_ action: @escaping () async throws -> Void) -> MediaCommand

Creates a command that advances to the next track in the playback queue. - Parameter action: The closure the system calls to advance to the next track.

static · iOS 27.0+

play

TypeScript
static play(action: (() => Promise<void>)): MediaCommand
Swift declaration
static func play(_ action: @escaping () async throws -> Void) -> MediaCommand

Creates a command that starts media playback. - Parameter action: The closure the system calls to start playback.

static · iOS 27.0+

stop

TypeScript
static stop(action: (() => Promise<void>)): MediaCommand
Swift declaration
static func stop(_ action: @escaping () async throws -> Void) -> MediaCommand

Creates a command that stops media playback. - Parameter action: The closure the system calls to stop playback.

static · iOS 27.0+

pause

TypeScript
static pause(action: (() => Promise<void>)): MediaCommand
Swift declaration
static func pause(_ action: @escaping () async throws -> Void) -> MediaCommand

Creates a command that pauses media playback. - Parameter action: The closure the system calls to pause playback.

method · iOS 27.0+

enabled

TypeScript
enabled(isEnabled: boolean): MediaCommand
Swift declaration
func enabled(_ isEnabled: Bool) -> MediaCommand

Sets the enabled state for this command. - Parameter isEnabled: If `true`, the command is enabled; if `false`, the command is disabled.

static · iOS 27.0+

feedback

TypeScript
static feedback(title: (string) | null, shortTitle: (string) | null, status: MediaCommand_FeedbackStatus, action: ((arg0: MediaCommand_FeedbackStatus) => Promise<void>)): MediaCommand
Swift declaration
static func feedback(title: String? = nil, shortTitle: String? = nil, status: MediaCommand.FeedbackStatus = .neutral, _ action: @escaping (MediaCommand.FeedbackStatus) async throws -> Void) -> MediaCommand

Creates a command that handles user feedback (positive, neutral, or negative) for the current content. - Parameters: - title: A localized string that describes the context of the command. - shortTitle: A shortened version of the title. - status: The current feedback status for the content. - action: The closure the system calls when the user changes the feedback status.

static · iOS 27.0+

previous

TypeScript
static previous(action: (() => Promise<void>)): MediaCommand
Swift declaration
static func previous(_ action: @escaping () async throws -> Void) -> MediaCommand

Creates a command that returns to the previous track in the playback queue. - Parameter action: The closure the system calls to return to the previous track.

Skipped declarations

No declarations were skipped in this snapshot.

All NowPlaying types →