本文主要是介绍play() failed because the user didn‘t interact with the document first.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
起因: 进入页面视频不自动播放(有时候可以,有时候不行)。
原因: Chrome
在66
版本后为了避免标签产生随机噪音,都在遵循autoplay政策。
解决方法: 为 video
标签设置静音状态即可(添加 muted
属性)
<video src="xxx.mp4" autoplay muted preload class="video" id="xx"></video>
经测试,上面方法可以解决问题
这篇关于play() failed because the user didn‘t interact with the document first.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!