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),
]}
```
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.