javascript 获得以秒计的视频时长

 

<!DOCTYPE html>
<html>
<body>

<h3>演示如何访问 VIDEO 元素</h3>

<video id="myVideo" width="320" height="240" controls>
  <source src="/i/movie.mp4" type="video/mp4">
  <source src="/i/movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>

<p>请点击按钮来获得以秒计的视频时长。</p>

<p id="demo"></p>

<button onclick="myFunction()">试一下</button>

<script>
function myFunction()
{
var x = document.getElementById("myVideo").duration;
document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

 

posted @ 2019-03-18 12:17  anobscureretreat  阅读(563)  评论(0编辑  收藏  举报