I'm making an experimental HTML5 video player. For now, I'm just using an <input type="range"> for the seek bar. To make this work, I'm using two event listeners:
Now my problem is that I'm getting a loop. When the video fires the 'timeupdate' event, it runs updateSeekBar() to change my seek bar's value. But once the seek bar's value is changed, it runs seekToTime() to seek the video to the seekbar's time, and then it loops.
(So essentially, the video progresses and updates the seek bar, and the seek bar says "I'm updated" and seeks the video, and repeat.)
I was under the impression that the "input" event isn't supposed to be fired if it's changed via Javascript? What should I do?
EDIT: Instead of using an event listener for input changed, I'm using onChange(), and that seems to be working. Problem averted!
Code:
video.addEventListener("timeupdate",updateSeekBar,false);
seekbar.addEventListener("input",seekToTime,false);
Now my problem is that I'm getting a loop. When the video fires the 'timeupdate' event, it runs updateSeekBar() to change my seek bar's value. But once the seek bar's value is changed, it runs seekToTime() to seek the video to the seekbar's time, and then it loops.
(So essentially, the video progresses and updates the seek bar, and the seek bar says "I'm updated" and seeks the video, and repeat.)
I was under the impression that the "input" event isn't supposed to be fired if it's changed via Javascript? What should I do?
EDIT: Instead of using an event listener for input changed, I'm using onChange(), and that seems to be working. Problem averted!