Skip to content

Commit

Permalink
Request next video if player state is ENDED
Browse files Browse the repository at this point in the history
  • Loading branch information
ozencb committed Nov 15, 2024
1 parent 79b788a commit 9e560cd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9e560cd

Please sign in to comment.