How can i continuously get a html-videos current time?

I’m trying in js to get a videos current time. I have come up with a rather ugly and not so precise solution, using a setInterval on the play event. But i would very much prefer using a better method. Maybe requestAnimationFrame could do it? I’m open for a better solution.

Current code: = document.createElement('video')
  this.duration = null
  this.currentTime = null'play',

  play(e) {
    setInterval(() => {
      this.currentTime =
    }, 1000)

>Solution :

I think what you’re looking for is the timeupdate event.


let video = document.getElementById("video");
let currentTime = null;

video.addEventListener('timeupdate', timeUpdate);

function timeUpdate(e) {
  currentTime =;
  console.log("Time: " + currentTime);
<video id="video" width="400" controls>
  <source src="" type="video/mp4">

Leave a Reply