Fix synced YouTube pause

This commit is contained in:
codex
2026-06-10 15:52:38 +02:00
parent 1c61bbbb62
commit 47cc987049
+14 -6
View File
@@ -343,16 +343,24 @@ async function applyWatchState(state) {
const position = Math.max(0, Number(state.position || 0) + elapsed);
if (youtubeReady) {
if (player.getVideoData?.().video_id !== currentYoutubeVideoId) {
player.loadVideoById(currentYoutubeVideoId, position);
} else {
player.seekTo(position, true);
}
if (state.playing) {
if (player.getVideoData?.().video_id !== currentYoutubeVideoId) {
player.loadVideoById(currentYoutubeVideoId, position);
} else {
player.seekTo(position, true);
}
player.playVideo();
} else {
if (player.getVideoData?.().video_id !== currentYoutubeVideoId) {
player.cueVideoById(currentYoutubeVideoId, position);
} else {
player.pauseVideo();
player.seekTo(position, true);
}
player.pauseVideo();
setTimeout(() => {
player.pauseVideo();
}, 150);
}
} else {
const interval = setInterval(() => {