音頻播放時出現 Uncaught (in promise) DOMException: play() failed because the user didn't interact with the

<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

解決辦法:promise

第一步,在chrome瀏覽器中輸入:chrome://flags/#autoplay-policy瀏覽器

第二步,在Autoplay policy中將Default改成No user gesture is requiredoop

第三步,重啓Chromeui

相關文章
相關標籤/搜索