0

I am working with HTML5 VideoSource extensions and I need to know how the time is reported on the 'updateend' event. When I log the event to the Chrome console I get the following data:

enter image description here

As shown in the screenshot there is a timeStamp value reported as timeStamp. I am currently unable to make heads or tails of it and need to know is it milliseconds, microseconds or nanoseconds?. Also how can I convert it into seconds so that I can compare the time that the videoplayer is playing to the time that the event was fired?.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
msrameshp
  • 626
  • 2
  • 12
  • 33
  • 2
    I don't get exactly why you want to use this `timeStamp` property. I'm not sure it's really reliable to anything. (Chrome uses `performance.now()` since v49, while others are still on an epoch base). Why don't you just call `performance.now()` in your callback, or even just check `Event.target.currentTime` ? – Kaiido Sep 01 '16 at 04:21

1 Answers1

1

For almost all native event listener (including updateend event), Event.timeStamp returns the time (in milliseconds) at which the event was created (see MDN).

To convert it to seconds use

event.timeStamp / 1E3 | 0;

If you don't want to truncate it, just remove | 0.

Edit

Note that starting with Chrome 49, Event.timeStamp returns a high-resolution monotonic time instead of epoch time.