Update html/poketube.ejs

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

View file

@ -619,11 +619,12 @@ background-color: #0000;
</style> </style>
<script> <script>
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
const video = videojs('video', { const video = videojs('video', {
controls: true, controls: true,
autoplay: false, autoplay: false,
preload: 'auto', preload: 'auto',
}); });
const qua = new URLSearchParams(window.location.search).get("quality") || ""; const qua = new URLSearchParams(window.location.search).get("quality") || "";
@ -675,27 +676,14 @@ document.addEventListener("DOMContentLoaded", () => {
}; };
video.on('play', () => { video.on('play', () => {
// Set initial sync point at 0.01 seconds if (Math.abs(video.currentTime() - audio.currentTime) > 0.3) {
video.currentTime(0.01); audio.currentTime = video.currentTime();
audio.currentTime = 0.01; }
// Wait for both video and audio to be buffered sufficiently if (isVideoBuffered()) {
if (isVideoBuffered() && checkAudioBuffer()) {
video.play();
audio.play(); audio.play();
} else { } else {
video.pause(); 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(); audio.pause();
}); });
video.on('seeking', handleSeek); video.on('seeking', handleSeek);
video.on('seeked', () => { video.on('seeked', () => {
@ -725,7 +715,6 @@ document.addEventListener("DOMContentLoaded", () => {
video.pause(); video.pause();
audio.pause(); audio.pause();
}); });
document.addEventListener('fullscreenchange', () => { document.addEventListener('fullscreenchange', () => {
if (!document.fullscreenElement) { if (!document.fullscreenElement) {
video.pause(); video.pause();
@ -733,7 +722,7 @@ document.addEventListener("DOMContentLoaded", () => {
} }
}); });
} }
}); });
</script> </script>