From 93897d67f63ec81ebbe13b10035e4cd5a3a09071 Mon Sep 17 00:00:00 2001 From: Brieuc Dubois <git@bhasher.com> Date: Mon, 2 Sep 2024 13:41:15 +0300 Subject: [PATCH] Fix audio change --- frontend/src/routes/tests/[id]/+page.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/routes/tests/[id]/+page.svelte b/frontend/src/routes/tests/[id]/+page.svelte index e21b403f..db36adc2 100644 --- a/frontend/src/routes/tests/[id]/+page.svelte +++ b/frontend/src/routes/tests/[id]/+page.svelte @@ -33,6 +33,7 @@ let type = currentQuestion.question.split(':')[0]; let value = currentQuestion.question.split(':').slice(1).join(':'); let gaps = type === 'gap' ? gapParts(currentQuestion.question) : null; + let soundPlayer: HTMLAudioElement; function setGroupId(id: number) { currentGroupId = id; @@ -47,6 +48,7 @@ type = currentQuestion.question.split(':')[0]; value = currentQuestion.question.split(':').slice(1).join(':'); gaps = type === 'gap' ? gapParts(currentQuestion.question) : null; + if (soundPlayer) soundPlayer.load(); } async function selectOption(option: string) { @@ -186,7 +188,7 @@ {:else if type == 'image'} <img src={value} alt="Question" /> {:else if type == 'audio'} - <audio controls autoplay class="rounded-lg mx-auto"> + <audio bind:this={soundPlayer} controls autoplay class="rounded-lg mx-auto"> <source src={value} type="audio/mpeg" /> Your browser does not support the audio element. </audio> -- GitLab