Live video on the AT Protocol

Merge pull request #524 from streamplace/natb/fix-frame-capture

golive: get frame capture working for thumb submission

authored by natalie and committed by GitHub dbeee573 a28b5458

+13 -4
+13 -4
js/app/hooks/useCaptureVideoFrame.ts
··· 1 - import { useVideoElement } from "contexts/VideoElementContext"; 1 + import { usePlayerStore } from "@streamplace/components"; 2 2 import { useCallback } from "react"; 3 - import { isWeb } from "tamagui"; 4 3 import { captureVideoFrame } from "utils/videoCapture"; 5 4 6 5 /** ··· 12 11 * @returns A function that captures a frame from the video element 13 12 */ 14 13 export function useCaptureVideoFrame() { 15 - const videoElement = useVideoElement(); 14 + const ref = usePlayerStore((state) => state.videoRef); 15 + 16 + // if ref is a function return null 17 + if (typeof ref === "function") { 18 + console.warn( 19 + "Video ref is a function (native player), cannot capture frame", 20 + ); 21 + return null; 22 + } 23 + 24 + const videoElement = ref?.current; 16 25 17 26 const captureFrame = useCallback( 18 27 async (maxWidth = 1280, quality = 0.85): Promise<Blob | null> => { 19 - if (!isWeb || !videoElement) { 28 + if (!videoElement) { 20 29 console.warn("Video element not available or not on web platform"); 21 30 return null; 22 31 }