fix stuff + add stuff

This commit is contained in:
ashley 2025-10-06 19:17:07 +02:00
parent 88bfec6cb6
commit b7da297df3

View File

@ -253,27 +253,35 @@ var versionclient = "youtube.player.web_20250917_22_RC00"
video.on('playing', markVPlaying); video.on('playing', markVPlaying);
audio.addEventListener('playing', markAPlaying); audio.addEventListener('playing', markAPlaying);
// simple guard fix for first-seek stuck/pingpong // improved seek handling — pause only on large seeks
let wasPlayingBeforeSeek = false; let wasPlayingBeforeSeek = false;
let lastSeekTime = 0;
const SEEK_THRESHOLD = 1.5; // seconds — anything above this counts as "large seek"
video.on('seeking', () => { video.on('seeking', () => {
if (restarting) return; if (restarting) return;
wasPlayingBeforeSeek = !video.paused(); wasPlayingBeforeSeek = !video.paused();
pauseTogether(); lastSeekTime = Number(audio.currentTime) || 0;
const vt = Number(video.currentTime());
safeSetCT(audio, vt);
}); });
video.on('seeked', () => { video.on('seeked', () => {
if (restarting) return; if (restarting) return;
const vt = Number(video.currentTime()); const vt = Number(video.currentTime());
const delta = Math.abs(vt - lastSeekTime);
safeSetCT(audio, vt); safeSetCT(audio, vt);
// BASIC FIX: ensure both are ready + synced before resume // only pause if the seek jump is large
setTimeout(() => { if (delta > SEEK_THRESHOLD) {
const bothReady = bothPlayableAt(vt); pauseTogether();
const bothStill = video.paused() && audio.paused; setTimeout(() => {
if (wasPlayingBeforeSeek && bothReady) playTogether({ allowMutedRetry: true }); const bothReady = bothPlayableAt(vt);
else if (!bothReady || bothStill) pauseTogether(); if (wasPlayingBeforeSeek && bothReady) playTogether({ allowMutedRetry: true });
}, 180); }, 180);
} else {
// small seek: just keep them synced
if (wasPlayingBeforeSeek) playTogether({ allowMutedRetry: false });
}
}); });
async function restartLoop() { async function restartLoop() {
@ -310,7 +318,6 @@ var versionclient = "youtube.player.web_20250917_22_RC00"
}); });
// https://codeberg.org/ashley/poke/src/branch/main/src/libpoketube/libpoketube-youtubei-objects.json // https://codeberg.org/ashley/poke/src/branch/main/src/libpoketube/libpoketube-youtubei-objects.json