Skip to content

PlayerState

PlayerState is the state of Spotify’s PlayerAPI, which Spicetify.Player.data holds. Spotify defines it, and its fields can change between client versions.

type PlayerState = {
timestamp: number;
context: { uri: string; url: string; metadata: Metadata };
index: { pageURI?: string | null; pageIndex: number; itemIndex: number };
item: PlayerTrack;
shuffle: boolean;
smartShuffle: boolean;
repeat: number;
speed: number;
positionAsOfTimestamp: number;
duration: number;
hasContext: boolean;
isPaused: boolean;
isBuffering: boolean;
restrictions: Record<string, boolean | string[]>;
previousItems?: PlayerTrack[];
nextItems?: PlayerTrack[];
playbackQuality: Record<string, number | boolean>;
playbackId: string;
sessionId: string;
signals?: any[];
};
type PlayerTrack = {
type: string;
uri: string;
uid: string;
name: string;
mediaType: string;
duration: { milliseconds: number };
album: { type: string; uri: string; name: string; images?: { url: string; label: string }[] };
artists?: { type: string; uri: string; name: string }[];
isLocal: boolean;
isExplicit: boolean;
is19PlusOnly: boolean;
provider: string;
metadata: Metadata;
images?: { url: string; label: string }[];
};
PropertyDescription
itemThe current track or episode.
contextThe playlist, album or other context that playback started from.
indexThe position of item in its context.
isPaused, isBufferingThe playback status.
positionAsOfTimestamp, timestampThe position in milliseconds at the time timestamp records. Player.getProgress computes the current position from both.
durationThe length of item in milliseconds.
shuffle, smartShuffle, repeatThe shuffle and repeat settings. repeat is 0 for off, 1 for all and 2 for one.
speedThe playback speed.
restrictionsWhich actions the current state allows, such as canSeek and canSkipNext.
previousItems, nextItemsThe tracks before and after item.

Metadata is a map of strings.