Use explicit YouTube play pause actions

This commit is contained in:
codex
2026-06-10 19:54:37 +02:00
parent 3e6a94ae2e
commit 5f86df62cf
3 changed files with 66 additions and 19 deletions
+5 -2
View File
@@ -221,14 +221,17 @@ const server = http.createServer(async (req, res) => {
const playlist = normalizePlaylist(payload.playlist);
const videoId = String(payload.videoId || "").trim();
const activeVideoId = playlist.some((item) => item.videoId === videoId) ? videoId : "";
const action = payload.action === "play" && activeVideoId ? "play" : "pause";
const watchState = {
type: "watch-state",
from: payload.from,
name: normalizeName(payload.name),
videoId: playlist.some((item) => item.videoId === videoId) ? videoId : "",
videoId: activeVideoId,
playlist,
position: Number(payload.position) || 0,
playing: Boolean(payload.playing),
playing: action === "play",
action,
updatedAt: Number(payload.updatedAt) || Date.now()
};