2014-12-06 139 views
0

我想使用Youtube视频作为全屏幕背景以显示初始页面(包括声音)。然而,应该没有控制,暂停的能力等。它应该看起来像背景电影。制作一个Youtube视频全高和宽度覆盖视频

这样做的最好方法是什么?

我应该使用标签还是有其他一些HTML5标签,或者我可以使用完全不同的方法?

回答

0

如果你想使用YouTube播放器,我建议您需要使用Youtube Player API

请记住,您可以让播放器为全背景大小,但无法在播放器内拉伸视频(因此您需要接受不同于原始比率的黑色条纹比例的视频)。我建议你使用html5视频播放器(也许video.js可以帮助你)

P.S .: @ Besto的建议Tubular打破Youtube的服务条款!

0
<div id="ytcon" style="overflow: hidden"> 
<iframe id="fullyt" src="//www.youtube.com/embed/QVr0M7WCBu4?autoplay=1" frameborder="0" allowfullscreen></iframe> 
</div> 

<script> 
$("#ytcon").height($(window).height()); 
$("#ytcon").width($(window).width()); 
$("#fullyt").height($(window).height()); 
$("#fullyt").width($(window).width()); 

$(window).on('resize', function(){ 
$("#ytcon").height($(window).height()); 
$("#ytcon").width($(window).width()); 
$("#fullyt").height($(window).height()); 
$("#fullyt").width($(window).width()); 
}); 

</script> 
+0

如果你想隐藏在顶部和视频的底部的酒吧,你可以通过顶部造型#fullyt负上边距,然后使它比窗口更大的像素所需数量卸下顶部。 – 2014-12-06 21:52:26