html5 video preload

a 夏天 提交于 2019-12-03 02:00:33

Try this out:

<!DOCTYPE html>
<html>
<body>

<video width="320" height="240" controls="controls" **preload="auto"**>
  <source src="movie.mp4" type="video/mp4" />
  <source src="movie.ogg" type="video/ogg" />
  <source src="movie.webM" type="video/webM" />
  Your browser does not support the video tag.
</video>

</body>
</html>

Note: This doesnt work on IE ;), for this you can use some player(simply inclusion of a .js). They have a fallbak of flash for IE use JW Player & JW Player Preload

Njoy!!!

I had a similar problem in IE, some of the videos are display:none, and when I show them IE doesn't show first frame...

I used the following code to solve it, when I show the hidden videos I call preloadAllVisible()

var preloadAllVisible = function() {
    $("video:visible").each(preload);
}
var preload = function(key, vid) {
    vid.play(); 
    setTimeout("pausevid("+key+")",100);
}

var pausevid = function(key) {
    vid =$("video:visible")[key];
    vid.pause();
    vid.currentTime = 0;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!