import { useEffect, useRef, useState } from 'react'; import type { PublicConfig, TrackKind, Video } from '../../shared/types.ts'; import { navigate } from '../App.tsx'; import { api } from '../api.ts'; import { Icon } from '../components/Icon.tsx'; import { MicMeter } from '../components/MicMeter.tsx'; import { channelName, type RecMessage, type RecPhase, type RecState } from '../lib/channel.ts'; import { fmtDuration, loadPref, savePref } from '../lib/format.ts'; import { RecordingSession } from '../lib/recorder.ts'; interface Prefs { useCamera: boolean; cameraId: string; cameraHeight: 720 | 1080; useMic: boolean; micId: string; audioProcessing: boolean; useScreen: boolean; countdown: number; } const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); function stopStream(s: MediaStream | null) { s?.getTracks().forEach((t) => t.stop()); } function VideoPreview({ stream, label }: { stream: MediaStream | null; label: string }) { const ref = useRef(null); useEffect(() => { if (ref.current) ref.current.srcObject = stream; }, [stream]); return (
{stream ?
); } export function Recorder({ videoId }: { videoId: string }) { const [video, setVideo] = useState