Forum Moderators: open

Message Too Old, No Replies

attach function to <audio> tag

         

Oddjob41

4:00 am on Jun 20, 2018 (gmt 0)

5+ Year Member Top Contributors Of The Month



Hi,

I have an mp3 file coded like this:
<audio id="myaudio" autoplay>
<source src="sound/mybig.mp3" type="audio/mpeg">
</audio>

I want to attach a function to it, so that the function fires when the player starts.
I've done a trawl of the basics, but can't see an "onplay" event... like
<audio id="myaudio" autoplay onplay="myFunction();">

Any advice appreciated.
Cheers.

Oddjob41

4:20 am on Jun 20, 2018 (gmt 0)

5+ Year Member Top Contributors Of The Month



's OK... onplay="my function();" works.

keyplyr

4:25 am on Jun 20, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Good work :)