This commit is contained in:
2026-08-18 14:38:00 +02:00
parent f54ebec0eb
commit d867a60126
14 changed files with 325 additions and 64 deletions
+16 -2
View File
@@ -342,15 +342,29 @@ class PlayerState {
}
addToQueue(item: QueueItem) {
this.playNext([item]);
}
playNext(items: QueueItem[]) {
if (items.length === 0) return;
if (this.currentId === null) {
this.playQueue([item], 0);
this.playQueue(items, 0);
return;
}
const tracks = [...this.tracks];
tracks.splice(this.#index() + 1, 0, toTrack(item));
tracks.splice(this.#index() + 1, 0, ...items.map(toTrack));
this.tracks = tracks;
}
appendToQueue(items: QueueItem[]) {
if (items.length === 0) return;
if (this.currentId === null) {
this.playQueue(items, 0);
return;
}
this.tracks = [...this.tracks, ...items.map(toTrack)];
}
playTrack(id: string | number) {
if (this.currentId === id) {
this.toggle();