HTML5 Game - Preloading the Video for video element

Introduction

The preload attribute tells the browser whether it should download the video when the page that contains the video element is first loaded.

Preloading the video reduces the initial delay when the user starts playback.

It can be a waste of network bandwidth if the user doesn't view the video.

The allowed values for this attribute are described in the following table.

Value
Description
none
The video will not be loaded until the user starts playback.
metadata

Only the metadata for the video (width, height, first frame, duration, and other such
information) should be loaded before the user starts playback.
auto

Requests that the browser download the video in its entirety as soon as possible.
The browser is free to ignore this request. This is the default behavior.

The following table shows the none and metadata values in use in the same document.

Demo

ResultView the demo in separate window

<!DOCTYPE HTML>  
<html>  
    <head>  
        <title>Example</title>  
    </head>  
    <body>  
        <video width="360" height="240" src="http://java2s.com/style/demo/your.webm"  
                controls preload="none" muted>  
            Video cannot be displayed  //  ww w  .  ja v a  2  s .  com
        </video>  
        <video width="360" height="240" src="http://java2s.com/style/demo/your.webm"  
                controls preload="metadata" muted>  
            Video cannot be displayed  
        </video>  
    </body>  
</html>

Related Topic