WIP: global player pt. 6 fix playback finally

This commit is contained in:
2026-02-10 00:22:52 -08:00
parent cfd45b6815
commit c8de948e7f
3 changed files with 32 additions and 15 deletions

View File

@@ -11,8 +11,17 @@
const audio = getAudioContext();
let open = $state(false);
let sliderValue = $state([0]);
// Sync Audio -> Slider
$effect(() => {
if (Math.abs(sliderValue[0] - audio.currentTime) > 0.1) {
sliderValue = [audio.currentTime];
}
});
function onSeek(v: number[]) {
if (Math.abs(v[0] - audio.currentTime) < 0.1) return;
audio.seek(v[0]);
}
</script>
@@ -101,9 +110,9 @@
<!-- Progress -->
<div class="space-y-2">
<Slider
value={[audio.currentTime]}
bind:value={sliderValue}
max={audio.duration || 100}
step={1}
step={0.01}
onValueChange={onSeek}
type="multiple"
class="w-full"