Chrome66禁止声音自动播放,也就是说<audio autopaly></audio> <video autoplay></video>
在桌面版浏览器无效。
Chrome设置一加载页面自动播放音频会报错:DOMException: play() failed because the user didn’t interact with the document first.(用户还没有交互,不能调用play())
解决方法:
function sound() {
var music = document.getElementById("vd");/
if (music.paused) { //判读是否播放
music.paused=false;
music.play();
} else{
music.play();
}
}