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; clearInterval(tm); } },1000);