日期:2014-05-17  浏览次数:20674 次

HTML5的video实现书签播放
功能:进入页面后,第一次播放从指定位置处(这里假定breakpoint秒)开始,之后从上一次开始。

1、页面中加入video元素。
      <video id='video' preload='none' width="200" height="100" controls autoplay>
    <source id='mp4' type='video/mp4' src="httpURL">
    not supported

      </video>

2、js代码
var MP_Video = document.getElementById("video");

var updatePlayTime = function() {
       MP_Video.currentTime = breakPoint;
       MP_Video.removeAttribute("ontimeupdate");
}

function fromBP() {
if (MP_Video.currentTime == 0) {
MP_Video.setAttribute("ontimeupdate", "updatePlayTime();");
}

MP_Video.play();
}

页面中按钮调用fromBP函数即可