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

<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:00div>
<div id="duration">0:00div>

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);
}

 

转载于:https://www.cnblogs.com/liujianhui/p/4599477.html

你可能感兴趣的:(html5 video获取当前时间和视频总时间长度)