[英]Javascript audio object onload event
I'm triying to call a function when Javascript audio()
object is loaded, but It doesn't work using onload
. 我正在试图在加载Javascript
audio()
对象时调用函数,但是使用onload
它不起作用。
myaud.onload = audioDone;
But it's working with the image()
object. 但它正在使用
image()
对象。 How can I make it working with audio()
object ? 如何使它与
audio()
对象一起使用?
Thanks 谢谢
An <audio>
element has a specific set of events called media events , and onload
is not one of them <audio>
元素具有一组称为媒体事件的特定事件 ,而onload
不是其中之一
You can check if the audio is loaded and can be played through with the canplaythrough
event 您可以检查音频是否已加载,并可通过
canplaythrough
事件播放
myaud.addEventListener('canplaythrough', audioDone, false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.