useParticipant Hook Event Callbacks - React Native
onStreamEnabled()
onStreamEnabled()is a callback which gets triggered whenever a participant's video, audio or screen share stream is enabled.- It receives the
RTCStreamobject. Checkstream.kindto tell the streams apart:audio,video,shareorshareAudio.
Example
function onStreamEnabled(stream) {
console.log("onStreamEnabled", stream.kind);
}
const { displayName } = useParticipant(participantId, {
onStreamEnabled,
});
onStreamDisabled()
onStreamDisabled()is a callback which gets triggered whenever a participant's video, audio or screen share stream is disabled.- It receives the
RTCStreamobject that was disabled.
Example
function onStreamDisabled(stream) {
console.log("onStreamDisabled", stream.kind);
}
const { displayName } = useParticipant(participantId, {
onStreamDisabled,
});
onMediaStatusChanged()
onMediaStatusChanged()is a callback which gets triggered whenever a participant's video or audio is disabled or enabled.- It receives
{ kind, peerId, newStatus }.kindis the media that changed,audioorvideo,peerIdis the participant's id, andnewStatusistruewhen it was turned on. - To show whether the participant's mic or camera is on, read
micOnandwebcamOn.
Example
function onMediaStatusChanged(data) {
const { kind, newStatus } = data;
console.log("onMediaStatusChanged", kind, newStatus);
}
const { displayName } = useParticipant(participantId, {
onMediaStatusChanged,
});
onStreamPaused()
onStreamPaused()is a callback which gets triggered when one of the participant's streams is paused on this device, for example when you call the stream'spause()or when the server pauses it.- The participant still sends the stream. Only its delivery to this device stops.
- It receives
{ kind, reason }.kindis the kind of stream that was paused, andreasonis why, as reported by the server.
Example
function onStreamPaused(data) {
const { kind, reason } = data;
console.log("onStreamPaused", kind, reason);
}
const { displayName } = useParticipant(participantId, {
onStreamPaused,
});
onStreamResumed()
onStreamResumed()is a callback which gets triggered when a paused stream of the participant is delivered to this device again.- It receives
{ kind, reason }, likeonStreamPaused().
Example
function onStreamResumed(data) {
const { kind, reason } = data;
console.log("onStreamResumed", kind, reason);
}
const { displayName } = useParticipant(participantId, {
onStreamResumed,
});
onE2EEStateChanged()
onE2EEStateChanged()is a callback which reports the end-to-end encryption state of the participant's media.- It receives
{ state, kind }:state: one ofEncryptionSuccess,EncryptionFailed,DecryptionSuccess,DecryptionFailed,InternalErrororUnknownState.kind:audio,video,shareorshareAudio.
EncryptionSuccessarrives when your media starts being encrypted, andDecryptionSuccesswhen a remote participant's media starts being decrypted.- Decryption failures are not reported:
DecryptionFaileddoes not arrive. A wrong or removed key shows only as the stream going dark.
Example
function onE2EEStateChanged(stateInfo) {
console.log("State Changed to", stateInfo.state, "for kind", stateInfo.kind);
}
const { displayName } = useParticipant(participantId, {
onE2EEStateChanged,
});
Got a Question? Ask us on discord

