音頻播放時出現 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