<body>
<audio src="b.mp3" controls="controls" preload id="music" hidden>
</audio>
<span onclick="control();">播放/暂停</span>
<span onclick="repeat();">重播</span>
<script>
function repeat(){
var audio = document.getElementById(‘music‘);
audio.currentTime = 0;//重新播放
}
function control(){
var audio = document.getElementById(‘music‘);
if(audio!==null){
if(audio.paused){
audio.play();// 播放
}else{
audio.pause();// 暂停
}
}
}
</script>
</body>
时间: 2024-10-15 23:25:19