Reputation: 48
I want to get the progress of a sound played by using the howler library.
The seek() function always returns 0 for me.
First I initialize the sound:
var sound = new Howl({
src: ['Audio/Track.wav']
});
Then I play the sound from another function (i can hear the sound) and try to get the seek.
function update() {
requestAnimationFrame(update);
if(!audioIsPlaying){
sound.play();
audioIsPlaying = true;
}
let seek = sound.seek || 0;
console.log(formatTime(Math.round(seek)));
}
function formatTime(secs) {
var minutes = Math.floor(secs / 60) || 0;
var seconds = (secs - minutes * 60) || 0;
return minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
}
Any ideas?
Greets
Upvotes: 0
Views: 974
Reputation: 11
instead of let seek = sound.seek || 0;
write let seek = sound.seek() || 0;
seek is a function, not a property
Upvotes: 1