0
How can I add a simple (any) "loading" animation to the center of the canvas tag that is created while generating the image? (Obs: canvas size may change) ; Below in the script it is generating thumbnails directly from url’s (audiences) of videos
function thumbnailList() {
var link = document.querySelectorAll(".selecao.video");
for (let x = 0; x < link.length; x++) {
let video = document.createElement("video");
video.addEventListener('loadeddata',
function() {
this.currentTime = 6;
}, false);
video.addEventListener('seeked',
function() {
generateThumbnail(this, link[x]);
}, false);
video.preload = "auto";
video.src = link[x].value;
}
}
function generateThumbnail(video, link) {
let canvas = document.createElement("canvas");
let ctx = canvas.getContext("2d");
canvas.width = 160;
canvas.height = 90;
ctx.drawImage(video, 0, 0, 160, 90);
link.parentElement.appendChild(canvas);
};
window.onload = thumbnailList();
<div id="box">
<div class="item">
<input class="selecao video" value="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" />
</div>
<div class="item">
<input class="selecao video" value="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" />
</div>
<div class="item">
<input class="selecao video" value="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4" />
</div>
</div>