charset="utf-8">
name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
音乐
src="b.mp3" controls="controls" preload id="music1" hidden>
id="bf" onclick="bf();">播放/暂停
id="bf" onclick="rbf();">重新播放</span>
function rbf(){
var audio = document.getElementById(‘music1‘);
audio.currentTime = 0;
}
function bf(){
var audio = document.getElementById(‘music1‘);
if(audio!==null){
//检测播放是否已暂停.audio.paused 在播放器播放时返回false.
alert(audio.paused);
if(audio.paused) {
audio.play();//audio.play();// 这个就是播放
}else{
audio.pause();// 这个就是暂停
}
}
}
</script>
</html>
来源: http://www.bubuko.com/infodetail-1980880.html