我尝试使用代码
window.load=function(){
myVideo=document.getElementById('video')[0];
if(!myVideo.webkitDisplayingFullscreen){
goFullscreen();
}
function goFullScreen(){ myVideo.webkitEnterFullscreen();}
}
并且铬说: 未捕获的InvalidStateError:无法执行' webkitEnterFullscreen' on' HTMLVideoElement':此元素只能进入全屏模式 对用户手势的响应
还有一些其他解决方案可以自动获得全屏模式吗?
答案 0 :(得分:1)
你可以像我的例子那样做一个视频作为你的页面的背景,检查小提琴
全屏:https://jsfiddle.net/N4Lbp/4/embedded/result/
HTML:
<video autoplay loop poster="http://peach.blender.org/wp-content/uploads/bbb-splash.png" id="video_bg">
<source src="http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_stereo.ogg" type="video/ogg">
<source src="http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4" type="video/mp4">
</video>
CSS:
*, *:after, *:before {
box-sizing: border-box;
-moz-box-sizing: border-box;
}
html, body {
height: 100%;
}
#video_bg {
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
position: fixed;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
z-index: -100;
background: url(http://peach.blender.org/wp-content/uploads/bbb-splash.png) no-repeat;
background-size: cover;
}