play() failed because the user didn‘t interact with the document first.

起因: 进入页面视频不自动播放(有时候可以,有时候不行)。
原因: Chrome66版本后为了避免标签产生随机噪音,都在遵循autoplay政策。

解决方法:video 标签设置静音状态即可(添加 muted 属性)

<video src="xxx.mp4" autoplay muted preload class="video" id="xx"></video>

经测试,上面方法可以解决问题

猜你喜欢

转载自blog.csdn.net/qq_17627195/article/details/134347082