js监听audio播放完毕

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>audio监听播放完毕</title>
</head>
<body>

<audio src="1.mp3" id="audio" controls="true" autoplay="true">
  <!-- <source src="1.mp3" type="audio/mpeg"> -->
  Your browser does not support the audio element.
</audio>
<script>
    var audio = document.getElementById("audio"); 
    audio.loop = false;
    audio.addEventListener('ended', function () {  
        alert('over');
    }, false);
</script> 
</body>
</html>

 

你可能感兴趣的