For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

Access playback via api.Playback.* in your plugin's lifecycle hooks. All methods are asynchronous and return Promises.


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 queue

  • all - Loop back to the beginning when reaching the end

  • one - 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:

Domain
Responsibility

Playback

Audio transport: play, pause, stop, seek, shuffle, repeat

Queue

Track navigation: next, previous


Usage


Reference

Types

Last updated