Skip to main content
Version: 2.x.x

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 RTCStream object. Check stream.kind to tell the streams apart: audio, video, share or shareAudio.

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 RTCStream object 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 }. kind is the media that changed, audio or video, peerId is the participant's id, and newStatus is true when it was turned on.
  • To show whether the participant's mic or camera is on, read micOn and webcamOn.

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's pause() or when the server pauses it.
  • The participant still sends the stream. Only its delivery to this device stops.
  • It receives { kind, reason }. kind is the kind of stream that was paused, and reason is 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 }, like onStreamPaused().

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 of EncryptionSuccess, EncryptionFailed, DecryptionSuccess, DecryptionFailed, InternalError or UnknownState.
    • kind: audio, video, share or shareAudio.
  • EncryptionSuccess arrives when your media starts being encrypted, and DecryptionSuccess when a remote participant's media starts being decrypted.
  • Decryption failures are not reported: DecryptionFailed does 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