Horje

Alert that the audio has started to play

Play audio

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>
<script>
function myFunction() { alert('The audio has started to play');
}
</script>
<p>Press play on the audio:</p>
<audio controls onplay="myFunction()"> <source src="https://file-examples.com/index.php/sample-audio-files/sample-mp3-download/" type="audio/ogg"> <source src="https://file-examples.com/index.php/sample-audio-files/sample-mp3-download/" type="audio/mpeg"> Your browser does not support the audio element.
</audio>
</body>
</html>

Output should be:

Alert that the audio has started to play




Type :
html
Category :
Web Tutorial
Sub Category :
HTML Media Events Attribute
Uploaded by :
Admin