Fix audio load

This commit is contained in:
Pen Anderson 2026-05-27 06:39:44 -05:00
parent c74c63ebd7
commit a40e4d2211

View file

@ -19,6 +19,7 @@
} }
if (!audio) return; if (!audio) return;
if (audio.paused) { if (audio.paused) {
if (audio.readyState < 3) loading = true;
audio.play().catch(() => undefined); audio.play().catch(() => undefined);
} else { } else {
audio.pause(); audio.pause();
@ -95,7 +96,7 @@
<input <input
type="range" type="range"
min="0" min="0"
max={duration && isFinite(duration) ? duration : 0} max={duration && isFinite(duration) ? duration : 1}
step="0.1" step="0.1"
bind:value={currentTime} bind:value={currentTime}
disabled={!duration || !isFinite(duration)} disabled={!duration || !isFinite(duration)}
@ -110,7 +111,7 @@
bind:paused bind:paused
bind:currentTime bind:currentTime
bind:duration bind:duration
onloadstart={() => { loading = true; errored = false; }} onloadstart={() => { errored = false; }}
oncanplay={() => { loading = false; }} oncanplay={() => { loading = false; }}
onwaiting={() => { loading = true; }} onwaiting={() => { loading = true; }}
onplaying={onPlaying} onplaying={onPlaying}