From 83c05731ed5e6c05f1bef26c85cf35024d9e3e53 Mon Sep 17 00:00:00 2001 From: hobokenchicken Date: Mon, 6 Jul 2026 12:40:26 +0000 Subject: [PATCH] fix(webrtc): correctly subscribe to remote camera tracks --- web/src/components/VideoGrid.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/web/src/components/VideoGrid.tsx b/web/src/components/VideoGrid.tsx index ac038ee..2304a18 100644 --- a/web/src/components/VideoGrid.tsx +++ b/web/src/components/VideoGrid.tsx @@ -30,16 +30,20 @@ function VideoTile({ participant, isLocal, room }: { participant: Participant; i attachTrack(); - // Listen for track publications changing on this participant via room events - const handlePublished = (pub: TrackPublication) => { - pub.track?.attach(el); - el.play().catch(() => {}); + // Listen for track subscriptions + const handleSubscribed = (track: Track, publication: TrackPublication, trackParticipant: Participant) => { + if (trackParticipant.identity === participant.identity && publication.source === Track.Source.Camera) { + track.attach(el); + el.muted = isLocal; + el.play().catch(() => {}); + } }; - room.on('trackPublished' as any, handlePublished); + + room.on('trackSubscribed' as any, handleSubscribed); return () => { detachTrack(); - room.off('trackPublished' as any, handlePublished); + room.off('trackSubscribed' as any, handleSubscribed); }; }, [participant, isLocal, room]);