Javascript DOM onseeking Event compare with onseeked event

Introduction

This example demonstrates the difference between the onseeking event and onseeked event:

The onseeking event occurs everytime the user STARTS moving to a new position in the audio/video.

The onseeked event occurs when the user is FINISHED moving to a new position in the audio/video.

Move to a new position in the video.

Try to hold down the mouse button and seek back and forth in the video playback.

View in separate window

<!DOCTYPE html>
<html>
<body>
<video controls onseeking="myFunction()" onseeked="mySecondFunction()">
  <source src="video.mp4" type="video/mp4">
  <source src="video.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>//from w w w.j a  va2s. c  o m

<p>seeking occured: <span id="demo"></span> times.</p>
<p>seeked occured: <span id="demo2"></span> times.</p>

<script>
x = 0;
function myFunction() {
  document.getElementById("demo").innerHTML = x += 1;
}

y = 0;
function mySecondFunction() {
  document.getElementById("demo2").innerHTML = y += 1;
}
</script>

</body>
</html>



PreviousNext

Related