【发布时间】:2013-06-05 21:46:31
【问题描述】:
我正在使用 html5 视频进行沙盒实验,我想知道一旦最终用户将鼠标悬停在视频之外,我如何才能让海报图像再次显示?
我有视频设置,因此如果您将鼠标悬停在视频上可以自动播放,如果您将鼠标悬停它会停止。我希望它返回海报图像。
Javascript
<script>
document.addEventListener('mouseover',hoverVideo,false);
var vid = document.getElementById('vid1');
function hoverVideo(a)
{
if(a.target == vid)
{
vid.play();
this.addEventListener('mouseout',hideVideo,false);
}
}
function hideVideo(e)
{
if(e.target == vid)
{
vid.pause();
}
}
</script>
HTML5
<video id="vid1" width="1000" height="418"
poster="poster.png" loop="true" preload="auto"
controls class="video-js vjs-default-skin">
<source src="my_video.mp4" type='video/mp4' >
<source src="my_video.webm" type='video/webm' />
<source src="my_video.ogv" type='video/ogg' />
</video>
【问题讨论】: