MediaSessionCommand class sealed
A command issued by the operating system's media session — pressed on the lockscreen, sent by a Bluetooth headset, triggered by Siri / Google Assistant, or forwarded by Android Auto / CarPlay.
Sealed because MediaSessionCommandSeekTo and MediaSessionCommandSeekBy carry Duration payloads that plain enums can't model. Pattern-match exhaustively in PlayerStream.mediaSessionCommands subscribers:
player.stream.mediaSessionCommands.listen((command) {
switch (command) {
case MediaSessionCommandPlay(): analytics.log('lockscreen-play');
case MediaSessionCommandSeekTo(:final position):
logging.info('user scrubbed to $position');
case _: break;
}
});
Commands are also auto-applied to the Player by default — the stream above is for analytics / interception only. The package routes next / previous to mpv's playlist when it holds more than one entry; otherwise the command is emit-only (the consumer's queue logic handles it).
- Implementers
- MediaSessionCommandLike
- MediaSessionCommandNext
- MediaSessionCommandPause
- MediaSessionCommandPlay
- MediaSessionCommandPlayPause
- MediaSessionCommandPrevious
- MediaSessionCommandSeekBy
- MediaSessionCommandSeekTo
- MediaSessionCommandSetPlaybackRate
- MediaSessionCommandSetRepeatMode
- MediaSessionCommandSetShuffle
- MediaSessionCommandStop
Constructors
- MediaSessionCommand.seekBy(Duration offset)
-
Seek by a relative offset from the current position. Negative
offsets rewind.
constfactory
- MediaSessionCommand.seekTo(Duration position)
-
Seek to an absolute position in the current track.
constfactory
- MediaSessionCommand.setPlaybackRate(double rate)
-
Change playback rate (e.g. 1.0 / 1.5 / 2.0). Auto-applied to
Player.setRate. The selectable rates are governed by
MediaSession.supportedPlaybackRates.
constfactory
- MediaSessionCommand.setRepeatMode(Loop loop)
-
Change the repeat mode (cycled through off / file / playlist by
the OS UI). Auto-applied to Player.setLoop.
constfactory
- MediaSessionCommand.setShuffle(bool shuffle)
-
Toggle shuffle. Auto-applied to Player.setShuffle.
constfactory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- like → const MediaSessionCommand
- The "like" / favourite control was pressed (advertise it with MediaAction.like). Emit-only: NOT auto-applied — there is no built-in favourite concept, so react to it on PlayerStream.mediaSessionCommands and reflect the new state back via MediaSession.isFavorite (fills/empties the star).
- next → const MediaSessionCommand
- Skip to the next track.
- pause → const MediaSessionCommand
- Pause playback.
- play → const MediaSessionCommand
- Start or resume playback.
- playPause → const MediaSessionCommand
- Toggle between play and pause. Sent by single-button hardware (most Bluetooth headsets, macOS spacebar key).
- previous → const MediaSessionCommand
- Skip to the previous track.
- stop → const MediaSessionCommand
- Stop playback and clear the now-playing entry.