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; return;
} }
if (data.c === "next_song" && data.d && data.d.song) { if (data.c === "next_song") {
try { if (data.d && data.d.song) {
Spicetify.Player.playUri(data.d.song); try {
Spicetify.Player.setRepeat(false); 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; 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, includeAuthors: true,
}); });
console.log(data);
songs = data.searchV2.tracksV2.items.reduce((o, c) => { songs = data.searchV2.tracksV2.items.reduce((o, c) => {
const item = c.item.data; const item = c.item.data;
@ -204,27 +208,23 @@ class SpotiQueue {
} }
if (this.button && !this.closing) { if (this.button && !this.closing) {
this.button.style.color = "" this.button.style.color = "";
} }
this.closing = false; this.closing = false;
} }
initUi() { initUi() {
const btn = new Spicetify.Topbar.Button( const btn = new Spicetify.Topbar.Button("SpotiQueue", "enhance", () => {});
"SpotiQueue",
"enhance",
() => {},
);
this.button = btn.button; this.button = btn.button;
this.button.style.color = "#e22134" this.button.style.color = "#e22134";
this.button.addEventListener("click", (e) => { this.button.addEventListener("click", (e) => {
console.log(e.pointerId); console.log(e.pointerId);
if (this.socket) { if (this.socket) {
this.stop(); this.stop();
return return;
} }
if (Spicetify.GraphQL.Definitions.searchDesktop === undefined) { if (Spicetify.GraphQL.Definitions.searchDesktop === undefined) {
Spicetify.Platform.History.push("/search/"); Spicetify.Platform.History.push("/search/");
@ -236,7 +236,7 @@ class SpotiQueue {
} }
this.closing = false; this.closing = false;
this.button.style.color = "" this.button.style.color = "";
this.connect(); this.connect();
}); });
@ -272,4 +272,3 @@ class SpotiQueue {
globalThis.spotiQueue = new SpotiQueue(); globalThis.spotiQueue = new SpotiQueue();
globalThis.spotiQueue.initUi(); globalThis.spotiQueue.initUi();
})(); })();

View file

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