From 92f2c6dab4709568edb318e13c6585b5c147faa3 Mon Sep 17 00:00:00 2001 From: Armin Date: Thu, 9 Jul 2026 00:23:29 +0200 Subject: [PATCH] add progress bar fallback when waveform data is unavailable --- index.html | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index b2606f3..5dba1e6 100644 --- a/index.html +++ b/index.html @@ -674,7 +674,28 @@ function drawWaveform() { const ctx = canvas.getContext('2d'); ctx.setTransform(dpr, 0, 0, dpr, 0, 0); ctx.clearRect(0, 0, visWidth, h); - if (!t || !t.waveform) return; + 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(); + ctx.fillStyle = '#84a0c6'; + ctx.beginPath(); + ctx.roundRect(0, y, visWidth * pct, barH, 2); + ctx.fill(); + ctx.strokeStyle = '#e27878'; + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.moveTo(visWidth * pct, 2); + ctx.lineTo(visWidth * pct, h - 2); + ctx.stroke(); + } + return; + } const wf = t.waveform; const data = wf.data; const halfH = h / 2;