como executar o código js quando o vídeo está totalmente em buffer / carregado
Eu procurei em todo o google por isso e nada faz o que é suposto Funciona perfeito no IE ... Você pode vê-lo nos logs em que funciona perfeitamente ... Mas não funcionará no chrome !!! Por que está fazendo isso no chrome? ... Carrega 10sek de catche e depois nada ...
<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>
Talvez alguém tenha outra maneira de fazer isso? Quando o vídeo estiver totalmente carregado ... isso deve ser executado ...
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);
EDITAR:
Tentei isso:
<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>
Não funciona !!
Untaught SyntaxError: token inesperado, Uncaught ReferenceError: runVideoRain não está definido onloadeddata