Onload event for javascript sound object


I try to call a function when a Javascript object is audio()loaded, but it does not work with onload.

myaud.onload = audioDone;

But it works with an object image(). How can I make it work with an object audio()?
thanks

+4
source share
1 answer

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

You can check if the sound is loaded and can be played using the event canplaythrough

myaud.addEventListener('canplaythrough', audioDone, false);
+3
source

Source: https://habr.com/ru/post/1623571/


All Articles