HTML DOM Video played Property


The HTML DOM Video played property returns a TimeRanges object containing information about the video’s played range length and its start, end position.

Syntax

Following is the syntax −

Returning TimeRanges Object

mediaObject.played

Let us see an example of Video played property −

Example

Live Demo

<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Video played</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-played</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="How much free view time is left?">
         <div id="divDisplay"></div>
         </fieldset>
   </form>
   <script>
      var divDisplay = document.getElementById("divDisplay");
      var demo = document.getElementById("demo");
      demo.autoplay =true;
      var limit = 5;
      function getTrackDetails() {
         divDisplay.textContent = 'You have '+(limit - demo.played.end(0))+' seconds left';
      }
   </script>
</body>
</html>

Output

Clicking ‘How much free view time is left?’ button with playing video −

Clicking ‘How much free view time is left?’ button after playing video for some seconds −

Updated on: 18-Feb-2021

73 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements