diff --git a/web/src/routes/artist/[id]/SidePlayer.svelte b/web/src/routes/artist/[id]/SidePlayer.svelte index f4b3bd4..45c5414 100644 --- a/web/src/routes/artist/[id]/SidePlayer.svelte +++ b/web/src/routes/artist/[id]/SidePlayer.svelte @@ -12,6 +12,7 @@ let duration = $state(0); let loading = $state(false); let errored = $state(false); + let intent = $state(false); function toggle() { if (errored) { @@ -20,9 +21,11 @@ } if (!audio) return; if (audio.paused) { + intent = true; if (audio.readyState < 3) loading = true; audio.play().catch(() => undefined); } else { + intent = false; audio.pause(); } } @@ -30,6 +33,7 @@ function retry() { if (!audio) return; errored = false; + intent = true; loading = true; audio.load(); audio.play().catch(() => undefined); @@ -47,7 +51,8 @@ $effect(() => { if (!autoplay || !audio) return; - audio.play().catch(() => undefined); + intent = true; + audio.play().catch(() => { intent = false; }); }); function fmt(s: number) { @@ -119,7 +124,7 @@ bind:duration onloadstart={() => { errored = false; }} oncanplay={() => { loading = false; }} - onwaiting={() => { if (!paused) loading = true; }} + onwaiting={() => { if (intent) loading = true; }} onplaying={onPlaying} onerror={() => { loading = false; errored = true; }} onended={() => { paused = true; }}