From d8f30cff843a01783effa443b437af2e1e1c26e0 Mon Sep 17 00:00:00 2001 From: Josh Patra <30350506+SoPat712@users.noreply.github.com> Date: Sun, 20 Apr 2025 20:36:15 -0400 Subject: [PATCH] Very carefully making skip always continue playing audio --- src/lib/HeardleGame.svelte | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/lib/HeardleGame.svelte b/src/lib/HeardleGame.svelte index 0e7b9eb..39051d3 100644 --- a/src/lib/HeardleGame.svelte +++ b/src/lib/HeardleGame.svelte @@ -325,12 +325,7 @@ function skipIntro() { if (!widgetReady || gameOver) return; - skipInProgress = true; // guard the PAUSE handler - widget.pause(); // PAUSE event will handle restart - clearTimeout(snippetTimeout); - currentPosition = 0; - - // record the skip + /*── 1 Record the skip attempt ──*/ attemptInfos = [...attemptInfos, { status: 'skip' }]; attemptCount++; userInput = ''; @@ -338,8 +333,24 @@ if (attemptCount >= maxAttempts) { revealAnswer(); + return; // nothing more to do + } + + /*── 2 Decide how to advance ──*/ + if (isPlaying) { + /* The usual case: we’re in the middle of a snippet. + Guard PAUSE → playSegment() hand‑off exactly as before. */ + skipInProgress = true; + clearTimeout(snippetTimeout); + widget.pause(); // PAUSE handler will launch the next snippet + } else { + /* Player is already paused (or hasn’t started yet). + Start the next snippet right away. */ + stopAllTimers(); // just in case something is still polling + currentPosition = 0; + /* No need for skipInProgress here – we’re bypassing the PAUSE pathway */ + playSegment(); } - // no playSegment() call here – PAUSE handler restarts next snippet } function submitGuess() {