howler.js icon indicating copy to clipboard operation
howler.js copied to clipboard

support timeupdate event ?

Open lili21 opened this issue 6 years ago • 7 comments

timeupdate event

The timeupdate event is fired when the time indicated by the currentTime attribute has been updated.

lili21 avatar Jun 19 '18 09:06 lili21

+1 This would be useful.

ondrakoupil avatar Jul 27 '18 13:07 ondrakoupil

The audio demo player uses something like this:

audio =  new Howl({
         src: url,
         onplay: function () {
             requestAnimationFrame(step.bind(this);
         }.bind(this)
 };

function step() {
   var self = this;
   // Get the Howl we want to manipulate.
   var sound = self.playlist[self.index].howl;

   // Determine our current seek position.
   var seek = sound.seek() || 0;
   timer.innerHTML = self.formatTime(Math.round(seek));
   progress.style.width = (((seek / sound.duration()) * 100) || 0) + '%';

   // If the sound is still playing, continue stepping.
   if (sound.playing()) {
     requestAnimationFrame(self.step.bind(self));
   }
 },

The issue with this is that it uses requestAnimationFrame which is only fired when the tab is active. For your audio player demo this wont be an issue because you use this to show real time progress bar, but for my case i need to manipulate the audio. Thus right now if user switches tabs in my software the audio goes out of sync with the rest of items on my website causing issues. Please add support for this, thank you.

hamzawain7 avatar Jan 29 '19 11:01 hamzawain7

this should be part of the functionality.

xerosanyam avatar May 08 '20 15:05 xerosanyam

It would be pretty useful feature. Please add

theankitc avatar Dec 21 '20 12:12 theankitc

+1

zhanghui-space avatar Jul 16 '21 22:07 zhanghui-space

Any updates on that issue?

Dani-Boy92 avatar Nov 10 '21 13:11 Dani-Boy92

@hamzawain7. Solution with requestAnimationFrame is pretty good. That is the base of my progress bar implementation. Thanks!

fresonn avatar Apr 09 '23 19:04 fresonn