fix(webrtc): correctly subscribe to remote camera tracks
This commit is contained in:
@@ -30,16 +30,20 @@ function VideoTile({ participant, isLocal, room }: { participant: Participant; i
|
|||||||
|
|
||||||
attachTrack();
|
attachTrack();
|
||||||
|
|
||||||
// Listen for track publications changing on this participant via room events
|
// Listen for track subscriptions
|
||||||
const handlePublished = (pub: TrackPublication) => {
|
const handleSubscribed = (track: Track, publication: TrackPublication, trackParticipant: Participant) => {
|
||||||
pub.track?.attach(el);
|
if (trackParticipant.identity === participant.identity && publication.source === Track.Source.Camera) {
|
||||||
|
track.attach(el);
|
||||||
|
el.muted = isLocal;
|
||||||
el.play().catch(() => {});
|
el.play().catch(() => {});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
room.on('trackPublished' as any, handlePublished);
|
|
||||||
|
room.on('trackSubscribed' as any, handleSubscribed);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
detachTrack();
|
detachTrack();
|
||||||
room.off('trackPublished' as any, handlePublished);
|
room.off('trackSubscribed' as any, handleSubscribed);
|
||||||
};
|
};
|
||||||
}, [participant, isLocal, room]);
|
}, [participant, isLocal, room]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user