Skip to main content
Version: 2.x.x

Media Events - React Native

VideoSDK offers various events that can be monitored to obtain information about the media status of participants in the room.

Here are the events specifically related to the stream:

onStreamEnabled()​

  • This event is triggered whenever a participant's video, audio or screen share stream is enabled.
  • It can be subscribed to using the useParticipant hook.

onStreamDisabled()​

  • This event is triggered whenever a participant's video, audio or screen share stream is disabled.
  • It can be subscribed to using the useParticipant hook.

onMediaStatusChanged()​

  • This event is triggered whenever a participant's video or audio is disabled or enabled.
  • To show whether a participant's mic or camera is on, read micOn and webcamOn from the useParticipant hook.
  • It can be subscribed to using the useParticipant hook.

Example​

Here is an example demonstrating the usage of all the events mentioned on this page.

function onStreamEnabled(stream) {
console.log(" onStreamEnabled", stream);
}

function onStreamDisabled(stream) {
console.log(" onStreamDisabled", stream);
}

function onMediaStatusChanged(data) {
//kind: It represents the type of media
//newStatus: It represents the status of the media
const { kind, newStatus } = data;
}

const { displayName } = useParticipant(participantId, {
onStreamEnabled,
onStreamDisabled,
onMediaStatusChanged,
});

API Reference​

The API references for all the methods and events utilised in this guide are provided below.

Got a Question? Ask us on discord