简体   繁体   English

html5视频海报gif,直到显示完整视频为止

[英]html5 video poster gif to display until full video loaded

I would like to keep the poster gif displayed until the full video has loaded. 我想一直显示海报gif,直到完整的视频加载完毕。 It seems like this is not possible but does anyone else have a work around.` 似乎这是不可能的,但是其他人都无法解决。

<video id="wrVideo" controls poster="/images/busy.gif" 
controlsList="nodownload"  onerror="myFunction()" preload="auto" autoplay>

The gif loads but since chrome will start playing as soon as it thinks it has enough to play, I cannot manipulate this. gif已加载,但是由于chrome将在认为足够播放后立即开始播放,因此我无法对其进行操作。 I can check the buffered value at various times but not sure how I can implement this to only play the video when more than half of the video duration has buffered. 我可以在各个时间检查缓冲的值,但不确定如何将其实现以仅在缓冲了一半以上的视频持续时间时播放视频。

vid.oncanplaythrough = function() {
    if(vid.buffered.end(0) < vid.duration){
        vid.pause;
    }

} }

something like this but rather load the gif/spinner while the buffering reaches that point. 像这样,而是在缓冲到达该点时加载gif / spinner。 Any ideas? 有任何想法吗?

I finally figured this out and it involved a hack around chrome loading playable segments at a time. 我终于弄明白了,它涉及一次铬加载可播放片段的黑客。 I forced the browser to download the entire video and then passed the blob url to the video source and voila, the preloader spins while the video is still loading which takes a while. 我强迫浏览器下载整个视频,然后将blob url传递给视频源,瞧,在视频仍加载时,预加载器旋转,这需要一段时间。

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

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