For the life of me, I cannot find a complete listing of all html5 <audio>
events and attributes (though I believe they may vary between browsers). A lot of my googling has websites talking about "using the javascript audio api" or "with the javascript audio api," etc. and shows a couple of examples, but I haven't found a list of methods or what they do.
For example,
var a = document.getElementById('audio');
a.ended = function () { alert('foo!'); }; //FAIL
a.onended = function () { alert('foo!'); }; //FAIL
a.addEventListener('ended', function () { alert('foo!'}); }; //PASS
a.addEventListener('play', function () { alert('foo!'}); };
Why is there no onended
? Why is it called play
instead of played
? These things aren't intuitive, so an actual list of the API would help a lot.
Additionally, do some browsers not respect the above attributes? My blackberry phone and mobile-ie9 won't alert on the ended event, but chrome, ffx, and ipad-safari all do.
audio
elementUnfortunately you're experiencing firsthand the fact that there simply is no official JavaScript API for audio (yet).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With