njdubois Posted January 30, 2013 Share Posted January 30, 2013 Using an html5 audio tag, I want to trap when a user clicked play, and when (or if) a user clicked stop. This is what I have In my php : <audio controls="controls" name="audio_player" id="audio_player" onclick="javascript: test_for_play(this);"> <source src="audio_upload/' . $filename . '" type="audio/mpeg" /> '.$audio_ABC_html.' </audio> And in the head I have : <script type="text/javascript"> function test_for_play(var name) { window.alert('Message goes here'); } </script> But I don't ever get the pop up? I'm doing one thing at a time, and I can't move forward until I get this function firing when the user clicks a button on the audio tag. Thanks for the help! Nick Link to comment https://forums.phpfreaks.com/topic/273849-save-to-mysql-that-user-played-audio-file/ Share on other sites More sharing options...
requinix Posted January 31, 2013 Share Posted January 31, 2013 elements have onplay and onpause events you can add handlers to. Link to comment https://forums.phpfreaks.com/topic/273849-save-to-mysql-that-user-played-audio-file/#findComment-1409263 Share on other sites More sharing options...
njdubois Posted January 31, 2013 Author Share Posted January 31, 2013 Awesome! You answered my next question, and I figured out why my function wasn't firing. Thanks sooo much! Nick Link to comment https://forums.phpfreaks.com/topic/273849-save-to-mysql-that-user-played-audio-file/#findComment-1409297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.