React Api Reference
    Preparing search index...

    Class useParticipant

    useParticipant provides reactive access to a participant’s state, streams, controls, statistics, and related events within a meeting.

    Index

    Constructors

    Properties

    displayName: string

    This represents display name of the participant.

    isActiveSpeaker: boolean

    This represents whether the participant is the active speaker.

    isLocal: boolean

    This represents whether the participant is the local participant.

    isMainParticipant: boolean

    This represents whether the participant is the main participant.

    micOn: boolean

    This represents whether the participant’s microphone is enabled.

    micStream: Stream

    This represents the microphone audio Stream of the participant.

    mode: "SEND_AND_RECV" | "SIGNALLING_ONLY" | "RECV_ONLY"

    This represents the current mode of the participant.

    participant: Participant

    This represents the underlying Participant instance.

    pinState: any

    This represents the current pin state of the participant.

    screenShareAudioOn: boolean

    This represents whether the participant’s screen-share audio is enabled.

    screenShareAudioStream: Stream

    This represents the screen-share audio Stream of the participant.

    screenShareOn: boolean

    This represents whether the participant is currently sharing their screen.

    screenShareStream: Stream

    This represents the screen-share video Stream of the participant.

    webcamOn: boolean

    This represents whether the participant’s webcam is enabled.

    webcamStream: Stream

    This represents the webcam video Stream of the participant.

    Methods

      • This method can be used to capture an image from the participant’s current video stream.
      • The captured image is returned as a Base64-encoded string.

      Parameters

      • options: { height?: number; width?: number }
        • Optionalheight?: number

          Desired height of the captured image.

        • Optionalwidth?: number

          Desired width of the captured image.

      Returns Promise<string>

      A Base64-encoded string representing the captured image, or null if the image could not be captured.

      const { captureImage } = useParticipant(participantId);

      const image = await captureImage({
      width: 640,
      height: 360,
      });
      • This method can be used to disable the remote participant’s microphone.

      Events associated with disableMic():

      Returns void

      const { disableMic } = useParticipant(participantId);

      disableMic();
      • This method can be used to disable the remote participant’s webcam.

      Events associated with disableWebcam():

      Returns void

      const { disableWebcam } = useParticipant(participantId);

      disableWebcam();
      • This method can be used to enable the remote participant’s microphone.

      Events associated with enableMic():

      • The participant first receives a onMicRequested event. Once the request is accepted, the microphone is enabled.
      • All participants receive a onStreamEnabled even containing the corresponding Stream object.

      Returns void

      const { enableMic } = useParticipant(participantId);

      enableMic();
      • This method can be used to enable the remote participant’s webcam.

      Events associated with enableWebcam():

      • The participant first receives a onWebcamRequestedevent. Once the request is accepted, the webcam is enabled.

      • All participants receive a onStreamEnabled event containing the corresponding Stream object.

      Returns void

      const { enableWebcam } = useParticipant(participantId);

      enableWebcam();
      • This method can be used to get detailed statistics about the participant’s audio stream.
      • These metrics provide insights into stream quality, network conditions, and transmission performance at the time the method is called.

      Returns Promise<
          {
              bitrate: number;
              codec: string;
              jitter: number;
              network: string;
              packetsLost: number;
              rtt: number;
              totalPackets: number;
          }[],
      >

      An array of objects containing the following metrics:

      • jitter – Represents variation in packet arrival time (stream instability).
      • bitrate – The bitrate at which the audio stream is being transmitted.
      • totalPackets – Total number of packets transmitted for the stream.
      • packetsLost – Total number of packets lost during transmission.
      • rtt – Round-trip time (in milliseconds) between the client and server.
      • codec – Codec used for encoding the audio stream.
      • network – Network type used for transmitting the stream.

      Info

      If the rtt value exceeds 300ms, consider switching to a region closer to the user for improved performance. Learn more visit here.

      const { getAudioStats } = useParticipant(participantId);

      const audioStats = await getAudioStats();
      • This method can be used to get detailed statistics about the participant’s screen share audio stream.
      • These metrics provide insights into stream quality, network conditions, and transmission performance at the time the method is called.

      Returns Promise<
          {
              bitrate: number;
              codec: string;
              jitter: number;
              network: string;
              packetsLost: number;
              rtt: number;
              totalPackets: number;
          }[],
      >

      An array of objects containing the following metrics:

      • jitter – Represents variation in packet arrival time (stream instability).
      • bitrate – The bitrate at which the audio stream is being transmitted.
      • totalPackets – Total number of packets transmitted for the stream.
      • packetsLost – Total number of packets lost during transmission.
      • rtt – Round-trip time (in milliseconds) between the client and server.
      • codec – Codec used for encoding the audio stream.
      • network – Network type used for transmitting the stream.

      Info

      If the rtt value exceeds 300ms, consider switching to a region closer to the user for improved performance. Learn more visit here.

      const { getShareAudioStats } = useParticipant(participantId);

      const shareAudioStats = await getShareAudioStats();
      • This method can be used to get detailed statistics about the participant’s screen share video stream.
      • These metrics provide insights into stream quality, network conditions, and transmission performance at the time the method is called.

      Returns Promise<
          {
              bitrate: number;
              codec: string;
              currentSpatialLayer: number;
              currentTemporalLayer: number;
              jitter: number;
              limitation: any;
              network: string;
              packetsLost: number;
              preferredSpatialLayer: number;
              preferredTemporalLayer: number;
              rtt: number;
              size: any;
              totalPackets: number;
          }[],
      >

      An array of objects containing the following metrics:

      • jitter – Represents variation in packet arrival time (stream instability).
      • bitrate – The bitrate at which the video stream is being transmitted.
      • totalPackets – Total number of packets transmitted for the stream.
      • packetsLost – Total number of packets lost during transmission.
      • rtt – Round-trip time (in milliseconds) between the client and server.
      • codec – Codec used for encoding the video stream.
      • network – Network type used for transmitting the stream.
      • limitation – Indicates any limitations affecting stream quality.
      • size – Resolution or size information related to the stream.

      Info

      If the rtt value exceeds 300ms, consider switching to a region closer to the user for improved performance. Learn more visit here.

      const { getShareStats } = useParticipant(participantId);

      const shareStats = await getShareStats();
      • This method can be used to get detailed statistics about the participant’s video stream.
      • These metrics provide insights into stream quality, network conditions, and transmission performance at the time the method is called.

      Returns Promise<
          {
              bitrate: number;
              codec: string;
              currentSpatialLayer: number;
              currentTemporalLayer: number;
              jitter: number;
              limitation: any;
              network: string;
              packetsLost: number;
              preferredSpatialLayer: number;
              preferredTemporalLayer: number;
              rtt: number;
              size: any;
              totalPackets: number;
          }[],
      >

      An array of objects containing the following metrics:

      • jitter – Represents variation in packet arrival time (stream instability).
      • bitrate – The bitrate at which the video stream is being transmitted.
      • totalPackets – Total number of packets transmitted for the stream.
      • packetsLost – Total number of packets lost during transmission.
      • rtt – Round-trip time (in milliseconds) between the client and server.
      • codec – Codec used for encoding the video stream.
      • network – Network type used for transmitting the stream.
      • limitation – Indicates any limitations affecting stream quality.
      • size – Resolution or size information related to the stream.

      Info

      If the rtt value exceeds 300ms, consider switching to a region closer to the user for improved performance. Learn more visit here.

      const { getVideoStats } = useParticipant(participantId);

      const videoStats = await getVideoStats();
      • This method can be used to pin the participant’s camera, screen share, or both.

      • Every participant receives a onPinStateChanged event when the pin state is updated.

      Parameters

      • type: "SHARE_AND_CAM" | "CAM" | "SHARE"

        Specifies which stream to pin.

        Allowed values:

        • "SHARE_AND_CAM" – Pins both screen share and camera streams.
        • "CAM" – Pins only the camera stream.
        • "SHARE" – Pins only the screen-share stream.
        SHARE_AND_CAM
        

      Returns void

      const { pin } = useParticipant(participantId);

      pin("CAM");
      • This method can be used to removes the remote participant from the meeting.

      Returns void

      const { remove } = useParticipant(participantId);

      remove();
      • This method can be used to set the incoming video quality of the remote participant.

      Parameters

      • quality: "low" | "med" | "high"

      Returns void

      const { setQuality } = useParticipant(participantId);

      setQuality("low");
      • This method can be used to set the quality of the incoming screen-share video of the remote participant.

      Parameters

      • quality: "low" | "med" | "high"

      Returns void

      const { setScreenShareQuality } = useParticipant(participantId);

      setScreenShareQuality("low");
      • This method can be used to adjust the video quality of the remote participant based on the specified viewport dimensions.

      Parameters

      • width: number

        The width of the viewport used to determine the video quality.

      • height: number

        The height of the viewport used to determine the video quality.

      Returns void

      const { setViewPort } = useParticipant(participantId);

      setViewPort(480, 360);
      • This method can be used to unpin the participant’s camera, screen share, or both.

      • Every participant receives a onPinStateChanged event when the pin state is updated.

      Parameters

      • type: "SHARE_AND_CAM" | "CAM" | "SHARE"

        Specifies which stream to unpin.

        Allowed values:

        • "SHARE_AND_CAM" – Unpins both screen share and camera streams.
        • "CAM" – Unpins only the camera stream.
        • "SHARE" – Unpins only the screen-share stream.
        "SHARE_AND_CAM"
        

      Returns void

      const { unpin } = useParticipant(participantId);

      unpin("CAM");

    Events

    • Triggered when the media status of a participant changes (for example, when audio or video is enabled or disabled).

      Parameters

      • data: { kind: "audio" | "video" | "share" | "shareAudio"; newStatus: boolean }
        • kind: "audio" | "video" | "share" | "shareAudio"

          Type of stream whose status changed.

        • newStatus: boolean

          The updated status of the stream.

      Returns void

      function onMediaStatusChanged(data) {
      const { kind, newStatus} = data;
      }

      const {
      displayName
      ...
      } = useParticipant(participantId,{
      onMediaStatusChanged,
      ...
      });
    • Triggered when a participant’s audio, video, or screen-share stream is disabled.

      Parameters

      • stream: Stream

        The Stream that was disabled.

      Returns void

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

      const {
      displayName
      ...
      } = useParticipant(participantId,{
      onStreamDisabled,
      ...
      });
    • Triggered when a participant’s audio, video, or screen-share stream is enabled.

      Parameters

      • stream: Stream

        The Stream that was enabled.

      Returns void

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

      const {
      displayName
      ...
      } = useParticipant(participantId,{
      onStreamEnabled,
      ...
      });
      • Triggered when a participant’s video, audio, or screen-share stream is paused.

      • This event is triggered only when the Subscription Manager is enabled by calling the enableAdaptiveSubscription() method.

      Parameters

      • data: { kind: "video"; reason: string }
        • kind: "video"

          Type of stream that was paused.

        • reason: string

          Reason why the stream was paused.

          Possible values:

          • "muted" – Stream was paused because it was muted.
          • "leastDominance" – Stream was paused due to bandwidth or dominance rules.

      Returns void

      function onStreamPaused({ kind, reason }) {
      console.log(kind, reason);
      }

      const {
      displayName
      ...
      } = useParticipant(participantId,{
      onStreamPaused,
      ...
      });
      • Triggered when a participant’s video, audio, or screen-share stream is resumed.

      • This event is triggered only when the Subscription Manager is enabled by calling the enableAdaptiveSubscription() method.

      Parameters

      • data: { kind: "video"; reason: string }
        • kind: "video"

          Type of stream that was resumed.

        • reason: string

          Reason why the stream was resumed.

          Possible values:

          • "adaptiveSubscriptionsDisabled" – Stream resumed after adaptive subscriptions were disabled.
          • "networkStable" – Stream resumed due to stable network conditions.

      Returns void

      function onStreamResumed({ kind, reason }) {
      console.log(kind, reason);
      }

      const {
      displayName
      ...
      } = useParticipant(participantId,{
      onStreamResumed,
      ...
      });
      • Triggered when the video quality of a participant changes.

      • The currentQuality and prevQuality values can be HIGH, MEDIUM, or LOW.

      Parameters

      • data: { currentQuality: "low" | "med" | "high"; prevQuality: "low" | "med" | "high" }
        • currentQuality: "low" | "med" | "high"

          The updated video quality level.

        • prevQuality: "low" | "med" | "high"

          The previous video quality level.

      Returns void

      function onVideoQualityChanged(data) {
      const { currentQuality, prevQuality } = data;
      }

      const {
      displayName
      ...
      } = useParticipant(participantId,{
      onVideoQualityChanged,
      ...
      });