开发者

Is there an oncomplete event for HTML5 audio?

开发者 https://www.devze.com 2023-02-12 17:29 出处:网络
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.

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 trying to play through an array of sounds one after the other.

Thanks.


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);


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

audio.addEventListener('ended', PlayNext);
0

精彩评论

暂无评论...
验证码 换一张
取 消