From a9e6314641e3f3f945df60c4e09a040d65ce2415 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Thu, 23 Apr 2026 23:48:37 -0700 Subject: type: press space to skip long intermission --- src/app/game/page.tsx | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/app/game') diff --git a/src/app/game/page.tsx b/src/app/game/page.tsx index 2082569..188c5c6 100644 --- a/src/app/game/page.tsx +++ b/src/app/game/page.tsx @@ -492,6 +492,24 @@ function GameInner() { useEffect(() => { if (phase !== "playing") return; const handler = (e: KeyboardEvent) => { + if (e.key === " ") { + const idx = gRef.current.displayedLineIdx; + if (idx < 0 && gameLines.length > 0) { + const firstMs = gameLines[0]?.millisecond ?? 0; + const media = isVideo ? videoRef.current : audioRef.current; + if (media) { + const currentMsLocal = media.currentTime * 1000 + offsetRef.current; + const intermissionRemaining = Math.max(0, firstMs - Math.max(0, currentMsLocal)); + if (intermissionRemaining > 5000) { + e.preventDefault(); + const targetMs = Math.max(0, firstMs - 3000); + media.currentTime = Math.max(0, (targetMs - offsetRef.current) / 1000); + setCurrentMs(media.currentTime * 1000 + offsetRef.current); + return; + } + } + } + } if (e.key.length === 1) { e.preventDefault(); handleKeyPress(e.key); @@ -499,7 +517,7 @@ function GameInner() { }; window.addEventListener("keydown", handler); return () => window.removeEventListener("keydown", handler); - }, [phase, handleKeyPress]); + }, [phase, handleKeyPress, gameLines, isVideo]); return ( @@ -714,6 +732,16 @@ function GameInner() { +
+ {intermissionData.remainingMs > 5000 && "Press Space to skip long intermissions"} +
-- cgit v1.2.3