Video object property currentTime in Javascript
The video object property currentTime used to set and retrieve the current playback position in a video in seconds. It allows to jump playback time to the specified position. It returns a number that represents the current playback time in seconds.
Syntax
 1 <video>.currentTime // to retrieve
 2 <video>.currentTime = <number> // to set
video : A video element object to set and retrieve currentTime property
number : It specifies the video playback current time in seconds
Video property currentTime
 1 <html>
 2 <style>
 3   .container {
 4     margin: 10px 0;
 5   }  
 6 </style>
 7 <body>
 8 	<h1>The Video Object</h1>
 9 	<h2>Example</h2>
 10 	
 11 	<div>
 12 	  <video id="video" width="320" height="240" controls >
 13 	    <source src="sample.mp4" type="video/mp4">
 14 	    Your browser does not support the video tag.
 15 	  </video>
 16 	</div>
 17 	<p>	  
 18 	  <button onclick="access()">Access</button>
 19 	</p>
 20 	<p id="result"></p>
 21 	
 22 	<script>
 23 	function access() {
 24 	  const video = document.getElementById("video");
 25 	  const str = `Video current time is : <b>${video.currentTime}</b>`;
 26 	  document.getElementById("result").innerHTML = str;
 27 	}
 28 	</script>
 29 </body>
 30 </html>
Video property currentTime
Privacy Policy
Terms of Service
Disclaimer
Contact us
About us