diff --git a/src/components/playground/Playground.tsx b/src/components/playground/Playground.tsx index b015b3a..579a0a6 100644 --- a/src/components/playground/Playground.tsx +++ b/src/components/playground/Playground.tsx @@ -54,7 +54,7 @@ export default function Playground({ themeColors, onConnect, }: PlaygroundProps) { - const {config, setUserSettings} = useConfig(); + const { config, setUserSettings } = useConfig(); const { name } = useRoomInfo(); const [agentState, setAgentState] = useState("offline"); const [messages, setMessages] = useState([]); @@ -182,51 +182,88 @@ export default function Playground({ const videoTileContent = useMemo(() => { const videoFitClassName = `object-${config.video_fit || "cover"}`; + + const disconnectedContent = ( +
+ No video track. Connect to get started. +
+ ); + + const loadingContent = ( +
+ + Waiting for video track +
+ ); + + const videoContent = ( + + ); + + let content = null; + if (roomState === ConnectionState.Disconnected) { + content = disconnectedContent; + } else if (agentVideoTrack) { + content = videoContent; + } else { + content = loadingContent; + } + return (
- {agentVideoTrack ? ( - - ) : ( -
- - Waiting for video track -
- )} + {content}
); - }, [agentVideoTrack, config]); + }, [agentVideoTrack, config, roomState]); const audioTileContent = useMemo(() => { - return ( + const disconnectedContent = ( +
+ No audio track. Connect to get started. +
+ ); + + const waitingContent = ( +
+ + Waiting for audio track +
+ ); + + const visualizerContent = (
- {agentAudioTrack ? ( - - ) : ( -
- - Waiting for audio track -
- )} +
); + + if (roomState === ConnectionState.Disconnected) { + return disconnectedContent; + } + + if (!agentAudioTrack) { + return waitingContent; + } + + return visualizerContent; }, [ agentAudioTrack, agentState, config.settings.theme_color, subscribedVolumes, + roomState, ]); const chatTileContent = useMemo(() => {