user5672329
user5672329

Reputation:

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.

myaud.onload = audioDone;

But it's working with the image() object. How can I make it working with audio() object ?
Thanks

Upvotes: 7

Views: 1648

Answers (1)

adeneo
adeneo

Reputation: 318162

An <audio> element has a specific set of events called media events, and onload is not one of them

You can check if the audio is loaded and can be played through with the canplaythrough event

myaud.addEventListener('canplaythrough', audioDone, false);

Upvotes: 8

Related Questions