<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<audio
src="https://ip-h5-nf01-sycdn.kuwo.cn/08fc62da0d838431d2c6135ddd66c5ae/5e1bdce5/resource/n2/97/38/2347707388.mp3"
controls id="music"></audio>
<button id="play">播放</button>
<button id="paused">暂停</button>
</body>
<script>
//封装函数让谷歌浏览器自动播放
function play() {
var music = document.getElementById("music");
//判断如果音乐停止播放中,就让他播放。。。
if (music.paused) {
music.paused = false;
music.play();
}
}
//调用函数
setInterval(play(), 1);
</script>
</html>