mirror of
https://codeberg.org/armin/noiz.git
synced 2026-09-01 14:00:54 +02:00
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:
parent
92f2c6dab4
commit
dd38dbd0f7
1 changed files with 6 additions and 5 deletions
11
index.html
11
index.html
|
|
@ -676,13 +676,13 @@ function drawWaveform() {
|
||||||
ctx.clearRect(0, 0, visWidth, h);
|
ctx.clearRect(0, 0, visWidth, h);
|
||||||
if (!t) return;
|
if (!t) return;
|
||||||
if (!t.waveform) {
|
if (!t.waveform) {
|
||||||
|
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) {
|
if (audio && audio.duration) {
|
||||||
const pct = audio.currentTime / 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.fillStyle = '#84a0c6';
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.roundRect(0, y, visWidth * pct, barH, 2);
|
ctx.roundRect(0, y, visWidth * pct, barH, 2);
|
||||||
|
|
@ -1562,6 +1562,7 @@ function onLoadedmetadata(e) {
|
||||||
if (t && audio.duration) {
|
if (t && audio.duration) {
|
||||||
t.playtime = audio.duration;
|
t.playtime = audio.duration;
|
||||||
renderTracks();
|
renderTracks();
|
||||||
|
drawWaveform();
|
||||||
computeWaveform(t);
|
computeWaveform(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue