I have a <video>
element in my page:
<video id="myVideo"> <source src="vid.mp4" type="video/mp4" /> <source src="vid.ogg" type="video/ogg" /> </video>
In my JS it reads:
var v = $('#myVideo')[0]; v.addEventListener('timeupdate',function(){ alert('I changed'); },false);
Now I started the console and typed:
$('#myVideo')[0].currentTime = 2;
The displayed frame will change, but the event will not fire. According to the specifications, timeupdate
should fire when currentTime was changed
, so I don’t think I'm using the wrong event? All other events that I use (i.e. play
and ended
) work fine.
There are many similar questions, but all of them seem to be outdated errors? Is this another mistake (I tested in Chrome 17 and FF10) or has something changed in the event structure? Or am I missing something completely different?
EDIT: I just noticed that this problem will only occur when the video has not yet been played. So when I do this:
$('#myVideo')[0].play(); $('#myVideo')[0].pause(); $('#myVideo')[0].currentTime = 2;
The event will fire as it should.
source share