From 9e560cd26f938d9d2a0c03116e13f7bf9a9e56b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zen=C3=A7=20Bilgili?= <18405305+ozencb@users.noreply.github.com> Date: Fri, 15 Nov 2024 20:10:46 +0300 Subject: [PATCH] Request next video if player state is ENDED --- static/script.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/static/script.js b/static/script.js index 1633a05..1fc09ef 100644 --- a/static/script.js +++ b/static/script.js @@ -581,12 +581,19 @@ const initApp = async (playerElementId) => { setControlIcon('control-mute', ICONS.volume_muted, true); } - if (data === YT.PlayerState.PLAYING && state.currentVideo) { + if ( + (data === YT.PlayerState.PLAYING || data === YT.PlayerState.ENDED) && + state.currentVideo + ) { deactiveBuffering(state); const intervalId = setInterval(async () => { const currentTime = state.player.getCurrentTime(); - if (currentTime >= state.currentVideo.sectionEnd) { + + if ( + currentTime >= state.currentVideo.sectionEnd || + data === YT.PlayerState.ENDED + ) { clearInterval(intervalId); const { newChannel, newVideo } = await changeChannel(state, 0); state.currentChannel = newChannel;