VideoTrack
function VideoTrack(__namedParameters): Element;Defined in: packages/react/src/components/track/VideoTrack.tsx:48
The VideoTrack component is responsible for rendering participant video tracks like camera and screen_share. This component must have access to the participant's context, or alternatively pass it a Participant as a property.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | VideoTrackProps |
Returns
Element
Example
// Basic — render a specific participant video track.
<VideoTrack trackRef={trackRef} />
// Advanced — render subscribed camera tracks with click handling.
function CameraGrid() {
return <VoiceRoom agent={agent}><CameraGridContent /></VoiceRoom>;
}
function CameraGridContent() {
const tracks = useTracks([Track.Source.Camera], { onlySubscribed: true });
return tracks.map((trackRef, index) => (
<VideoTrack key={index} trackRef={trackRef} onTrackClick={(event) => focusParticipant(event)} />
));
}