Reputation:
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
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