音频播放时出现 Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD


<audio id="play" controls="controls" loop="loop">
  <source src="horse.mp3" type="audio/mpeg">
</audio>
浏览器出现:Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD 

原因:Chrome的autoplay政策在2018年4月做了更改。

解决办法:

第一步,在chrome浏览器中输入:chrome://flags/#autoplay-policy

第二步,在Autoplay policy中将Default改为No user gesture is required

第三步,重启Chrome

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM