1
I have a website where every access it shows a different video. The code is 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 other times the background turns white and when I see on the console, the message appears below:
But the videos are correctly inside the directory:
I tried to change that line:
if(videoaleatorio[video] != "undefined"){
// alert(videoaleatorio[video]);
$('source').attr('src', 'mp4/'+videoaleatorio[video]);
}
But still the problem remains. How do I make sure that the white background no longer appears?
which complete directory path?
– Thiago Magalhães
Hello Thiago. I have already put the absolute path, but the problem continues and the directory is correct.
– user24136