diff --git a/.env.example b/.env.example index f680711..26db09a 100644 --- a/.env.example +++ b/.env.example @@ -11,6 +11,7 @@ title: 'LiveKit Agent Playground' description: 'LiveKit Agent Playground allows you to test your LiveKit Agent integration by connecting to your LiveKit Cloud or self-hosted instance.' github_link: 'https://github.com/livekit-examples/agent-playground' theme_color: 'cyan' +video_fit: 'cover' # 'contain' or 'cover' outputs: audio: true # Enable or disable audio output video: true # Enable or disable video output diff --git a/src/components/playground/Playground.tsx b/src/components/playground/Playground.tsx index e3ed0f2..e6b9401 100644 --- a/src/components/playground/Playground.tsx +++ b/src/components/playground/Playground.tsx @@ -57,6 +57,7 @@ export interface PlaygroundProps { showQR?: boolean; onConnect: (connect: boolean, opts?: { token: string; url: string }) => void; metadata?: PlaygroundMeta[]; + videoFit?: "contain" | "cover"; } const headerHeight = 56; @@ -72,6 +73,7 @@ export default function Playground({ defaultColor, onConnect, metadata, + videoFit, }: PlaygroundProps) { const [agentState, setAgentState] = useState("offline"); const [themeColor, setThemeColor] = useState(defaultColor); @@ -201,12 +203,13 @@ export default function Playground({ useDataChannel(onDataReceived); const videoTileContent = useMemo(() => { + const videoFitClassName = `object-${videoFit}`; return (
{agentVideoTrack ? ( ) : (
@@ -216,7 +219,7 @@ export default function Playground({ )}
); - }, [agentVideoTrack]); + }, [agentVideoTrack, videoFit]); const audioTileContent = useMemo(() => { return ( diff --git a/src/hooks/useAppConfig.tsx b/src/hooks/useAppConfig.tsx index 23ba618..831ed0e 100644 --- a/src/hooks/useAppConfig.tsx +++ b/src/hooks/useAppConfig.tsx @@ -7,6 +7,7 @@ export type AppConfig = { description: string; github_link?: string; theme_color?: string; + video_fit?: "cover" | "contain"; outputs: { audio: boolean; video: boolean; @@ -24,6 +25,7 @@ const defaultConfig: AppConfig = { title: "Agents Playground", description: "A playground for testing LiveKit Agents", theme_color: "cyan", + video_fit: "cover", outputs: { audio: true, video: true, diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 612d51d..2846ccf 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -159,6 +159,7 @@ export default function Home() { defaultColor={appConfig?.theme_color ?? "cyan"} onConnect={handleConnect} metadata={metadata} + videoFit={appConfig?.video_fit ?? "cover"} /> diff --git a/tailwind.config.js b/tailwind.config.js index 8b51953..cf8495c 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -37,6 +37,8 @@ const safelist = [ 'bg-black', 'bg-white', 'transparent', + 'object-cover', + 'object-contain', ...shadowNames, ...textShadowNames, ...shades.flatMap(shade => [