HTML DOM Video currentTime Property


The HTML DOM Video currentTime property returns/sets the current position of seeker (in seconds) of media.

Following is the syntax −

Returning seeker position

mediaObject.currentTime

Setting currentTime to seekable position

mediaObject.currentTime = seconds

Let us see an example of Video currentTime property −

Example

Live Demo

<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Video currentTime</title>
<style>
   * {
      padding: 2px;
      margin:5px;
   }
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   input[type="button"] {
      border-radius: 10px;
   }
</style>
</head>
<body>
   <form>
      <fieldset>
         <legend>HTML-DOM-Video-currentTime</legend>
         <video id="demo" width="320" controls><source          src="http://www.tutorialspoint.com/html5/foo.mp4" type="video/mp4"></video><br>
         <input type="button" onclick="getTrackDetails()" value="Jump some seconds">
         <div id="divDisplay"></div>
      </fieldset>
   </form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var demo = document.getElementById("demo");
   function getTrackDetails() {
      demo.currentTime = '15';
      divDisplay.textContent = 'Some Seconds Avoided';
   }
</script>
</body>
</html>

Output

Before clicking ‘Jump some seconds’ button −

After clicking ‘Jump some seconds’ button −

Updated on: 18-Feb-2021

246 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements