<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM Events</h1>
<h2>The ontimeupdate</h2>
<p>Assign an "ontimeupdate" event to an audio element.</p>
<p>When the user plays the audio, or skips to a new position, a function will display the position (in seconds) of the playback:</p>
<audio controls ontimeupdate="myFunction(this)">
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<p>Playback position: <span id="demo"></span></p>
<script>
function myFunction(event) {
document.getElementById("demo").innerHTML = event.currentTime;
}
</script>
</body>
</html>