有控件的播放器
html
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>播放音频</title> </head> <body> <audio src="raw/1.mp3" controls="controls">你的浏览器不支持</audio> </body> </html>
播放器不可见,用按钮控制播放
html
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>播放音频</title> </head> <body> <button onclick="clickA()">播放/暂停</button> <audio id="audio" src="raw/1.mp3">你的浏览器不支持</audio> <script> var a=document.getElementById("audio"); function clickA(){ if(a.paused){ a.play(); }else{ a.pause(); } } </script> </body> </html>