in app/components/LocalVideo.tsx [14:48]
export default function LocalVideo() {
const [enabled, setEnabled] = useState(false);
const chime: ChimeSdkWrapper | null = useContext(getChimeContext());
const videoElement = useRef(null);
useEffect(() => {
chime?.audioVideo?.addObserver({
videoTileDidUpdate: (tileState: VideoTileState): void => {
if (
!tileState.boundAttendeeId ||
!tileState.localTile ||
!tileState.tileId ||
!videoElement.current
) {
return;
}
chime?.audioVideo?.bindVideoElement(
tileState.tileId,
(videoElement.current as unknown) as HTMLVideoElement
);
setEnabled(tileState.active);
}
});
}, []);
return (
<div
className={cx('localVideo', {
enabled
})}
>
<video muted ref={videoElement} className={cx('video')} />
</div>
);
}