From b6b328dfb88acaa14448a4c4b26dc63a83437c29 Mon Sep 17 00:00:00 2001 From: jonathan Date: Tue, 2 Jun 2026 23:24:17 +0200 Subject: [PATCH] fix: switch audio to preload=auto when player opens or seek is triggered preload='metadata' only fetches the header; every seek then requires a fresh Range request and buffering delay. Switching to 'auto' lets the browser start buffering the file immediately so seeking into it is fast. Set both in togglePlayer (on open) and in seekToSection/jumpToDaySection (in case the player was already open with the old metadata-only mode). Co-Authored-By: Claude Sonnet 4.6 --- web.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web.py b/web.py index aa4ae3f..208a7f0 100644 --- a/web.py +++ b/web.py @@ -861,7 +861,7 @@ function togglePlayer(idx, filename) { if (!open) { if (!audio.getAttribute('data-src-set')) { - audio.preload = 'metadata'; + audio.preload = 'auto'; audio.src = '/stream/' + encodeURIComponent(filename); audio.load(); audio.setAttribute('data-src-set','1'); @@ -931,6 +931,7 @@ function seekToSection(idx, filename, startSec, endSec, sectionIdx) { if (pbtn.getAttribute('aria-expanded') !== 'true') togglePlayer(idx, filename); activePlayerIdx = idx; const audio = document.getElementById('aud-'+idx); + audio.preload = 'auto'; const seekTo = Math.max(0, startSec - getPreroll()); const doSeek = () => { audio.currentTime = seekTo; audio.play().catch(() => {}); }; if (audio.readyState >= 1) doSeek(); @@ -1540,6 +1541,7 @@ function jumpToDaySection(si) { const audio = document.getElementById('aud-' + fileIdx); if (!audio) return; + audio.preload = 'auto'; const seekTo = Math.max(0, start - getPreroll()); const doSeek = () => { audio.currentTime = seekTo; audio.play().catch(() => {}); }; if (audio.readyState >= 1) doSeek();