import type { CallParticipant, CallSelf } from 'callskit'; import { useCall } from 'callskit/react'; import clsx from 'clsx'; import { HTMLMotionProps, motion } from 'motion/react'; import { useEffect, useRef } from 'react'; export function ScreenshareTile({ participant, className, ...props }: HTMLMotionProps<'div'> & { participant: CallParticipant | CallSelf; }) { const call = useCall(); const videoRef = useRef(null); const isSelf = call.self.id === participant.id; useEffect(() => { if ( participant.screenshareEnabled && participant.screenshareTracks?.video ) { const stream = new MediaStream([participant.screenshareTracks.video]); videoRef.current!.srcObject = stream; } else { videoRef.current!.srcObject = null; } }, [participant.screenshareEnabled, participant.screenshareTracks?.video]); const id = `screenshare-${participant.id}`; return ( ); }