chilly-soccer-432
02/12/2025, 9:42 PMgray-monkey-83525
02/12/2025, 9:42 PMLiveKitRoom
component to connect to a LiveKit room. Ensure you have a valid serverUrl
and token
for authentication.
2. Use VideoTrack Component: Utilize the VideoTrack
component to render the video stream. You need to pass the trackRef
of the video track you want to display.
3. Fetch Video Tracks: Use the useTracks
hook to get the video tracks from the room. You can filter these tracks to find the specific agent's video track.
Here's a basic example:
import { LiveKitRoom, useTracks, VideoTrack } from '@livekit/components-react';
import { Track } from 'livekit-client';
function AgentVideoStream() {
const tracks = useTracks([{ source: Track.Source.Camera }]);
const agentVideoTrack = tracks.find(track => track.participant.identity === 'agent');
return (
<LiveKitRoom serverUrl="<your-server-url>" token="<your-token>" connect={true}>
{agentVideoTrack ? <VideoTrack trackRef={agentVideoTrack} /> : <div>No video stream available</div>}
</LiveKitRoom>
);
}
Would you like more detailed guidance on any specific part of this process?
Sources:
- Rendering a single track
- LiveKitRoom Component
- VideoTrack Component 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.