Is there an oncomplete event for HTML5 audio?

前端 未结 2 1523
傲寒
傲寒 2020-12-05 18:35

Is there an oncomplete event for HTML5 audio? I could not find anything on this. I am trying to play a sound after it completes.

Well, specifically I am

相关标签:
2条回答
  • 2020-12-05 18:51

    The correct way to to this is using the addEventListener function:

    audio.addEventListener('ended', PlayNext);
    
    0 讨论(0)
  • 2020-12-05 19:05

    There is the ended event . . .

    http://dev.w3.org/html5/spec/Overview.html#event-media-ended

    Example:

    var audioElement = document.getElementById("myAudio");
    
    audioElement.addEventListener('ended', function() {
        // Audio has ended when this function is executed.
    },false);
    
    0 讨论(0)
提交回复
热议问题