<!DOCTYPE html>
<html>
<body>
<p>This example demonstrates how to assign an "onplay" event to an audio element.</p>
<p>Press play.</p>
<audio controls onplay="myFunction()">
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<script>
function myFunction() {
alert("The audio started to play");
}
</script>
</body>
</html>