VIDEO当前视频的总长度和视频进度

Posted 朴pu客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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: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);
}

以上是关于VIDEO当前视频的总长度和视频进度的主要内容,如果未能解决你的问题,请参考以下文章