关于谷歌浏览器不能自动播放音频的问题
音频播放时报错。Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD
音乐播放
<audio id='audioPlay' src='../assets/style/music/zdqc.mp3' autoplay='autoplay' controls='true' hidden='true' ></audio>
js代码
<script>
function toggleSound() {
var music = document.getElementById("audioPlay");
if (music.paused) {
music.paused=false;
music.play();
}
}
setInterval("toggleSound()",1);
</script>
暂时只能引导用户点击页面任意地方触发,如果有更好的方法欢迎指导