我在我的网站上使用视频标签。它适用于所有主流浏览器,但我遇到了 Firefox 的问题。
当我点击播放按钮时,视频滚动到视频结尾!
为了开始播放视频,我需要将视频倒退到开始以外的位置,然后单击播放。奇怪的。我试图将视频的初始位置设置为 1s,但没有帮助。我仍然需要手动滚动它。任何帮助将不胜感激。谢谢
<video width="80% height="80%" controls id="video1">
<source src="videos/<cfoutput>#getVideo.URL#</cfoutput>.mp4" type="video/mp4">
<source src="videos/<cfoutput>#getVideo.URL#</cfoutput>.ogv" type="video/ogg">
<source src="videos/<cfoutput>#getVideo.URL#</cfoutput>.webmhd.webm" type="video/webm">
Your browser does not support the video tag.
</video>
Javascript:
视频 */
function setupVideo(){ if(!myVideo){ console.log("设置视频"); myVideo=document.getElementById("video1"); timeElapsed = 0; 计时器;
myVideo.addEventListener("play",videoStarted,false); myVideo.addEventListener("pause",videoPaused,false); myVideo.addEventListener("loadeddata",videoLoaded,false); console.log(" Video Element is: "+myVideo); } else{ console.log("Video Was Already set"); playPause(); }
}
函数 playPause() { if (myVideo.paused) myVideo.play(); 否则 myVideo.pause(); }
function videoLoaded(e) { console.log("视频加载"); myVideo.currentTime = 1; }
function videoStarted(e) { console.log("视频开始"); //启动定时器 timer = setInterval(videoPlaying,1000); }
函数 videoPlaying(){ timeElapsed ++; console.log("视频播放"+myVideo.currentTime);
if(Math.ceil(myVideo.currentTime)== 10) { console.log(" it reached 10 now display quiz"); playPause(); }
}
函数 videoPaused(e) { clearInterval(timer); console.log("暂停"); }