added rpc seek for the video

This commit is contained in:
2026-01-03 16:19:07 +01:00
parent 3fe39bd6df
commit 57acf10f38
2 changed files with 22 additions and 0 deletions

View File

@@ -249,6 +249,7 @@ const AnimePlayer = (function() {
els.video.onloadedmetadata = onLoadedMetadata;
els.video.onended = onEnded;
els.video.onvolumechange = onVolumeChange;
els.video.onseeked = onSeeked;
}
}
@@ -437,6 +438,16 @@ const AnimePlayer = (function() {
_rpcActive = true;
}
function onSeeked() {
if (!els.video || els.video.paused || !els.video.duration) return;
const elapsed = Math.floor(els.video.currentTime);
const start = Math.floor(Date.now() / 1000) - elapsed;
const end = start + Math.floor(els.video.duration);
sendRPC({ startTimestamp: start, endTimestamp: end });
}
function onPause() {
if (els.playPauseBtn) {
els.playPauseBtn.innerHTML = `