Update html/poketube.ejs

This commit is contained in:
ashley 2024-08-19 22:18:23 +00:00
parent ad28847a67
commit 4f901e602a

View file

@ -624,6 +624,7 @@ document.addEventListener("DOMContentLoaded", () => {
controls: true,
autoplay: false,
preload: 'auto',
});
const qua = new URLSearchParams(window.location.search).get("quality") || "";
@ -675,27 +676,14 @@ document.addEventListener("DOMContentLoaded", () => {
};
video.on('play', () => {
// Set initial sync point at 0.01 seconds
video.currentTime(0.01);
audio.currentTime = 0.01;
if (Math.abs(video.currentTime() - audio.currentTime) > 0.3) {
audio.currentTime = video.currentTime();
}
// Wait for both video and audio to be buffered sufficiently
if (isVideoBuffered() && checkAudioBuffer()) {
video.play();
if (isVideoBuffered()) {
audio.play();
} else {
video.pause();
audio.pause();
const bufferListener = () => {
if (isVideoBuffered() && checkAudioBuffer()) {
video.play();
audio.play();
audio.removeEventListener('canplay', bufferListener);
}
};
audio.addEventListener('canplay', bufferListener);
}
});
@ -703,6 +691,8 @@ document.addEventListener("DOMContentLoaded", () => {
audio.pause();
});
video.on('seeking', handleSeek);
video.on('seeked', () => {
@ -725,7 +715,6 @@ document.addEventListener("DOMContentLoaded", () => {
video.pause();
audio.pause();
});
document.addEventListener('fullscreenchange', () => {
if (!document.fullscreenElement) {
video.pause();