Is it possible to detect when the play button in the html5 audio player is clicked? For example:
<audio controls> <source src="music.mp3"/> <source src="music.ogg" /> </audio> .... .... $('playbutton').on('click', function(e){ //some functions });
http://www.quackit.com/html_5/tags/html_audio_tag.cfm
$(audio)[0].onplay= function(e){ //some functions };
I tried this but it doesn't do anything, no alert is produced when I click play button:
$(audio)[0].onplay= function(e){ alert('playing'); }; ... ... <audio controls> <source src="music.mp3"/> <source src="music.ogg" /> </audio>
What is the [0] for?
oops:
$('audio')[0].onplay= function(e){ //some functions };