Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comprehensive html5 Audio API

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.

like image 971
Explosion Pills Avatar asked Dec 02 '11 15:12

Explosion Pills


1 Answers

  • HTML5 spec: the audio element
  • When can I use... audio compatibility tables (and links to external resources)

Unfortunately you're experiencing firsthand the fact that there simply is no official JavaScript API for audio (yet).

like image 113
Matt Ball Avatar answered Oct 04 '22 00:10

Matt Ball