creationRoutine = {
let videoIndex = 1;
setTimeout(
() =>
setInterval(() => {
const videoSphereIndexActive = (videoIndex + 1) % 2;
const videoSphereIndexInactive = videoIndex % 2;
const videoSphere = $(`#video-sphere-${videoSphereIndexInactive}`);
videoSphere.attr("visible", true);
$(`#video-sphere-${videoSphereIndexActive}`).attr("visible", false);
const randomNumber = videoIndex % tesla_video.length;
const video = $(`<video id='video-${videoIndex}' />`);
video.attr("loop", true);
video.attr("crossorigin", "anonymous");
video.attr("src", tesla_video[randomNumber]);
video[0].addEventListener(
'loadeddata',
function() {
console.log("Play");
video[0].muted = true;
video[0].play();
},
false
);
$("#assets").append(video);
videoSphere.attr("src", `#video-${videoIndex}`);
videoIndex++;
$("#assets").append(video);
}, 2000),
3000
);
}