我有一个循环播放的背景视频,它在台式机上效果很好,但是当我在移动设备上看到它时,它无法播放

时间:2019-03-14 19:33:04

标签: html css html5

在台式机或笔记本电脑上的所有尺寸上均可完美运行,但是当我在移动设备上看到它时,它看起来就像图像。

.video {
  position: fixed;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  z-index: -100;
  transform: translate(-50%, -50%);
}
<video controls autoplay muted loop id="myVideo">
    <source src="img/Smartphone - 3180.webmsd.webm" type="video/webm">
 </video>

In mobile instead of autoplaying it stays like that, the video is in webm format

1 个答案:

答案 0 :(得分:1)

许多移动浏览器不支持在移动设备上自动播放,但是,在适用于android的chrome的更新版本以及iOS上的浏览器上,只要将视频静音,它们就应该能够自动播放。

Check out this answer as well

编辑: 看来您还需要在视频元素上具有属性playsinline才能起作用。

<video controls autoplay muted playsinline></video>

This forum mentioned the playsinline attribute that is needed to work