show progress bar before waveform loads

- Draw progress bar track background unconditionally when no waveform
  exists, so the waveform area never appears blank
- Call drawWaveform() from onLoadedmetadata() so the bar fill appears
  as soon as metadata is available
This commit is contained in:
Armin 2026-07-09 00:27:48 +02:00
commit dd38dbd0f7

View file

@ -676,13 +676,13 @@ function drawWaveform() {
ctx.clearRect(0, 0, visWidth, h);
if (!t) return;
if (!t.waveform) {
if (audio && audio.duration) {
const pct = audio.currentTime / audio.duration;
const barH = 4, y = (h - barH) / 2;
ctx.fillStyle = '#272c42';
ctx.beginPath();
ctx.roundRect(0, y, visWidth, barH, 2);
ctx.fill();
if (audio && audio.duration) {
const pct = audio.currentTime / audio.duration;
ctx.fillStyle = '#84a0c6';
ctx.beginPath();
ctx.roundRect(0, y, visWidth * pct, barH, 2);
@ -1562,6 +1562,7 @@ function onLoadedmetadata(e) {
if (t && audio.duration) {
t.playtime = audio.duration;
renderTracks();
drawWaveform();
computeWaveform(t);
}
}