如何在移动设备上自动播放,全屏和无控制

时间:2016-02-08 08:25:33

标签: css html5 video mobile autoplay

有没有办法让全屏视频自动播放,无需控制,可以在移动设备上使用?

我使用过的方法只显示了一个黑色背景的播放按钮。

<video poster="#url#" id="backgroundvideo">
<source src="#url#" type="video/mp4">
<source src="#url#" type="video/ogg">
<source src="#url#" type="video/webm">
</video>

backgroundvideo { 
position: fixed;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -1000;
-ms-transform: translateX(-50%) translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
background: url(#url#) no-repeat;
background-size: cover; 
background-size: 100%;
background-position: center;
}

1 个答案:

答案 0 :(得分:0)

波纹管将自动播放来源:

<video width="320" height="240" autoplay>
  <source src="changeme.mp4" type="video/mp4">
</video>

如果您希望在用户的浏览器不支持该方法时显示消息:

<video width="320" height="240" autoplay>
  <source src="changeme.mp4" type="video/mp4">
  Your browser does not support the video.
</video>

以下浏览器及其最低版本号支持上述代码:

enter image description here

相关问题