Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat: Video thumbnail, seek slider
Richie McIlroy512a752c128c
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex c7d953210..13c614a28 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -60,8 +60,42 @@ pub async fn start_dual_recording(clean_and_create_dir(&video_chunks_dir)?;let ffmpeg_screen_args_future = construct_recording_args(&options, &screen_chunks_dir, "screen", &options.screen_index);+// let ffmpeg_video_args_future = construct_recording_args(&options, &video_chunks_dir, "video", &options.video_index);let ffmpeg_screen_args = ffmpeg_screen_args_future.await.map_err(|e| e.to_string())?;+++ let screenshot_output_path = data_dir.join("screen-capture.jpg").to_str().unwrap().to_string();+ let ffmpeg_screen_screenshot_args = match std::env::consts::OS {+ "macos" => vec![+ "-f".to_string(),+ "avfoundation".to_string(),+ "-i".to_string(),+ options.screen_index.clone(),+ "-vframes".to_string(),+ "1".to_string(),+ screenshot_output_path.clone()+ ],+ "windows" => vec![+ "-f".to_string(),+ "gdigrab".to_string(),+ "-i".to_string(),+ "desktop".to_string(),+ "-vframes".to_string(),+ "1".to_string(),+ screenshot_output_path.clone()+ ],+ "linux" => vec![+ "-f".to_string(),+ "x11grab".to_string(),+ "-i".to_string(),+ ":0.0".to_string(),+ "-vframes".to_string(),+ "1".to_string(),+ screenshot_output_path+ ],+ _ => return Err("Unsupported OS".to_string()),+ };// let ffmpeg_video_args = ffmpeg_video_args_future.await.map_err(|e| e.to_string())?;println!("Screen args: {:?}", ffmpeg_screen_args);@@ -86,6 +120,16 @@ pub async fn start_dual_recording(tokio::spawn(log_output(screen_stdout, "Screen stdout".to_string()));tokio::spawn(log_output(screen_stderr, "Screen stderr".to_string()));+ let ffmpeg_binary_path_clone = ffmpeg_binary_path_str.clone();+ let ffmpeg_screen_screenshot_args_clone = ffmpeg_screen_screenshot_args.clone();++ // Spawn the screenshot task without directly awaiting it+ tokio::spawn(async move {+ if let Err(e) = take_screenshot(ffmpeg_binary_path_clone, ffmpeg_screen_screenshot_args_clone).await {+ eprintln!("Failed to take screenshot: {}", e);+ }+ });+// let video_stdout = video_child.stdout.take().unwrap();// let video_stderr = video_child.stderr.take().unwrap();// tokio::spawn(log_output(video_stdout, "Video stdout".to_string()));@@ -147,6 +191,18 @@ pub async fn stop_all_recordings(state: State<'_, Arc<Mutex<RecordingState>>>) -// This will wait for all the current upload handles to complete.let _ = futures::future::try_join_all(upload_handles.into_iter()).await;+ let state_guard = state.lock().await;+ let data_dir_option = state_guard.data_dir.clone();+ let options_clone = state_guard.recording_options.clone();+ let shutdown_flag_clone = state_guard.shutdown_flag.clone();+ drop(state_guard);++ if let Some(data_dir) = data_dir_option {+ if let Err(e) = upload_jpeg_files(&data_dir, options_clone).await {+ eprintln!("Error uploading JPEG files: {}", e);+ }+ }+println!("All recordings and uploads stopped.");Ok(())@@ -528,4 +584,44 @@ async fn upload_remaining_chunks(} else {Err("No recording options provided".to_string())}+}++async fn take_screenshot(+ ffmpeg_binary_path_str: String,+ ffmpeg_screen_screenshot_args: Vec<String>,+) -> Result<(), String> {+ println!("Waiting for 3 seconds before taking the screenshot...");+ tokio::time::sleep(Duration::from_secs(3)).await;++ let mut screen_screenshot_child = tokio::process::Command::new(&ffmpeg_binary_path_str)+ .args(&ffmpeg_screen_screenshot_args)+ .stdout(Stdio::piped())+ .stderr(Stdio::piped())+ .spawn()+ .map_err(|e| e.to_string())?;++ let screen_screenshot_stdout = screen_screenshot_child.stdout.take().unwrap();+ let screen_screenshot_stderr = screen_screenshot_child.stderr.take().unwrap();+ tokio::spawn(log_output(screen_screenshot_stdout, "Screen screenshot stdout".to_string()));+ tokio::spawn(log_output(screen_screenshot_stderr, "Screen screenshot stderr".to_string()));++ Ok(())+}++async fn upload_jpeg_files(+ dir_path: &PathBuf,+ options: Option<RecordingOptions>,+) -> Result<(), String> {+ let dir_entries = std::fs::read_dir(dir_path).map_err(|e| format!("Failed to read dir: {}", e))?;+ for entry in dir_entries {+ let entry = entry.map_err(|e| format!("Failed to process dir entry: {}", e))?;+ let path = entry.path();+ if path.is_file() && path.extension().map_or(false, |ext| ext == "jpeg" || ext == "jpg") {+ let file_path_str = path.to_str().unwrap_or_default();+ println!("Found JPEG file for upload: {}", file_path_str);+ upload_file(options.clone(), file_path_str.to_string(), "screenshot".to_string()).await.map_err(|e| format!("Failed to upload JPEG: {}", e))?;+ }+ }++ Ok(())}\ No newline at end of filediff --git a/apps/desktop/src/components/windows/Camera.tsx b/apps/desktop/src/components/windows/Camera.tsxindex d6c0f1e82..c66a51a44 100644--- a/apps/desktop/src/components/windows/Camera.tsx+++ b/apps/desktop/src/components/windows/Camera.tsx@@ -1,5 +1,3 @@-"use client";-import { useEffect, useRef, useState } from "react";import { useMediaDevices } from "@/utils/recording/MediaDeviceContext";@@ -11,7 +9,7 @@ export const Camera = () => {useEffect(() => {let activeStream: MediaStream | null = null;- const setupCamera = async () => {+ async function setupCamera() {if (!videoRef.current || !selectedVideoDevice) {setIsLoading(false);return;@@ -34,44 +32,31 @@ export const Camera = () => {},});- // Save stream- activeStream = stream;+ // Ensure videoRef.current is still not null+ if (!videoRef.current) return;- const videoTrack = stream.getVideoTracks()[0];- const settings = videoTrack.getSettings();- const videoProperties = {- framerate: settings.frameRate ? String(settings.frameRate) : "",- resolution: `${settings.width}x${settings.height}`,- };- localStorage.setItem(- "videoDeviceProperties",- JSON.stringify(videoProperties)- );+ videoRef.current.srcObject = stream;+ videoRef.current.onplaying = () => setIsLoading(false);+ await videoRef.current.play();- const video = videoRef.current;- video.srcObject = stream;- video.onplaying = () => {- setIsLoading(false);- };- await video.play();+ // Save stream for cleanup+ activeStream = stream;} catch (err) {console.error(err);setIsLoading(false);}- };+ }setupCamera();- // Cleanup function to stop the stream and reset loading statereturn () => {if (activeStream) {activeStream.getTracks().forEach((track) => track.stop());activeStream = null;}- // Avoid loading when the component is not actually loadingsetIsLoading(false);};- }, [selectedVideoDevice, videoRef]);+ }, [selectedVideoDevice]);return (<divdiff --git a/apps/desktop/src/components/windows/inner/Recorder.tsx b/apps/desktop/src/components/windows/inner/Recorder.tsxindex 88911d1df..6e81b2fae 100644--- a/apps/desktop/src/components/windows/inner/Recorder.tsx+++ b/apps/desktop/src/components/windows/inner/Recorder.tsx@@ -19,7 +19,6 @@ import { useMediaRecorder } from "@/utils/recording/useMediaRecorder";import { getSelectedVideoProperties } from "@/utils/recording/utils";import { getLatestVideoId, saveLatestVideoId } from "@/utils/database/utils";import { openLinkInBrowser } from "@/utils/helpers";-import { uuidParse } from "@cap/utils";import toast, { Toaster } from "react-hot-toast";import { LogicalSize, WebviewWindow, appWindow } from "@tauri-apps/api/window";@@ -95,9 +94,6 @@ export const Recorder = () => {const data = await res.json();- console.log("data:");- console.log(data);-if (!data.id || !data.user_id || !data.aws_region || !data.aws_bucket) {console.error("No data received");toast.error("No data received - please try again later.");@@ -117,8 +113,6 @@ export const Recorder = () => {}) => {// Extracted from the useEffect hook; this starts the video recordingconsole.log("Starting dual recording...");- console.log("video data:");- console.log(videoData);const mediaSettings = await getSelectedVideoProperties();if (mediaSettings?.resolution && mediaSettings?.framerate) {await invoke("start_dual_recording", {@@ -143,6 +137,7 @@ export const Recorder = () => {try {const videoData = await prepareVideoData();if (videoData) {+ setIsRecording(true);const stream = await navigator.mediaDevices.getUserMedia({audio: { deviceId: selectedAudioDevice?.deviceId },video: { deviceId: selectedVideoDevice?.deviceId },@@ -218,36 +213,6 @@ export const Recorder = () => {console.log("Test...");- useEffect(() => {- const setupListener = async () => {- await listen("oauth://url", (event: any) => {- let deep_link = event.payload as string;- console.log("deep_link:");- console.log(deep_link);- });-- // Start tauri oauth plugin. When receive first request- // When it starts, will return the server port- // it will kill the server- invoke("plugin:oauth|start", {- config: {- // Optional config, but use here to more friendly callback page- response: callbackTemplate,- },- }).then((port) => {- open(- "http://localhost:3000/api/authhere" +- "response_type=token&" +- "client_id=<CLIEN_ID_FROM_FIREBASE>&" +- `redirect_uri=http%3A//localhost:${port}&` +- "scope=email%20profile%20openid&" +- "prompt=consent"- );- });- };- setupListener();- }, []);-return (<>{countdownActive && (diff --git a/apps/desktop/src/components/windows/inner/SignIn.tsx b/apps/desktop/src/components/windows/inner/SignIn.tsxindex a7ddf92f5..920d85281 100644--- a/apps/desktop/src/components/windows/inner/SignIn.tsx+++ b/apps/desktop/src/components/windows/inner/SignIn.tsx@@ -3,11 +3,9 @@import { Button, Logo } from "@cap/ui";import { useState } from "react";import { login } from "@/utils/auth";-import { getCookie } from "cookies-next";export const SignIn = () => {const [loading, setLoading] = useState(false);- const cookie = getCookie("next-auth.session-token");const handleSignIn = async () => {setLoading(true);@@ -15,22 +13,6 @@ export const SignIn = () => {login();};- const getData = async () => {- if (!cookie) {- return;- }-- const res = await fetch(- `${process.env.NEXT_PUBLIC_URL}/api/desktop/session/verify`,- {- credentials: "include",- }- );- const data = await res.json();- console.log("dataaa:");- console.log(data);- };-return (<divdata-tauri-drag-region@@ -40,25 +22,19 @@ export const SignIn = () => {<div className="mb-12"><Logo className="w-32 h-auto mx-auto" /></div>- <Button- onClick={() => {- handleSignIn();- }}- variant="default"- type="button"- disabled={loading}- >- Sign in via Cap.so- </Button>- {cookie && (- <button+ <div>+ <ButtononClick={() => {- getData();+ handleSignIn();}}+ variant="default"+ type="button"+ disabled={loading}+ className="w-full">- get data- </button>- )}+ Sign in with browser+ </Button>+ </div></div></div>);diff --git a/apps/desktop/src/utils/recording/useMediaRecorder.ts b/apps/desktop/src/utils/recording/useMediaRecorder.tsindex b7e03f125..a68736bac 100644--- a/apps/desktop/src/utils/recording/useMediaRecorder.ts+++ b/apps/desktop/src/utils/recording/useMediaRecorder.ts@@ -50,13 +50,20 @@ export const useMediaRecorder = () => {await writeTextFile(segmentListPath, newContent);};- const saveFile = async (data: Uint8Array, fileName: string) => {+ const saveFile = async (+ data: Uint8Array,+ fileName: string,+ screenshot: boolean+ ) => {try {- const dir = await getVideoChunksDir();+ const dir =+ screenshot === false ? await getVideoChunksDir() : await appDataDir();await createDir(dir, { recursive: true });const filePath = await join(dir, fileName);await writeBinaryFile(filePath, data);- await appendToSegmentListFile(fileName);+ if (screenshot === false) {+ await appendToSegmentListFile(fileName);+ }} catch (error) {console.error("Failed to save file:", error);}@@ -79,10 +86,6 @@ export const useMediaRecorder = () => {}}- ffmpegRef.current.on("log", (log) => {- console.log("FFmpeg log:", log.message);- });-while (queue.current.length > 0) {try {const chunk = queue.current.shift();@@ -153,7 +156,7 @@ export const useMediaRecorder = () => {const savedVideo = (await ffmpeg.readFile(outputFileName)) as Uint8Array;- await saveFile(savedVideo, outputFileName);+ await saveFile(savedVideo, outputFileName, false);console.log("log-5");} catch (error) {console.error("Failed to save file:", error);@@ -161,10 +164,41 @@ export const useMediaRecorder = () => {console.log("log-6");+ if (segmentCounter.current === 2) {+ const screenshotFileName = "video-capture.jpeg";++ console.log("Generating screenshot...");++ await ffmpeg.exec([+ "-i",+ outputFileName,+ "-ss",+ "0",+ "-frames:v",+ "1",+ "-q:v",+ "1",+ screenshotFileName,+ ]);++ try {+ const savedScreenshot = (await ffmpeg.readFile(+ screenshotFileName+ )) as Uint8Array;+ await saveFile(savedScreenshot, screenshotFileName, true);+ console.log("Screenshot saved.");+ } catch (error) {+ console.error("Failed to save screenshot:", error);+ }++ // Clean up by deleting the temporary screenshot file generated by FFmpeg+ await ffmpeg.deleteFile(screenshotFileName);++ console.log("Screenshot process completed.");+ }+await ffmpeg.deleteFile(inputFileName);await ffmpeg.deleteFile(outputFileName);-- console.log("log-7");} catch (error) {console.error("Failed to process chunk:", error);}diff --git a/apps/web/app/api/playlist/route.ts b/apps/web/app/api/playlist/route.tsindex 5d39480fc..55d663a7a 100644--- a/apps/web/app/api/playlist/route.ts+++ b/apps/web/app/api/playlist/route.ts@@ -19,6 +19,7 @@ export async function GET(request: NextRequest) {const userId = searchParams.get("userId") || "";const videoId = searchParams.get("videoId") || "";const videoType = searchParams.get("videoType") || "";+ const thumbnail = searchParams.get("thumbnail") || "";if (!userId || !videoId) {return new Response(@@ -84,6 +85,7 @@ export async function GET(request: NextRequest) {const screenObjectsCommand = new ListObjectsV2Command({Bucket: bucket,Prefix: screenPrefix,+ MaxKeys: thumbnail ? 1 : undefined,});const screenObjects = await s3Client.send(screenObjectsCommand);@@ -120,6 +122,7 @@ export async function GET(request: NextRequest) {const videoObjectsCommand = new ListObjectsV2Command({Bucket: bucket,Prefix: videoPrefix,+ MaxKeys: thumbnail ? 1 : undefined,});const videoObjects = await s3Client.send(videoObjectsCommand);diff --git a/apps/web/app/api/thumbnail/route.ts b/apps/web/app/api/thumbnail/route.tsnew file mode 100644index 000000000..d2a44a453--- /dev/null+++ b/apps/web/app/api/thumbnail/route.ts@@ -0,0 +1,73 @@+import { type NextRequest } from "next/server";+import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";+import { getSignedUrl } from "@aws-sdk/s3-request-presigner";++export const revalidate = 3500;++export async function GET(request: NextRequest) {+ const { searchParams } = request.nextUrl;+ const userId = searchParams.get("userId");+ const videoId = searchParams.get("videoId");++ if (!userId || !videoId) {+ return new Response(+ JSON.stringify({+ error: true,+ message: "userId or videoId not supplied",+ }),+ {+ status: 400,+ headers: { "Content-Type": "application/json" },+ }+ );+ }++ const s3Client = new S3Client({+ region: process.env.CAP_AWS_REGION || "",+ credentials: {+ accessKeyId: process.env.CAP_AWS_ACCESS_KEY || "",+ secretAccessKey: process.env.CAP_AWS_SECRET_KEY || "",+ },+ });++ const bucket = process.env.CAP_AWS_BUCKET;+ const fileKeys = [+ {+ type: "screen" as "screen" | "video",+ key: `${userId}/${videoId}/screenshot/screen-capture.jpg`,+ },+ {+ type: "video" as "screen" | "video",+ key: `${userId}/${videoId}/screenshot/video-capture.jpeg`,+ },+ ];++ // Initialize a response object+ const responseObject: { screen: string | null; video: string | null } = {+ screen: null,+ video: null,+ };++ await Promise.all(+ fileKeys.map(async ({ type, key }) => {+ try {+ const url = await getSignedUrl(+ s3Client,+ new GetObjectCommand({ Bucket: bucket, Key: key }),+ { expiresIn: 3600 }+ );+ responseObject[type] = url;+ } catch (error) {+ console.error("Error generating URL for:", key, error);++ // Set the response object to null if an error occurred+ responseObject[type] = null;+ }+ })+ );++ return new Response(JSON.stringify(responseObject), {+ status: 200,+ headers: { "Content-Type": "application/json" },+ });+}diff --git a/apps/web/app/dashboard/caps/Caps.tsx b/apps/web/app/dashboard/caps/Caps.tsxindex 6f0350bab..2660e88ea 100644--- a/apps/web/app/dashboard/caps/Caps.tsx+++ b/apps/web/app/dashboard/caps/Caps.tsx@@ -2,6 +2,7 @@import { Button } from "@cap/ui";import { videos } from "@cap/database/schema";import moment from "moment";+import { VideoThumbnail } from "@/components/VideoThumbnail";export const Caps = ({ data }: { data: (typeof videos.$inferSelect)[] }) => {return (@@ -38,10 +39,16 @@ export const Caps = ({ data }: { data: (typeof videos.$inferSelect)[] }) => {return (<divkey={index}- className="rounded-xl border border-filler overflow-hidden"+ className="rounded-xl border border-filler overflow-hidden group"><a href={`/share/${cap.id}`}>- <div className="aspect-video bg-gray-100"></div>+ <div>+ <VideoThumbnail+ userId={cap.ownerId}+ videoId={cap.id}+ alt={`${cap.name} Thumbnail`}+ />+ </div><div className="p-4"><p className="font-medium">{cap.name}</p><p className="text-sm text-gray-400">diff --git a/apps/web/app/dashboard/layout.tsx b/apps/web/app/dashboard/layout.tsxindex 3cfc06b78..26e4e278e 100644--- a/apps/web/app/dashboard/layout.tsx+++ b/apps/web/app/dashboard/layout.tsx@@ -24,9 +24,9 @@ export default async function DashboardLayout({redirect("/login");}- if (!user.name) {- redirect("/dashboard/onboarding");- }+ // if (!user.name) {+ // redirect("/onboarding");+ // }// const supabase = await createSupabaseServerClient();// const spaceData = await supabasediff --git a/apps/web/app/onboarding/page.tsx b/apps/web/app/onboarding/page.tsxnew file mode 100644index 000000000..019a807f8--- /dev/null+++ b/apps/web/app/onboarding/page.tsx@@ -0,0 +1,7 @@+export default async function OnboardingPage() {+ return (+ <div>+ <h1>Onboarding Page</h1>+ </div>+ );+}diff --git a/apps/web/app/share/[videoId]/_components/ShareVideo.tsx b/apps/web/app/share/[videoId]/_components/ShareVideo.tsxindex 98446fe8f..375a5c62f 100644--- a/apps/web/app/share/[videoId]/_components/ShareVideo.tsx+++ b/apps/web/app/share/[videoId]/_components/ShareVideo.tsx@@ -18,16 +18,14 @@ export const ShareVideo = ({ data }: { data: typeof videos.$inferSelect }) => {const [isPlaying, setIsPlaying] = useState(false);const [currentTime, setCurrentTime] = useState(0);const [isLoading, setIsLoading] = useState(true);- const [duration1, setDuration1] = useState(0);- const [duration2, setDuration2] = useState(0);const [longestDuration, setLongestDuration] = useState(0);+ const [seekTime, setSeekTime] = useState(0);+ const [seeking, setSeeking] = useState(false);useEffect(() => {const handleLoadedMetadata = () => {const loadedDuration1 = video1Ref.current?.duration || 0;const loadedDuration2 = video2Ref.current?.duration || 0;- setDuration1(loadedDuration1);- setDuration2(loadedDuration2);setLongestDuration(Math.max(loadedDuration1, loadedDuration2));if (loadedDuration1 > 0 && loadedDuration2 > 0) {@@ -75,14 +73,52 @@ export const ShareVideo = ({ data }: { data: typeof videos.$inferSelect }) => {}};- const watchedPercentage =- longestDuration > 0 ? (currentTime / longestDuration) * 100 : 0;+ const handleSeekMouseDown = (event: any) => {+ console.log("seeking2", seeking);+ // Indicate the start of seeking+ setSeeking(true);+ };++ const handleSeekMouseUp = (event: any) => {+ // Apply seek on mouse up to make sure it is precise and doesn't stick to mouse moves only+ if (!seeking) return;+ setSeeking(false); // Stop seeking+ const seekBar = event.currentTarget;+ const seekTo = calculateNewTime(event, seekBar);+ setSeekTime(seekTo); // Assume setSeekTime updates the state that determines the current time+ applyTimeToVideos(seekTo);+ };++ const handleSeekMouseMove = (event: any) => {+ console.log("seeking", seeking);+ if (!seeking) return;+ const seekBar = event.currentTarget;+ const seekTo = calculateNewTime(event, seekBar);+ // Optionally update a visual indicator or the current time state+ applyTimeToVideos(seekTo);+ };++ const calculateNewTime = (event: any, seekBar: any) => {+ const rect = seekBar.getBoundingClientRect();+ const offsetX = event.clientX - rect.left; // Get the mouse position relative to the seek bar start+ const relativePosition = offsetX / rect.width; // Calculate the relative position as a percentage+ const newTime = relativePosition * longestDuration; // Calculate the new time based on the relative position+ return newTime;+ };++ const applyTimeToVideos = (time: number) => {+ if (video1Ref.current) video1Ref.current.currentTime = time;+ if (video2Ref.current) video2Ref.current.currentTime = time;+ };const handlePlay = () => {video1Ref.current?.play();video2Ref.current?.play();};+ const watchedPercentage =+ longestDuration > 0 ? (currentTime / longestDuration) * 100 : 0;+useEffect(() => {if (!isLoading && isPlaying) {video1Ref.current?.play();@@ -116,15 +152,15 @@ export const ShareVideo = ({ data }: { data: typeof videos.$inferSelect }) => {><buttonaria-label="Play video"- className=" inline-flex items-center text-sm font-medium transition ease-in-out duration-150 text-white border border-transparent hover:opacity-50 px-2 py-2 justify-center rounded-lg"+ className=" w-full h-full flex items-center justify-center text-sm font-medium transition ease-in-out duration-150 text-white border border-transparent px-2 py-2 justify-center rounded-lg"tabIndex={0}type="button"onClick={() => handlePlayPauseClick()}>{isPlaying ? (- <Pause className="w-auto h-14" />+ <Pause className="w-auto h-14 hover:opacity-50" />) : (- <Play className="w-auto h-14" />+ <Play className="w-auto h-14 hover:opacity-50" />)}</button></div>@@ -147,15 +183,22 @@ export const ShareVideo = ({ data }: { data: typeof videos.$inferSelect }) => {<div className="absolute bottom-0 z-20 w-full text-white bg-black bg-opacity-50 opacity-0 group-hover:opacity-100 transition-all"><divid="seek"- className="absolute left-0 right-0 block h-4 mx-4 -mt-2 group"+ className="drag-seek absolute left-0 right-0 block h-4 mx-4 -mt-2 group z-20 cursor-pointer"+ onMouseDown={handleSeekMouseDown}+ onMouseMove={handleSeekMouseMove}+ onMouseUp={handleSeekMouseUp}+ onMouseLeave={() => setSeeking(false)}+ onTouchStart={handleSeekMouseDown}+ onTouchMove={handleSeekMouseMove}+ onTouchEnd={handleSeekMouseUp}>- <div className="absolute top-1.5 w-full h-1 bg-white bg-opacity-50 rounded-full cursor-pointer" />+ <div className="absolute top-1.5 w-full h-1 bg-white bg-opacity-50 rounded-full z-0" /><div- className="absolute top-1.5 h-1 bg-white rounded-full cursor-pointer transition-all duration-300"+ className="absolute top-1.5 h-1 bg-white rounded-full cursor-pointer transition-all duration-300 z-0"style={{ width: `${watchedPercentage}%` }}/><div- className="absolute top-1.5 z-10 -mt-1.5 -ml-2 w-4 h-4 bg-white rounded-full border border-white cursor-pointer focus:ring-2 focus:ring-indigo-600 focus:ring-opacity-80 focus:outline-none transition-all duration-300"+ className="drag-button absolute top-1.5 z-10 -mt-1.5 -ml-2 w-4 h-4 bg-white rounded-full border border-white cursor-pointer focus:ring-2 focus:ring-indigo-600 focus:ring-opacity-80 focus:outline-none transition-all duration-300"tabIndex={0}style={{ left: `${watchedPercentage}%` }}/>diff --git a/apps/web/components/VideoThumbnail.tsx b/apps/web/components/VideoThumbnail.tsxnew file mode 100644index 000000000..ab8f1e6ad--- /dev/null+++ b/apps/web/components/VideoThumbnail.tsx@@ -0,0 +1,72 @@+import Image from "next/image";+import { useEffect, useState } from "react";++// Define your props interface+interface VideoThumbnailProps {+ userId: string;+ videoId: string;+ alt: string;+}++export const VideoThumbnail = ({+ userId,+ videoId,+ alt,+}: VideoThumbnailProps) => {+ const [imageUrls, setImageUrls] = useState({ screen: "", video: "" });+ const [loading, setLoading] = useState(true);++ // Fetch the pre-signed URLs on component mount+ useEffect(() => {+ const fetchPreSignedUrls = async () => {+ try {+ const response = await fetch(+ `/api/thumbnail?userId=${userId}&videoId=${videoId}`+ );+ if (response.ok) {+ const data = await response.json();+ setImageUrls({ screen: data.screen, video: data.video });+ } else {+ console.error("Failed to fetch pre-signed URLs");+ }+ } catch (error) {+ console.error("Error fetching pre-signed URLs:", error);+ }+ setLoading(false);+ };++ fetchPreSignedUrls();+ }, [userId, videoId]);++ return (+ <div+ className={`aspect-video relative overflow-hidden rounded-lg ${+ loading ? "bg-gray-200" : "bg-black"+ }`}+ >+ {imageUrls.video && (+ <div className="absolute bottom-2 right-2 w-[50px] h-[50px] z-10 rounded-full overflow-hidden">+ <Image+ src={imageUrls.video}+ alt="Video Thumbnail"+ layout="fill"+ objectFit="cover"+ className="w-full h-full"+ onLoadingComplete={() => setLoading(false)}+ />+ </div>+ )}+ {imageUrls.screen && (+ <Image+ src={imageUrls.screen}+ alt={alt}+ layout="fill"+ objectFit="cover"+ className="group-hover:scale-[1.02] transition-all w-full h-full"+ onLoadingComplete={() => setLoading(false)}+ />+ )}+ <div className="bg-black opacity-0 z-10 absolute top-0 left-0 w-full h-full group-hover:opacity-50 transition-all"></div>+ </div>+ );+};diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjsindex af6ed9cb2..30b9acf52 100644--- a/apps/web/next.config.mjs+++ b/apps/web/next.config.mjs@@ -30,6 +30,16 @@ const nextConfig = {"@react-email/tailwind",],},+ images: {+ remotePatterns: [+ {+ protocol: "https",+ hostname: "*.amazonaws.com",+ port: "",+ pathname: "**",+ },+ ],+ },async headers() {return [{