If queues empty spotify won't pause anymore
This commit is contained in:
parent
d40affac9a
commit
35ffca5d8d
2 changed files with 22 additions and 20 deletions
|
|
@ -114,7 +114,8 @@ class SpotiQueue {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.c === "next_song" && data.d && data.d.song) {
|
if (data.c === "next_song") {
|
||||||
|
if (data.d && data.d.song) {
|
||||||
try {
|
try {
|
||||||
Spicetify.Player.playUri(data.d.song);
|
Spicetify.Player.playUri(data.d.song);
|
||||||
Spicetify.Player.setRepeat(false);
|
Spicetify.Player.setRepeat(false);
|
||||||
|
|
@ -123,6 +124,10 @@ class SpotiQueue {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("[SpotiQueue] Error playing received song:", err);
|
console.error("[SpotiQueue] Error playing received song:", err);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Spicetify.Player.play();
|
||||||
|
this.startedPlaying = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.c === "search" && data.d && data.d.query && data.d.id) {
|
if (data.c === "search" && data.d && data.d.query && data.d.id) {
|
||||||
|
|
@ -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,26 +208,22 @@ 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) {
|
||||||
|
|
@ -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();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 }));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue