Facing Problem in retrieving HTML5 video duration

JavascriptWeb DevelopmentFront End Scripts

To get the video duration, query the readyState attribute. It has a series from 0 to 4. When the metadata has loaded, the value you will get is 1.

Therefore, you need to do something like −

window.setInterval(function(tm) {
   // Using readyState attriute
   if (video.readyState > 0) {
      var duration = $('#duration').get(0);
      // for video duration
      var video_duration = Math.round(video.duration);
      duration.firstChild.nodeValue = video_duration;
Published on 05-Apr-2018 11:02:00