creationRoutine = {
let videoIndex = 1;
let previousVideo = null;
setTimeout(
() =>
setInterval(() => {
const videoSphereIndexActive = (videoIndex + 1) % 2;
const videoSphereIndexInactive = videoIndex % 2;
const randomNumber = videoIndex % tesla_video.length;
gettingBlob(tesla_video[randomNumber], data => {
const objectURL = URL.createObjectURL(data);
console.log(data);
const videoSphere = $(`#video-sphere-${videoSphereIndexInactive}`);
videoSphere.attr("visible", true);
$(`#video-sphere-${videoSphereIndexActive}`).attr("visible", false);
if (previousVideo) {
previousVideo[0].pause();
previousVideo[0].removeAttribute('src');
previousVideo[0].load();
}
const video = $(`<video id='video-${videoIndex}' />`);
video.attr("loop", true);
video.attr("crossorigin", "anonymous");
video.attr("src", objectURL);
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
);
}