From 6cfd1235bcc837c3a20ccb3338fdac4b533a87d4 Mon Sep 17 00:00:00 2001 From: frost768 Date: Mon, 1 May 2023 00:15:18 +0300 Subject: [PATCH] thumbnailCreator deleted --- src/utils/thumbnailCreator.ts | 41 ----------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 src/utils/thumbnailCreator.ts diff --git a/src/utils/thumbnailCreator.ts b/src/utils/thumbnailCreator.ts deleted file mode 100644 index 159f4349..00000000 --- a/src/utils/thumbnailCreator.ts +++ /dev/null @@ -1,41 +0,0 @@ -export default async function extractThumbnails( - videoUrl: string, - numThumbnails: number -): Promise { - const video = document.createElement("video"); - video.src = videoUrl; - video.crossOrigin = "anonymous"; - - // Wait for the video metadata to load - const metadata = await new Promise((resolve, reject) => { - video.addEventListener("loadedmetadata", resolve); - video.addEventListener("error", reject); - }); - console.log(metadata); - - const canvas = document.createElement("canvas"); - canvas.width = video.videoWidth; - canvas.height = video.videoHeight; - const ctx = canvas.getContext("2d"); - const thumbnails = []; - if (!ctx) return [""]; - - for (let i = 0; i < numThumbnails; i += 1) { - const time = ((i + 1) / (numThumbnails + 1)) * video.duration; - - // Seek to the specified time - video.currentTime = time; - await new Promise((resolve) => { - video.addEventListener("seeked", resolve); - }); - - // Draw the video frame on the canvas - ctx.drawImage(video, 0, 0, canvas.width, canvas.height); - - // Convert the canvas to a data URL and add it to the list of thumbnails - const thumbnailUrl = canvas.toDataURL("image/jpeg", 0.8); - thumbnails.push(thumbnailUrl); - } - - return thumbnails; -}