If queues empty spotify won't pause anymore

This commit is contained in:
Jurn Wubben 2026-02-03 21:19:19 +01:00
parent d40affac9a
commit 35ffca5d8d
2 changed files with 22 additions and 20 deletions

View file

@ -114,14 +114,19 @@ class SpotiQueue {
return;
}
if (data.c === "next_song" && data.d && data.d.song) {
try {
Spicetify.Player.playUri(data.d.song);
Spicetify.Player.setRepeat(false);
if (data.c === "next_song") {
if (data.d && data.d.song) {
try {
Spicetify.Player.playUri(data.d.song);
Spicetify.Player.setRepeat(false);
this.startedPlaying = true;
console.log("[SpotiQueue] New song received!");
} catch (err) {
console.error("[SpotiQueue] Error playing received song:", err);
}
} else {
Spicetify.Player.play();
this.startedPlaying = true;
console.log("[SpotiQueue] New song received!");
} catch (err) {
console.error("[SpotiQueue] Error playing received song:", err);
}
}
@ -144,7 +149,6 @@ class SpotiQueue {
includeAuthors: true,
});
console.log(data);
songs = data.searchV2.tracksV2.items.reduce((o, c) => {
const item = c.item.data;
@ -204,27 +208,23 @@ class SpotiQueue {
}
if (this.button && !this.closing) {
this.button.style.color = ""
this.button.style.color = "";
}
this.closing = false;
}
initUi() {
const btn = new Spicetify.Topbar.Button(
"SpotiQueue",
"enhance",
() => {},
);
const btn = new Spicetify.Topbar.Button("SpotiQueue", "enhance", () => {});
this.button = btn.button;
this.button.style.color = "#e22134"
this.button.style.color = "#e22134";
this.button.addEventListener("click", (e) => {
console.log(e.pointerId);
if (this.socket) {
this.stop();
return
}
return;
}
if (Spicetify.GraphQL.Definitions.searchDesktop === undefined) {
Spicetify.Platform.History.push("/search/");
@ -236,7 +236,7 @@ class SpotiQueue {
}
this.closing = false;
this.button.style.color = ""
this.button.style.color = "";
this.connect();
});
@ -272,4 +272,3 @@ class SpotiQueue {
globalThis.spotiQueue = new SpotiQueue();
globalThis.spotiQueue.initUi();
})();

View file

@ -46,7 +46,10 @@ export class SpotifyWS {
public sendSong(uri?: string) {
const song = uri ?? playerManager.getNext()?.uri;
if (!song) return;
if (!song) {
this.send(buildCommand("next_song"));
return
};
this.send(buildCommand("next_song", { song }));
}