Javascript DOM onseeking Event on <audio> element

Introduction

Execute a JavaScript when the user starts moving to a new position in the audio:

This example demonstrates how to assign an "onseeking" event to an audio element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<p>Move to a new position in the video.</p>

<audio controls onseeking="myFunction()">
  <source src="sound.ogg" type="audio/ogg">
  <source src="sound.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>/* ww  w  . j av  a  2  s .  c  o m*/

<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Seek operation began!";
}
</script>

</body>
</html>



PreviousNext

Related