码迷,mamicode.com
首页 > Web开发 > 详细

html5 video获取当前时间和视频总时间长度

时间:2018-10-24 15:32:13      阅读:1155      评论:0      收藏:0      [点我收藏+]

标签:strong   event   update   src   this   time   pre   ram   eof   

 html:

<video
    id="video-active"
    class="video-active"
    width="640"
    height="390"
    controls="controls">
    <source src="myvideo.mp4" type="video/mp4">
</video>
<div id="current">0:00</div>
<div id="duration">0:00</div>

js:
$(document).ready(function(){
  $("#video-active").on(
    "timeupdate", 
    function(event){
      onTrackedVideoFrame(this.currentTime, this.duration);
    });
}

function onTrackedVideoFrame(currentTime, duration){
    $("#current").text(currentTime);
    $("#duration").text(duration);
}

html5 video获取当前时间和视频总时间长度

标签:strong   event   update   src   this   time   pre   ram   eof   

原文地址:https://www.cnblogs.com/xiaozhangzhang/p/9842686.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!