简体   繁体   English

预加载视频文件 - HTML5播放

[英]Preloading Video Files - HTML5 playback

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. 我需要转换是无缝的,所以理想情况下应该预加载整个视频文件以避免任何延迟。

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

Neither have really made much difference to just swapping out the video src when i require to play a different video. 当我需要播放不同的视频时,两者都没有真正改变视频src。

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. 欣赏有关为HTML5播放预加载视频文件的任何想法和反馈。

Thanks 谢谢

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>

though because preload="auto" isn't consistent across browsers your milage may vary. 虽然因为preload =“auto”在浏览器中不一致,所以你的milage可能会有所不同。 If these are very short clips (you mentioned 5 seconds) then it probably will be fairly reliable 如果这些是非常短的剪辑(你提到5秒)那么它可能会相当可靠

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM