js 获取视频的总时长

js 获取视频的总时长:

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>

<video id="videoPlayerNew" src="http://vfx.mtime.cn/Video/2019/03/18/mp4/190318231014076505.mp4" controls="controls">
your browser does not support the video tag
</video>
</body>
<script type="text/javascript">
    var vid = document.getElementById("videoPlayerNew");
        vid.onloadedmetadata = function() {
              console.log('metadata loaded!');
              console.log(vid.duration); //打印时长
        };
</script>
</html>

转自:https://stackoverflow.com/questions/40763057/trying-to-get-full-video-duration-but-returning-as-nan

posted @ 2020-05-12 22:29  Ananiah  阅读(11584)  评论(2编辑  收藏  举报