From 4e2b0daf07cd1fe6eb095f72deb0fa68577270a6 Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Wed, 1 Sep 2021 23:12:24 +0000 Subject: [PATCH] remove debug and cleanup a bit ref #220 --- gulp/res/js/forms.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gulp/res/js/forms.js b/gulp/res/js/forms.js index 2b4e5568..75feab34 100644 --- a/gulp/res/js/forms.js +++ b/gulp/res/js/forms.js @@ -13,14 +13,15 @@ async function videoThumbnail(file) { reject(err); }); hiddenVideo.addEventListener('loadedmetadata', () => { + //apparently 'loadedmetadata' is too early -.- setTimeout(() => { - hiddenVideo.currentTime = 0; //max hiddenVideo.duration - }, 500); //apparently 'loadedmetadata' is too early -.- + hiddenVideo.currentTime = 0; + }, 500); hiddenVideo.addEventListener('seeked', () => { - const canvas = document.createElement("canvas"); + const canvas = document.createElement('canvas'); canvas.width = hiddenVideo.videoWidth; canvas.height = hiddenVideo.videoHeight; - const ctx = canvas.getContext("2d"); + const ctx = canvas.getContext('2d'); ctx.drawImage(hiddenVideo, 0, 0, canvas.width, canvas.height); ctx.canvas.toBlob(blob => { resolve(blob); @@ -377,10 +378,8 @@ class formHandler { case 'video': try { const thumbnailBlob = await videoThumbnail(file); -console.log(thumbnailBlob) item.url = URL.createObjectURL(thumbnailBlob); } catch (err) { -console.error(err) //couldnt create video thumb for some reason item.url = '/file/video.png' }