fix: adjustShuttle reads live rate with 0.25 step, fullscreen targets documentElement

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-22 19:45:50 -04:00
parent 980f31a414
commit c00c215d33
3 changed files with 72 additions and 13 deletions

View File

@@ -84,11 +84,12 @@ export function resetShuttleRate() {
}
}
export function adjustShuttle(dir: 1 | -1, shuttleRate: number): number {
export function adjustShuttle(dir: 1 | -1): number {
const videoEl = getVideo();
if (!videoEl) return shuttleRate;
if (!videoEl) return 1;
const nextRate = Math.max(0.25, Math.min(4, shuttleRate + dir * 0.5));
const current = videoEl.playbackRate;
const nextRate = Math.max(0.25, Math.min(4, current + dir * 0.25));
videoEl.playbackRate = nextRate;
if (videoEl.paused) {
void videoEl.play();
@@ -121,14 +122,13 @@ export function toggleFullscreen(): void {
console.error('Exit fullscreen failed:', e);
});
} else {
const videoEl = getVideo();
if (!videoEl) return;
if (videoEl.requestFullscreen) {
videoEl.requestFullscreen().catch((e) => {
const el = document.documentElement;
if (el.requestFullscreen) {
el.requestFullscreen().catch((e) => {
console.error('Fullscreen request failed:', e);
});
} else if ((videoEl as HTMLVideoElement & { webkitEnterFullscreen?: () => void }).webkitEnterFullscreen) {
(videoEl as HTMLVideoElement & { webkitEnterFullscreen: () => void }).webkitEnterFullscreen();
} else if ((el as HTMLElement & { webkitRequestFullscreen?: () => void }).webkitRequestFullscreen) {
(el as HTMLElement & { webkitRequestFullscreen: () => void }).webkitRequestFullscreen();
}
}
}