【问题标题】:I have a background video on loop and it works perfectly on desktop, but when i see it on mobile it doesn't play [duplicate]我有一个循环播放的背景视频,它在桌面上完美运行,但是当我在移动设备上看到它时它不播放[重复]
【发布时间】:2019-03-14 19:33:03
【问题描述】:

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

.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

【问题讨论】:

标签: css html


【解决方案1】:

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

Check out this answer as well

编辑: 看起来您还需要在视频元素上添加属性 playinline 才能正常工作。

<video controls autoplay muted playsinline></video>

This forum mentioned the playsinline attribute that is needed to work

【讨论】:

    猜你喜欢
    • 2016-08-02
    • 2020-02-24
    • 1970-01-01
    • 2022-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-05
    • 1970-01-01
    相关资源
    最近更新 更多