Answer the question
In order to leave comments, you need to log in
Why does determining the duration of a video file through JavaScript not work?
I asked for help in solving this problem. How to determine the duration of a JavaScript video file and display it on the site? I need to determine the duration of the video file through javaScript. They helped me. But for some reason the code doesn't work. I don't know much about code. And for this I need your help.
<h2>Видео контент номер 1</h2><span class="time">тут выводит время</span>
<video id="myvideo" width="480" height="270">
<source src="http://doktorpull.myjino.ru/uploads/files/1388073459_pixel-news-v1.mp4">
</video>
(function(window) {
var videoNode = window.document.querySelector('#myvideo');
var timeNode = window.document.querySelector('.time');
videoNode.addEventListener('loadedmetadata', function(e) {
var duration = videoNode.duration.toFixed(1);
var m = duration % 60;
timeNode.innerText = Math.floor(duration / 60) + ':' + (m < 10 ? '0' : '') + m;
});
})(window);
Answer the question
In order to leave comments, you need to log in
Stop duplicating questions! You have been given a code. He works. Everything is displayed and working on JSFiddle. What else do you need?
@Anonym he doesn't display the duration of the video in the span tag<span class="time">тут выводит время</span>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question