Reputation: 191749
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.
Upvotes: 5
Views: 6056
Reputation: 479
w3schools has a useful event, property and method list for audio/video. Although it does not address cross browser concerns:
http://www.w3schools.com/tags/ref_av_dom.asp
Upvotes: 0
Reputation: 4618
As you can see from Matt's fine canIuse link
"Consistant cross-browser support for audio is currently a mess in HTML5 ..."
so you should take a look at sound.js ;)
"... but SoundJS works to abstract away the problems and makes adding sound to your games or rich experiences much easier. "
Upvotes: 0
Reputation: 359816
audio
elementUnfortunately you're experiencing firsthand the fact that there simply is no official JavaScript API for audio (yet).
Upvotes: 8