import React, { useCallback } from "react"; import { useStreamCrafterContext } from "../context/StreamCrafterContext"; import { useStudioTranslate } from "../context/StudioI18nContext"; import { StudioSettings } from "./StudioSettings"; const CameraIcon = ({ size = 18 }: { size?: number }) => ( ); const MonitorIcon = ({ size = 18 }: { size?: number }) => ( ); export interface StudioActionBarProps { /** Whether a WHIP endpoint is configured (required to go live) */ whipUrl?: string; /** Show the settings button */ showSettingsButton?: boolean; /** Custom children to render instead of default buttons */ children?: React.ReactNode; } export const StudioActionBar: React.FC = ({ whipUrl, showSettingsButton = true, children, }) => { const ctx = useStreamCrafterContext(); const t = useStudioTranslate(); const canAddSource = ctx.state !== "destroyed" && ctx.state !== "error"; const hasCamera = ctx.sources.some((s) => s.type === "camera"); const canStream = ctx.isCapturing && !ctx.isStreaming && whipUrl !== undefined; const handleStartCamera = useCallback(async () => { try { await ctx.startCamera(); } catch (err) { console.error("Failed to start camera:", err); } }, [ctx]); const handleStartScreenShare = useCallback(async () => { try { await ctx.startScreenShare({ audio: true }); } catch (err) { console.error("Failed to start screen share:", err); } }, [ctx]); const handleGoLive = useCallback(async () => { try { await ctx.startStreaming(); } catch (err) { console.error("Failed to start streaming:", err); } }, [ctx]); const handleStop = useCallback(async () => { await ctx.stopStreaming(); }, [ctx]); if (children) { return
{children}
; } return (
{showSettingsButton && } {!ctx.isStreaming ? ( ) : ( )}
); };