I have a website where each access it shows a different video. The code looks like this:
<script>
$('document').ready( function(){
var video = Math.round(Math.random()*7);
var videoaleatorio = [
'fundo.mp4',
'fundo1.mp4',
'fundo2.mp4',
'fundo3.mp4',
'fundo4.mp4',
'fundo5.mp4',
'fundo6.mp4'
];
$('source').attr('src', 'mp4/'+videoaleatorio[video]);
});
//console.log('endereço do video selecionado: '+ $('source').attr('src'));
</script>
....
<div class="overlay"></div>
<video playsinline="playsinline" autoplay="autoplay" muted="muted" loop="loop">
<source src="" type="video/mp4">
</video>
The problem is that sometimes the video appears, but sometimes the background turns white and when I see it in the console, the following message appears:
Butthevideosarerightinsidethedirectory:
Itriedchangingthisline:
if(videoaleatorio[video]!="undefined"){
// alert(videoaleatorio[video]);
$('source').attr('src', 'mp4/'+videoaleatorio[video]);
}
But still the problem continues. How do I stop the white background from appearing again?