HTML 5播放器暂停问题



我正在尝试创建一个HTML 5播放器。在其他浏览器芽中,一切正常。如果我尝试暂停并在Chrome视频中播放视频超过2次,则不再播放。所有其他浏览器,但Chrome工作正常。

<video id="myVideo" style="width:100%"></video>
<div id="videoControlsBar">
   <button id="playpausebtn">&#10074;&#10074;</button>
    <span id="curtimetext"></span> / <span id="durtimetext"></span>
</div>
var vid, playbtn;
function initializePlayer() {
    vid = document.getElementById("myVideo");
    playbtn = document.getElementById("playpausebtn");
    curtimetext = document.getElementById("curtimetext");
    durtimetext = document.getElementById("durtimetext");
    playbtn.addEventListener("click", playPause, false);
    vid.addEventListener("timeupdate", seekTimeUpdate, false);
}
window.onload = initializePlayer();
function playPause() {
if (vid.paused) {
    vid.play();
    playbtn.innerHTML = "&#10074;&#10074;";
}
else {
    vid.pause();
    playbtn.innerHTML = "&#9658";;
}
}
function seekTimeUpdate() {
    var nt = vid.currentTime * (100 / vid.duration);
    var curmins = Math.floor(vid.currentTime / 60);
    var cursecs = Math.floor(vid.currentTime - curmins * 60);
    var durmins = Math.floor(vid.duration / 60);
    var dursecs = Math.floor(vid.duration - durmins * 60);
    if (cursecs < 10) { cursecs = "0" + cursecs; }
    if (dursecs < 10) { dursecs = "0" + dursecs; }
    if (curmins < 10) { curmins = "0" + curmins; }
    if (durmins < 10) { durmins = "0" + durmins; }
    curtimetext.innerHTML = curmins + ":" + cursecs;
    durtimetext.innerHTML = durmins + ":" + dursecs;
}
$scope.$on('playVideo', function (event, data) {
    vid.src = "/Content/Videos/SetVideos/" + data.videoLink;
    vid.play();
});
<!DOCTYPE html>
<html><head>
<title>iTech</title>
</head>
<body>
<video width="680" height="320" controls="controls" autoplay="false">
<source src="mp3,mp4 file url">
</video></body></html>

<embed src="mp3,mp4 file url" width="700" height="500" loop="false" autostart="false/>

测试&amp;在Chrome中工作正常。

相关内容

  • 没有找到相关文章

最新更新