HTML DOM Video buffered Property

HTMLWeb DevelopmentFront End Technology

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

Following is the syntax −

Returning TimeRanges Object

mediaObject.buffered

Let us see an example of Video buffered property −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Video buffered</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-buffered</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="Get Buffered Seconds">
         <div id="divDisplay"></div>
      </fieldset>
   </form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var demo = document.getElementById("demo");
   demo.buffered = true;
   function getTrackDetails() {
      divDisplay.textContent = 'Buffered: '+demo.buffered.end(0)+' seconds';
   }
</script>
</body>
</html>

Output

Clicking ‘Get Buffered Seconds’ button without playing video −

Clicking ‘Get Buffered Seconds’ button after playing video −

raja
Published on 30-Oct-2019 06:44:52
Advertisements