<!DOCTYPE html>
<html>
<body>
<script>
function myFunction() {
alert('The audio has ended');
}
</script>
<p>Press play and wait for the audio to end.</p>
<audio controls onended="myFunction()">
<source src="https://download.samplelib.com/mp3/sample-3s.mp3" type="audio/ogg">
<source src="https://download.samplelib.com/mp3/sample-3s.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>