Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I preload multiple video resources to load in the same HTML5 <video> element?

I'm working out details on a web application which involves the sequential loading of a long series of (very short) video clips, one after the other, with occasional input from the user establishing new directions for which video clips to load.

I would like to be able to have the browser preload the video clips five at a time. However, the way that we currently have the site working is by means of a single video element which is having its src attribute continually updated through JavaScript.

Is there a straightforward way I can get the browser to preload multiple video clips even though I am ultimately loading them all (one at a time) into the same video element?

like image 821
S P Avatar asked Sep 09 '10 20:09

S P


People also ask

What is the correct HTML5 element for playing video files?

<video>: The Video Embed element. The <video> HTML element embeds a media player which supports video playback into the document.

What is HTML preload?

The HTML preload Attribute is used to specify the way the author thinks the media should be loaded when the page loads. The preload attribute allows the author to portray to the browser about the way the user experience of a website should be implemented.


1 Answers

You can preload images in browsers by creating an <img> tag in JavaScript, and setting its src attribute. Although it’s not required by any spec, all browsers then download the image and cache it (assuming their caches haven’t been disabled).

I’ve no idea if that works with the <video> element in HTML5, but it might do. Could you give it a go?

like image 173
Paul D. Waite Avatar answered Oct 04 '22 17:10

Paul D. Waite