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

Queue

Control playback order, manipulate the queue, and react to track changes in Nuclear.

Queue API for Plugins

The Queue API gives plugins control over Nuclear's playback queue. Add tracks, reorder items, control navigation, and subscribe to queue changes.

Access the queue via api.Queue.* in your plugin's lifecycle hooks. All queue operations are asynchronous and return Promises.


Core concepts

Queue structure

The queue is a list of items with a pointer to the current playback position:

type Queue = {
  items: QueueItem[];        // Ordered list of tracks
  currentIndex: number;      // Position of currently playing item (0-based)
};

Queue items

Each item in the queue has its own unique ID and tracks its own state:

type QueueItem = {
  id: string;                // UUID for this queue entry
  track: Track;              // Full track metadata
  
  // Playback state
  status: 'idle' | 'loading' | 'success' | 'error';
  error?: string;            // Error message if status is 'error'
  
  // Metadata
  addedAtIso: string;        // ISO timestamp of when added
};

Status lifecycle:

  • idle - Item is in queue but hasn't been played yet

  • loading - Finding candidates, or stream resolution in progress

  • success - Stream resolved and ready for playback

  • error - All streams failed or playback error occurred


Usage


Reference

Best practices

  • Use subscriptions for reactive features. subscribe() for queue-wide changes, subscribeToCurrentItem() for playback tracking

Last updated