revision:
The onseeking attribute defines a script to run when the user starts moving/skipping to a new position in the audio/video.
The onseeking attribute is part of the event attributes and can be used on the following elements: <audio> and <video>.
Use the "currentTime" property of the Audio/Video Object to get the current playback position.
<element onseeking="script"></element>
script: the script to be run on onseeking.
Move to a new position in the audio:
<div> <p class="spec" id="demo-aa">Move to a new position in the audio:</p> <audio style="margin-left:3vw;" id="myAudio-1" controls onseeking="myFunction()"> <source src="../../pics/horse.wav" type="audio/wav"> Your browser does not support the audio element. </audio> </div> <script> function myFunction() { document.getElementById("demo-aa").innerHTML = "You moved to position " + document.getElementById("myAudio-1").currentTime; } </script>
Move to a new position in the video:
<p class="spec" id="demo-1">Move to a new position in the video:</p> <video style="margin-left:3vw;" id="myVideo" width="320" height="176" controls onseeking="myFunc()"> <source src="../../pics/Wuzhen-20-10_02.mp4" type="video/mp4"> Your browser does not support HTML5 video. </video> <script> function myFunc() { document.getElementById("demo-1").innerHTML = "You moved to position " + document.getElementById("myVideo").currentTime; } </script>