How can I update a progress bar with howler js?
There is currently no progress event in howler.js, though it may get added at a later date. However, you can get the current position by calling audio.seek()
at any time (on 2.0) or audio.pos()
on 1.0. You could then either call this in requestAnimationFrame
(this is what the 2.0 demos use) or setInterval
to update your progress bar.
You can use the following snippet
setInterval(() => {
updateWidth();
},300);
function updateWidth() {
if (sound.playing()) {
let width = (sound.seek()/sound.duration())*100;
}
}