Provided by PlayerProvider through PlayerContext. Cards and previews read what plays and call the controls; GlobalPlayer and MediaPlayer use the internal fields to report the media's state back.
current: PlayerItem | null
Always queue[queueIndex], or null when nothing plays.
playing: boolean
queue: PlayerItem[]
The queue. Every playback is a queue of at least one item, so single tracks and albums share one code path.
queueIndex: number
hasNext: boolean
hasPrevious: boolean
resolving: boolean
True while a stream's URLs are re-resolved, which GlobalPlayer shows.
startTime: number
Where MediaPlayer starts the current item, in seconds: not 0 only for an item restored from a previous session, or resumed after a re-resolve.
autoplay: boolean
Whether the current item starts on mount. A restored session appears
paused, since no user gesture is behind it; a fresh play() autoplays.
seekRef: { current: ((t: number) => void) | null; }
Where the mounted MediaPlayer registers its seek handle, for seekTo.
toggleRef: { current: (() => void) | null; }
Where the mounted MediaPlayer registers its play/pause handle.
play(item: PlayerItem): void
Plays item alone, replacing the queue.
playQueue(items: PlayerItem[],startIndex?: number): void
Replaces the queue with items and plays it from startIndex.
playAt(index: number): void
Plays the queue's item at index, or restarts it when it is current.
next(): void
previous(): void
Restarts the item after its first 3 seconds, else plays the previous one.
stop(): void
Empties the queue, which closes the player.
seekTo(time: number): void
Seeks a file or stream to time seconds. An embed doesn't move.
togglePlay(): void
Pauses or resumes a file or stream. An embed has its own controls.
onPlayStateChange(playing: boolean): void
Called by MediaPlayer when its media starts or stops.
onTimeUpdate(time: number,duration: number): void
Called by MediaPlayer as its media plays.
onEnded(): void
Called by MediaPlayer at its media's end, to play the next item.
onError(): void
Called by MediaPlayer when its media fails, to re-resolve a stream.