firefox mobile/firefox focus 应该总是自动播放视频吗?

问题描述

添加一个视频作为背景(您可以找到许多技巧),该视频可以在 chrome 移动设备和桌面设备上自动播放,但不能在 Firefox 移动设备和 Firefox Focus 上自动播放。它是特定于 mozilla 的吗?移动视频有规则吗?

video#bgvid {
    position: fixed;
    right: 0; bottom: 0;
    min-width: 100%; min-height: 100%;
    width: auto; height: auto; z-index: -10;
    background-size: cover;
}


<script>
    window.onload = function(){
        document.getElementById('bgvid').play();
    }
</script>


<video id="bgvid" playsinline src="bg3.mp4" autoplay="autoplay" loop autoplay muted>
</video>

VLC video info,dimensions,codec,was compressed with AVIDemux

解决方法

我已经在所有浏览器上测试过它与 javascript 事件完美配合

<video onloadeddata="this.play();" poster="poster.png" playsinline loop muted controls>
    <source src="video.mp4" type="video/mp4" />
    <source src="video.mp4.webm" type="video/webm" />
    <source src="video.mp4.ogg" type="video/ogg" />
    Your browser does not support the video tag or the file format of this video.
</video>