Adding event listener to audio HTML5 tag in javascript

帅比萌擦擦* 提交于 2019-11-30 10:53:40

try:

audio.addEventListener('ended', foo);

This is the correct and standard method to add event listeners.

user1217010

First, make sure whether audio element has the event before you use it, suppose the HTMLAudioElement is audio, you can test it like this audio.hasOwnProperty('onended')

Based on my browser, it doesn't support.

I found this very helpful jsfiddle from Google: http://jsfiddle.net/aarongloege/fzXsT/light/

{Code on /*jsFiddle*/}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!