Playback
Control audio transport, read playback state, and react to playback changes.
Playback API for plugins
The Playback API controls audio states: play, pause, stop, seek, and subscribe to state changes. It doesn't handle track navigation, use the Queue API for that.
Core concepts
Playback state
Playback state is exposed through a single object:
type PlaybackState = {
status: PlaybackStatus;
seek: number; // Current position in seconds
duration: number; // Total duration in seconds
};
type PlaybackStatus = 'playing' | 'paused' | 'stopped';seek and duration are always in seconds, not milliseconds.
Repeat modes
off- Stop at the end of the queueall- Loop back to the beginning when reaching the endone- Repeat the current track indefinitely
Repeat mode is stored in the settings under the core.playback.repeat key.
Shuffle
When shuffle is enabled, goToNext() and goToPrevious() on the Queue API pick random indices instead of sequential ones. The algorithm avoids repeating the same track twice in a row.
Shuffle state is stored in the settings under the core.playback.shuffle key.
Playback vs. Queue
These two domains divide playback responsibilities:
Playback
Audio transport: play, pause, stop, seek, shuffle, repeat
Queue
Track navigation: next, previous
Usage
subscribe fires frequently during playback as the seek position updates. Keep your listener lightweight to avoid blocking the UI thread.
Reference
Types
Last updated