mirror of
https://codeberg.org/ashley/poke.git
synced 2024-12-24 04:28:03 +01:00
.
This commit is contained in:
parent
fa6a64c5f3
commit
1d0d76832d
1 changed files with 12 additions and 33 deletions
|
@ -612,7 +612,7 @@ background-color: #0000;
|
|||
</style>
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const video = videojs('video', {
|
||||
controls: true,
|
||||
autoplay: false,
|
||||
|
@ -667,34 +667,32 @@ background-color: #0000;
|
|||
}
|
||||
};
|
||||
|
||||
const syncPlayPause = () => {
|
||||
if (video.paused) {
|
||||
audio.pause();
|
||||
video.on('play', () => {
|
||||
if (isVideoBuffered()) {
|
||||
audio.play();
|
||||
} else {
|
||||
audio.play().catch(() => {
|
||||
video.pause();
|
||||
});
|
||||
video.pause();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
video.on('play', syncPlayPause);
|
||||
video.on('pause', syncPlayPause);
|
||||
video.on('pause', () => {
|
||||
audio.pause();
|
||||
});
|
||||
|
||||
video.on('timeupdate', () => {
|
||||
if (Math.abs(video.currentTime() - audio.currentTime) > 0.3) {
|
||||
audio.pause(); // Pause audio if it's not in sync
|
||||
audio.currentTime = video.currentTime();
|
||||
audio.play();
|
||||
}
|
||||
});
|
||||
|
||||
video.on('seeking', handleSeek);
|
||||
|
||||
video.on('seeked', () => {
|
||||
if (isVideoBuffered() && checkAudioBuffer()) {
|
||||
if (isVideoBuffered()) {
|
||||
video.play();
|
||||
audio.play();
|
||||
}
|
||||
audio.play(); // Ensure audio is playing after seek
|
||||
});
|
||||
|
||||
video.on('volumechange', syncVolume);
|
||||
|
@ -706,28 +704,9 @@ background-color: #0000;
|
|||
audio.pause();
|
||||
}
|
||||
});
|
||||
|
||||
// Ensure audio and video are both ready before playing
|
||||
let videoReady = false;
|
||||
let audioReady = false;
|
||||
|
||||
video.on('canplay', () => {
|
||||
videoReady = true;
|
||||
if (videoReady && audioReady) {
|
||||
video.play();
|
||||
audio.play();
|
||||
}
|
||||
});
|
||||
|
||||
audio.addEventListener('canplay', () => {
|
||||
audioReady = true;
|
||||
if (videoReady && audioReady) {
|
||||
video.play();
|
||||
audio.play();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<% if(dm) { %>
|
||||
|
|
Loading…
Reference in a new issue