预加载视频文件 - HTML5播放 [英] Preloading Video Files - HTML5 playback

查看:1274
本文介绍了预加载视频文件 - HTML5播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网站首次加载时预先加载一些小视频文件。这样,当用户点击进入网站的某个部分时,可以自动播放和使用它们。我需要转换是无缝的,所以理想情况下应该预加载整个视频文件以避免任何延迟。

Im looking to preload a number of small video files on my website when it first loads. This is so they can be auto-played and used when a user clicks to enter a section of the website. I need the transitions to be seamless so ideally the whole video file should be preloaded to avoid any delays.

我尝试了一些不同的插件,比如html5preloader,以及其他一些JS技术,将视频文件加载到页面,但隐藏它们试图强制浏览器加载我使用它们之前的视频。

Ive tried a few different plugins like html5preloader, and also some other JS techniques to load the video files to the page but hide them to try and force the browser to load the videos before i use them.

当我需要播放不同的视频时,两者都没有真正改变视频src。

Neither have really made much difference to just swapping out the video src when i require to play a different video.

实际上是否有适当的解决方案,或者是因为HTML5视频播放,浏览器仅在播放时部分下载文件?

Is there actually a proper solution for doing this or is it because of the HTML5 video playback that the browser only Partially downloads the file as it is played back?

欣赏关于为HTML5播放预加载视频文件的任何想法和反馈。

Appreciate any thoughts and feedback on preloading video files for HTML5 playback.

谢谢

推荐答案

这样的事情应该会有所帮助:

something like this should help:

<video controls="controls" preload="auto">
  <source src="sample.mp4" type="video/mp4" />
  ...
  Your browser does not support the video tag.
</video>

但是因为preload =auto在浏览器中不一致,所以你的milage可能会有所不同。如果这些是非常短的剪辑(你提到5秒)那么它可能会相当可靠

though because preload="auto" isn't consistent across browsers your milage may vary. If these are very short clips (you mentioned 5 seconds) then it probably will be fairly reliable

这篇关于预加载视频文件 - HTML5播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆