diff --git a/packages/convert/app/components/VideoThumbnail.tsx b/packages/convert/app/components/VideoThumbnail.tsx index 819265099c..cad603139e 100644 --- a/packages/convert/app/components/VideoThumbnail.tsx +++ b/packages/convert/app/components/VideoThumbnail.tsx @@ -1,23 +1,19 @@ import {FastAverageColor} from 'fast-average-color'; -import {useEffect, useRef, useState} from 'react'; +import React, {useEffect, useRef, useState} from 'react'; const THUMBNAIL_HEIGHT = Math.round((350 / 16) * 9); -export const VideoThumbnail: React.FC<{ - readonly thumbnail: VideoFrame | null; -}> = ({thumbnail}) => { +const ThumbnailContent: React.FC<{readonly thumbnail: VideoFrame}> = ({ + thumbnail, +}) => { const ref = useRef(null); - const scaleRatio = thumbnail ? THUMBNAIL_HEIGHT / thumbnail.displayHeight : 0; - const width = thumbnail ? Math.round(thumbnail.displayWidth * scaleRatio) : 0; + const scaleRatio = THUMBNAIL_HEIGHT / thumbnail.displayHeight; + const width = Math.round(thumbnail.displayWidth * scaleRatio); const [color, setColor] = useState('transparent'); useEffect(() => { - if (!thumbnail) { - return; - } - createImageBitmap(thumbnail, { resizeWidth: width, resizeHeight: THUMBNAIL_HEIGHT, @@ -34,10 +30,7 @@ export const VideoThumbnail: React.FC<{ }, [scaleRatio, thumbnail, width]); return ( -
+
); }; +export const VideoThumbnail: React.FC<{ + readonly thumbnail: VideoFrame | null; +}> = ({thumbnail}) => { + return ( +
+ {thumbnail ? : null} +
+ ); +};