From 32bc8f449498c04f59b5a04e9a544fc93afddd20 Mon Sep 17 00:00:00 2001 From: Izan Gil <66965250+SrIzan10@users.noreply.github.com> Date: Fri, 18 Apr 2025 21:06:21 +0200 Subject: [PATCH] fix: playing and pausing going back to initial state --- src/lib/components/app/daemon.svelte | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/lib/components/app/daemon.svelte b/src/lib/components/app/daemon.svelte index d0c5a39..a02789a 100644 --- a/src/lib/components/app/daemon.svelte +++ b/src/lib/components/app/daemon.svelte @@ -11,20 +11,17 @@ if (!audioElement) return; if (play && state.hasInteracted) { + audioElement.currentTime = state.currentTime; audioElement.play().catch(() => { state.error = 'Audio playback failed. Please interact with the page first.'; state.isPlaying = false; }); - audioElement.currentTime = state.currentTime; } else { + state.currentTime = audioElement.currentTime; audioElement.pause(); } } - function playAudio() { - togglePlayback(true); - } - state.togglePlay = () => { state.isPlaying = !state.isPlaying; togglePlayback(state.isPlaying); @@ -115,7 +112,7 @@ class="flex flex-col h-screen w-full items-center justify-center space-y-2 cursor-pointer" onclick={() => { state.hasInteracted = true; - playAudio() + togglePlayback(true); }} >

Click anywhere on the screen