The HTML section loops but repeatedly plays the same randomly selected video selected by the JS. If I refresh the html it will play a different video. I would like it to choose a different random video after each delayms expires. I apologize, I am kind of new to programming and my terminology is off.
//HTML
{url:randvideo1, delayms:10000},
//video arrays found in JS
var videoArray1 = [
"v/video01.mp4",
"v/video02.mp4",
"v/video03.mp4",
"v/video04.mp4"
];
var randvideo1 = videoArray1[Math.floor(Math.random()*videoArray1.length)];
You're probably looking for setInterval which calls a function every given amount of time.
const delay = 3000;
var videoArray1 = [
"v/video01.mp4",
"v/video02.mp4",
"v/video03.mp4",
"v/video04.mp4"
];
function playVideo() {
var randvideo1 = videoArray1[Math.floor(Math.random() * videoArray1.length)];
console.log(`Playing video ${randvideo1} for ${delay / 1000} seconds...`)
/*
The rest of your code to set the new video source in the html.
*/
}
setInterval(playVideo, delay);