【发布时间】:2014-01-29 21:01:06
【问题描述】:
我已经在谷歌上搜索了这个,但没有什么能做它应该做的事情 它在 IE 中完美运行......你可以在日志中看到它完美运行......但它不会在 chrome 中运行! 为什么它在 chrome 中这样做? ...它从 catche 加载 10sek,然后什么都没有 ...
<div style=" width:100%; height:320px; margin-top:-95px; background-image:url('video-logo.png'); background-repeat:no-repeat; background-position:center;">
<div id="videoRain" class="videoWrapper" style="text-align:center; display: none;">
<video id="rainVideo" width="100%" height="400px" preload="auto">
<source src="rain-video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
</div>
<script>
setTimeout(function(){
var refreshId = window.setInterval(function(){
myVid=document.getElementById('rainVideo');
puhvitud = Math.round(myVid.buffered.end(0));
if (puhvitud >= 14) {
setTimeout(function(){document.getElementById('videoRain').style.display='block';},0);
setTimeout(function(){document.getElementById('rainVideo').play();},0);
clearInterval(refreshId);
setTimeout(function(){document.getElementById('videoRain').style.display='none';},15000);
}
console.log(puhvitud);
}, 2000);
},1000);
</script>
也许有人有另一种方法来做到这一点? 当视频完全加载...这应该运行...
setTimeout(function(){document.getElementById('videoRain').style.display='block';},0);
setTimeout(function(){document.getElementById('rainVideo').play();},0);
setTimeout(function(){document.getElementById('videoRain').style.display='none';},15000);
编辑:
试过这个:
<script>
function runVideoRain(){
rainVideo.addEventListener("loadeddata", runRain, false);
}
function runRain()
{
setTimeout(function() {document.getElementById('videoRain').style.display='block';},0);
setTimeout(function(){document.getElementById('rainVideo').play();},0);
setTimeout(function() {document.getElementById('videoRain').style.display='none';},15000);
}, false);
</script>
不行!!
Uncaught SyntaxError: Unexpected token , 未捕获的 ReferenceError:未定义 runVideoRain 加载数据
【问题讨论】:
-
Onloadeddata="myfunc()" - 不起作用!!! ... readyState === 4 - 不起作用! ... canplaythrough - 不起作用! ...这些只是加载视频几秒钟
-
刚试过这个... oncanplaythrough ...它只是在加载视频标签时启动功能,而不是等待视频加载!
-
仅供参考(问题后 3 年)“canplay”适用于当前的 Chrome。 Javascript 示例:
var video = document.getElementById('myvideo');video.oncanplay = function(){...};例如,我测试了在开始播放视频时淡出覆盖视频的图像。