This commit is contained in:
ashley 2024-09-24 19:31:18 +00:00
parent 00a7738a1d
commit adc02ed151

View file

@ -7,7 +7,6 @@ document.addEventListener("DOMContentLoaded", () => {
const qua = new URLSearchParams(window.location.search).get("quality") || "";
localStorage.setItem(`progress-${new URLSearchParams(window.location.search).get('v')}`, 0);
if (qua !== "medium") {
const audio = document.getElementById('aud');
@ -48,9 +47,14 @@ document.addEventListener("DOMContentLoaded", () => {
video.play();
audio.play();
}
}, {
once: true
});
}, { once: true });
}
};
const playBothIfBuffered = () => {
if (isVideoBuffered() && checkAudioBuffer()) {
video.play();
audio.play();
}
};
@ -74,22 +78,17 @@ document.addEventListener("DOMContentLoaded", () => {
video.on('waiting', () => {
video.pause();
audio.pause();
// Add event listener to resume when buffering is done
video.on('canplaythrough', playBothIfBuffered);
});
video.on('canplaythrough', () => {
if (!video.paused()) {
video.play();
audio.play();
}
});
video.on('canplaythrough', playBothIfBuffered);
video.on('seeking', handleSeek);
video.on('seeked', () => {
if (isVideoBuffered()) {
video.play();
}
audio.play(); // Ensure audio is playing after seek
playBothIfBuffered();
});
video.on('volumechange', syncVolume);
@ -105,6 +104,7 @@ document.addEventListener("DOMContentLoaded", () => {
video.pause();
audio.pause();
});
document.addEventListener('fullscreenchange', () => {
if (!document.fullscreenElement) {
video.pause();
@ -112,7 +112,7 @@ document.addEventListener("DOMContentLoaded", () => {
}
});
}
});
window.pokePlayer = {
ver:`16-vjs-${videojs.VERSION}`,