Skip to main content
Version: 0.0.x

Manage Participants - React Native

1. Local Participant (self)

Local participant is used to consume your video & audio streams. it contains information about local participant such as displayName, id, quality and streams Map.

You can acces localParticipant from the useMeeting Hook.

Participant object properties

Property NameTypeDescription
idstringUnique id of the participant.
displayNamestringThe name you define during the meeting initialization.
localbooleanIndicates the participant is local or not.
qualitystringIndicates the participant streams quality.
StreamsMap of StreamReturns Video & Audio Streams.

Stream Object properties

Property NameTypeDescription
idstringUnique id
codecstringVideo/Audio codec.
kindstringStream Kind.
trackstringMediaStreamTrack

2. Other Participants (Except You)

Other participants Map is used to get all the participants (except you) in the meeting at any given time.

Other participants Map contains same properties as LocalParticipant.

Local And Other Participants

import { View } from "react-native";
import {
useParticipant,
RTCView,
MediaStream,
} from "@videosdk.live/react-native-sdk";

/** localParticipant contains Participant object
as displayed above local participant section */
const { localParticipant, participants } = useMeeting();

/** Render All Participant including local participant */
{
[...participants.keys()].map((k) => (
<View>
{k.map((l) => (
<ParticipantView key={l} participantId={l} />
))}
</View>
));
}

/** Participant View Component*/

const ParticipantView = ({ participantId }) => {
/** useParticipant Hooks which accept `participantId`
as parameter then return participant properties such as displayName, webcamOn, micOn etc. */
const { displayName, webcamStream, webcamOn, micOn, isActiveSpeaker } =
useParticipant(participantId);

return (
<RTCView
streamURL={new MediaStream([webcamStream?.track]).toURL()}
style={{ flex: 1 }}
/>
);
};
  1. onParticipantJoined - Whenever any new participant join the meeting, onParticipantJoined event will trigger. For example, the meeting is running with Alice and Bob, then Eve join that meeting, after that onParticipantJoined event trigger and return the participant object.

  2. onParticipantLeft - Whenever any participant leave/exit the meeting, onParticipantLeft event will trigger.For example, the meeting is running with Alice and Bob, then Bob leave that meeting, after that onParticipantLeft event trigger and return the participant object

  3. onPresenterChanged - Whenever any participant present/screenshare their screen/window in meeting, onPresenterChanged event will trigger and return the presenter participantId.

  4. onStreamEnabled - Whenever any participant enabled mic/webcam in meeting, onStreamEnabled event will trigger and return Stream.

  5. onStreamDisabled - Whenever any participant disabled mic/webcam in meeting, onStreamDisabled event will trigger and return Stream.

import { useMeeting, useParticipant } from "@videosdk.live/react-native-sdk";

/** useMeeting hooks events */
const {
/** Methods */
} = useMeeting({
onParticipantJoined: (participant) => {},
onParticipantLeft: (participant) => {},
onPresenterChanged: (presenterId) => {},
});

/** useParticipant hooks events */
const {
/** Methods */
} = useParticipant(participantId, {
onStreamEnabled:(stream) => {};
onStreamDisabled(stream) => {};
});

Got a Question? Ask us on discord