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

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

时间:2017-09-19 21:24:12      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:js代码   func   read   height   control   视频   mp4   代码   ready   

标签:

<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获取当前时间和视频总时间长度

标签:js代码   func   read   height   control   视频   mp4   代码   ready   

原文地址:http://www.cnblogs.com/yeyifu/p/7553840.html

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