Fix synced YouTube pause
This commit is contained in:
+14
-6
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user