mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 19:18:20 +01:00
.
This commit is contained in:
parent
fa6a64c5f3
commit
1d0d76832d
1 changed files with 12 additions and 33 deletions
|
@ -667,34 +667,32 @@ background-color: #0000;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const syncPlayPause = () => {
|
video.on('play', () => {
|
||||||
if (video.paused) {
|
if (isVideoBuffered()) {
|
||||||
audio.pause();
|
audio.play();
|
||||||
} else {
|
} else {
|
||||||
audio.play().catch(() => {
|
|
||||||
video.pause();
|
video.pause();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
video.on('play', syncPlayPause);
|
video.on('pause', () => {
|
||||||
video.on('pause', syncPlayPause);
|
audio.pause();
|
||||||
|
});
|
||||||
|
|
||||||
video.on('timeupdate', () => {
|
video.on('timeupdate', () => {
|
||||||
if (Math.abs(video.currentTime() - audio.currentTime) > 0.3) {
|
if (Math.abs(video.currentTime() - audio.currentTime) > 0.3) {
|
||||||
audio.pause(); // Pause audio if it's not in sync
|
audio.pause(); // Pause audio if it's not in sync
|
||||||
audio.currentTime = video.currentTime();
|
audio.currentTime = video.currentTime();
|
||||||
audio.play();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
video.on('seeking', handleSeek);
|
video.on('seeking', handleSeek);
|
||||||
|
|
||||||
video.on('seeked', () => {
|
video.on('seeked', () => {
|
||||||
if (isVideoBuffered() && checkAudioBuffer()) {
|
if (isVideoBuffered()) {
|
||||||
video.play();
|
video.play();
|
||||||
audio.play();
|
|
||||||
}
|
}
|
||||||
|
audio.play(); // Ensure audio is playing after seek
|
||||||
});
|
});
|
||||||
|
|
||||||
video.on('volumechange', syncVolume);
|
video.on('volumechange', syncVolume);
|
||||||
|
@ -706,28 +704,9 @@ background-color: #0000;
|
||||||
audio.pause();
|
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>
|
</script>
|
||||||
|
|
||||||
<% if(dm) { %>
|
<% if(dm) { %>
|
||||||
|
|
Loading…
Reference in a new issue