Skip to main content

Interface: PlaybackState

Defined in: packages/media-session/src/types.ts:30

The broadcast playback state, as the app writes it.

Differs from the bridge's NativePlaybackState only in optionality: controls, capabilities and customActions default to empty here, because "no buttons" is a perfectly ordinary state and [] is noise at the call site. normalizePlaybackState fills them in.

Properties

bufferedPosition?

optional bufferedPosition?: number;

Defined in: packages/media-session/src/types.ts:46

Buffered position in ms; omit when unknown.

Android only — media3 draws it as the secondary bar behind the scrubber. MediaPlayer has no buffered-position key anywhere in MPNowPlayingInfoCenter (the nearest, MPNowPlayingInfoPropertyPlaybackProgress, is a watched-so-far indicator, not a buffer level), so it renders nothing on iOS. Harmless to send on both.


capabilities?

optional capabilities?: MediaCapability[];

Defined in: packages/media-session/src/types.ts:50

Commands to accept.

Default

[]

compactControlIndices?

optional compactControlIndices?: number[];

Defined in: packages/media-session/src/types.ts:64

Android only: which of controls occupy the ≤3 collapsed notification slots. Omit to take the first three. iOS has no button layout — commands are enabled or not and the system draws what it draws — so this is ignored there.


controls?

optional controls?: MediaControl[];

Defined in: packages/media-session/src/types.ts:48

Buttons to offer, in order.

Default

[]

customActions?

optional customActions?: MediaCustomAction[];

Defined in: packages/media-session/src/types.ts:57

Extra buttons with app-defined meanings. Android only: MPRemoteCommandCenter's command set is fixed and closed, so iOS has no surface that can render or invoke one — see MediaCustomAction. Presses arrive at MediaHandler.customAction.

Default

[]

errorMessage?

optional errorMessage?: string;

Defined in: packages/media-session/src/types.ts:75

Only meaningful when status === 'error'.

Android only: it becomes the session's PlaybackException message. MediaPlayer has no error surface at all and cannot even distinguish error from paused (see MediaPlaybackStatus), so an errored session looks paused on the iOS lock screen. Show the message in your own UI.


position

position: PositionAnchor;

Defined in: packages/media-session/src/types.ts:36

Position anchor — { value, at, rate }. Broadcast on discontinuities only; every surface projects locally. See PositionAnchor.


queueIndex?

optional queueIndex?: number;

Defined in: packages/media-session/src/types.ts:66

Index into the last broadcast queue, or -1/omitted when not queue-backed.


repeatMode?

optional repeatMode?: MediaRepeatMode;

Defined in: packages/media-session/src/types.ts:85

Current repeat mode for the remote surfaces' repeat button.

Additive and optional so every existing call site keeps compiling and keeps behaving identically.

Default

'off'

The button only appears if capabilities also contains 'setRepeatMode'; presses arrive at MediaHandler.onSetRepeatMode.


shuffleEnabled?

optional shuffleEnabled?: boolean;

Defined in: packages/media-session/src/types.ts:87

Current shuffle state. Same rules as repeatMode.

Default

false

status

status: MediaPlaybackStatus;

Defined in: packages/media-session/src/types.ts:31