React Native Api Reference - v2.0.1
    Preparing search index...

    Class useRoom

    useRoom provides reactive access to the room instance, participants, media state, events, and controls to manage the full room lifecycle.

    Index
    activeSpeakerId: string

    This indicates the participant ID of the user who is currently speaking. If no participant is actively speaking, the value is null.

    baseUrl: string
    • The signalling base URL the room is connected through.

    • null on React Native, where the native SDKs own the transport.

    hlsState:
        | "HLS_STARTING"
        | "HLS_STARTED"
        | "HLS_PLAYABLE"
        | "HLS_STOPPING"
        | "HLS_STOPPED"

    This represents the current state of the HLS stream.

    hlsUrls: { livestreamUrl: string; playbackHlsUrl: string }

    This represents the URLs associated with the ongoing HLS stream.

    • playbackHlsUrl – URL used for playback.
    • livestreamUrl – URL used for live streaming.
    isCamEnabled: boolean

    This represents whether the local participant’s webcam is enabled.

    isHls: boolean
    • true while an HLS stream is running for the room.

    • The coarse form of hlsState; use that when you need HLS_PLAYABLE, the point at which hlsUrls can be played.

    isLiveStreaming: boolean
    • true while a livestream is running for the room.

    • The coarse form of liveStreamState; use that when you need the starting and stopping phases.

    isMicEnabled: boolean

    This represents whether the local participant’s microphone is enabled.

    isRecording: boolean

    This represents whether the room is currently being recorded.

    isRoomJoined: boolean
    • true once this participant has joined the room and the SDK is ready for room actions.

    • Gate anything that must not run before join on this rather than on roomId being set.

    isScreenSharing: boolean

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

    liveStreamState:
        | "LIVESTREAM_STARTING"
        | "LIVESTREAM_STARTED"
        | "LIVESTREAM_STOPPING"
        | "LIVESTREAM_STOPPED"

    This represents the current state of the livestream.

    localParticipant: Participant

    This represents the local Participant (you) who joined the room.

    messages: {
        data: Uint8Array<ArrayBufferLike>;
        isBinary: boolean;
        reliable: boolean;
        senderId: string;
        text: string;
        timestamp: number;
    }[]
    • Every data-channel message received so far, in arrival order.

    • Appended to on each onDataReceived, so a component that mounts late still sees the backlog. Cleared when the room is left.

    participants: Map<string, Participant>

    This represents a map of all remote participants currently in the room.

    • The key represents the participant ID.
    • The value represents the corresponding Participant instance.

    This map does not include the local participant.

    pinnedParticipants: Map<string, { cam: boolean; share: boolean }>

    This represents a map of all participants currently pinned in the room.

    • The key represents the participant ID.
    • The value represents the pin state, indicating whether the participant’s camera (cam) and/or screen share (share) is pinned.
    presenterId: string

    This indicates the participant ID of the user who is currently sharing their screen in the room. If no one is presenting, the value is null.

    recordingState:
        | "RECORDING_STARTING"
        | "RECORDING_STARTED"
        | "RECORDING_STOPPING"
        | "RECORDING_STOPPED"

    This represents the current state of the room recording.

    room: Room

    This represents the underlying Room instance.

    roomId: string

    This represents the unique ID of the room that the participant has joined.

    selectedCameraDevice: { deviceId: string }

    The camera the room is capturing from, as { deviceId }, or null when the SDK chose it or a custom track is in use.

    selectedMicrophoneDevice: { deviceId: string }

    The microphone the room is capturing from, as { deviceId }, or null when the SDK chose it or a custom track is in use.

    transcriptionState:
        | "TRANSCRIPTION_STARTING"
        | "TRANSCRIPTION_STARTED"
        | "TRANSCRIPTION_STOPPING"
        | "TRANSCRIPTION_STOPPED"

    This represents the current state of real-time transcription.

    translationState:
        | "TRANSLATION_STARTING"
        | "TRANSLATION_STARTED"
        | "TRANSLATION_STOPPING"
        | "TRANSLATION_STOPPED"
    • The state of realtime translation for the room, one of the translation states reported by useTranslation's onTranslationStateChanged.
    "TRANSLATION_STOPPED"
    
      • This method can be used to change the active webcam device.
      • If multiple cameras are connected, this method allows switching between them dynamically during the room.

      Parameters

      • Optionalobject: string | MediaStream

        Either:

        • A deviceId of the webcam to switch to, or
        • A MediaStream to be used as the video source.

        Omit it to move to the camera after the current one in useMediaDevice's getCameras() list, wrapping around.

      Returns Promise<void>

      const { getWebcam, changeCam } = useRoom();

      async function switchWebcam() {
      try {
      const cameras = await getCameras();
      const { deviceId, label } = webcams[0];
      await changeCam(deviceId);
      } catch (err) {
      console.log("changeCam failed", err);
      }
      }
      • This method can be used to change the active microphone device.
      • If multiple microphones are available, this method allows switching between them dynamically during the room.

      Parameters

      • Optionalobject: string | MediaStream

        Either:

        • A deviceId string of the microphone to switch to, or
        • A MediaStream to be used as the audio input source.

        Omit it to move to the microphone after the current one in useMediaDevice's getMics() list, wrapping around.

      Returns Promise<void>

      const { changeMic } = useRoom();
      const { getMics } = useMediaDevice();

      async function switchMic() {
      try {
      const mics = await getMics();
      const { deviceId, label } = mics[0];
      await changeMic(deviceId);
      } catch (err) {
      console.log("changeMic failed", err);
      }
      }
      • This method can be used to change the local participant's mode.
      • You can switch between the following modes: Mode.

      Events associated with changeMode():

      Parameters

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

      Returns Promise<void>

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

      const { changeMode } = useRoom();

      async function switchToSendAndRecv() {
      try {
      await changeMode(Constants.Mode.SEND_AND_RECV);
      } catch (err) {
      console.log("changeMode failed", err);
      }
      }
    • The participant presenting now, or null.

      Returns string

    • The participant speaking now, or null.

      Returns string

      • This method can be used to join the room.
      • During initialization using the <RoomProvider>, if joinWithoutUserInteraction is set to true, participant will automatically join the room. If it is false explicity call for join() should be made.

      Events associated with join():

      • The local participant receives a onRoomJoined event once the room is successfully joined.
      • Remote participants receive a onParticipantJoined event containing the newly joined participant.

      Returns Promise<void>

      const { join } = useRoom();

      async function joinRoom() {
      try {
      await join();
      } catch (err) {
      console.log("join failed", err);
      }
      }
      • This method can be used to leave the currently joined room.

      Events associated with leave():

      • The local participant receives a onRoomLeft event.
      • All remote participants receive a onParticipantLeft event containing the participant ID of the user who left.

      Returns Promise<void>

      const { leave } = useRoom();

      async function leaveRoom() {
      try {
      await leave();
      } catch (err) {
      console.log("leave failed", err);
      }
      }
      • This method can be used to pause active media streams in the room.
      • The local participant will receive the onPausedAllStreams event.

      Parameters

      • Optionalkind: "audio" | "video" | "share" | "all"

        Specifies which type of media stream should be paused. If not provided, all media streams (audio, video, and screen share) will be paused.

      Returns Promise<void>

      const { pauseAllStreams } = useRoom();

      async function pauseStreams() {
      try {
      await pauseAllStreams("video");
      } catch (err) {
      console.log("pauseAllStreams failed", err);
      }
      }
    • Uninstalls the applied frame processor; idempotent.

      Returns Promise<void>

      • This method is used to request media relay to another room.

      Parameters

      • options: {
            destinationRoomId: string;
            kinds?: ("audio" | "video" | "share")[];
            token?: string;
        }
        • destinationRoomId: string

          The room ID to relay media to.

        • Optionalkinds?: ("audio" | "video" | "share")[]

          Optional array of media kinds to relay. Relays every kind when omitted; an empty array relays none.

        • Optionaltoken?: string

          Optional token for the destination room.

      Returns Promise<void>

      const { requestMediaRelay } = useRoom();

      async function startMediaRelay() {
      try {
      await requestMediaRelay({
      destinationRoomId: "room-id",
      token: "auth-token",
      kinds: ["audio", "video"],
      });
      } catch (err) {
      console.log("requestMediaRelay failed", err);
      }
      }
      • This method is used to respond to a participant's entry request when the room has ask_join enabled.

      Parameters

      • participantId: string

        The participantId of the participant whose entry request is being responded to.

      • decision: "allowed" | "denied"

        "allow" to admit the participant, "deny" to reject.

      Returns Promise<void>

      const { respondEntry } = useRoom();

      async function allowEntry() {
      try {
      await respondEntry("participant-id", "allowed");
      } catch (err) {
      console.log("respondEntry failed", err);
      }
      }
      • This method can be used to resume media streams that were previously paused.
      • The local participant will receive the onResumedAllStreams event.

      Parameters

      • Optionalkind: "audio" | "video" | "share" | "all"

        Specifies which type of media stream should be resumed.If not provided, all media streams (audio, video, and screen share) will be resumed.

      Returns Promise<void>

      const { resumeAllStreams } = useRoom();

      async function resumeStreams() {
      try {
      await resumeAllStreams("video");
      } catch (err) {
      console.log("resumeAllStreams failed", err);
      }
      }
    • Applies the native frame processor registered under processor.

      A JS function cannot process frames: the processor is native code the host app registers by name (Kotlin VideoProcessorRegistry.register, Swift VideoProcessorRegistry.shared.register), and this selects it.

      Parameters

      • processor: string

      Returns Promise<void>

      • This method can be used to start HLS streaming for the room.
      • This allows participants and viewers to watch the room via HLS playback.
      • All participants, including the local participant, will receive the HLS_STARTING event state in the onHlsStateChanged event.

      Parameters

      • Optionalconfig: HLSConfig

        Configuration used to control the HLS stream.

        How an HLS stream looks, for useRoom's startHLS. A field left out takes the server's default.

        • Optionallayout?: ConfigLayout
        • Optionalmode?: "audio" | "video-and-audio"

          Whether video is streamed or audio only.

        • Optionalorientation?: "landscape" | "portrait"

          The output orientation.

        • Optionalquality?: "low" | "med" | "high"

          The output quality.

        • Optionalrecording?: { enabled: boolean }

          Whether the HLS stream is also recorded.

        • Optionaltheme?: "DEFAULT" | "DARK" | "LIGHT"

          The background theme.

      • Optionaltranscription: {
            enabled: boolean;
            modelId?: string;
            summary?: { enabled: boolean; prompt?: string };
        }

        Configuration for post-room transcription and summary generation.

        • enabled: boolean

          Enables or disables transcription.

        • OptionalmodelId?: string

          Transcription model to use; the server default when left out.

        • Optionalsummary?: { enabled: boolean; prompt?: string }
          • enabled: boolean

            Enables or disables summary generation.

          • Optionalprompt?: string

            Custom prompt used for generating the summary.

      Returns Promise<void>

      const config = {
      layout: {
      type: "SPOTLIGHT",
      priority: "PIN",
      gridSize: 9,
      },
      theme: "DEFAULT",
      recording = {
      enabled: true,
      };
      };

      const transcription = {
      enabled: true,
      summary: {
      enabled: true,
      },
      };

      const { startHLS } = useRoom();

      async function beginHls() {
      try {
      await startHLS(config, transcription);
      } catch (err) {
      console.log("startHLS failed", err);
      }
      }
      • This method can be used to start live streaming the room.
      • This allows you to stream the room to external platforms such as YouTube, Facebook, or any service that supports RTMP.
      • All participants, including the local participant, will receive the LIVESTREAM_STARTING state in the onLivestreamStateChanged event.

      Parameters

      • outputs: LivestreamOutput[]

        An array of RTMP output destinations where the livestream will be broadcast.

      • Optionalconfig: LivestreamConfig

        Configuration options for the RTMP livestream.

        How an RTMP livestream looks, for useRoom's startLivestream. A field left out takes the server's default.

        • Optionallayout?: ConfigLayout
        • Optionalrecording?: { enabled: boolean }

          Whether the livestream is also recorded.

        • Optionaltheme?: "DEFAULT" | "DARK" | "LIGHT"

          The background theme.

      Returns Promise<void>

      const outputs = [
      {
      url: "rtmp://a.rtmp.youtube.com/live2",
      streamKey: "<STREAM_KEY>",
      },
      {
      url: "rtmps://",
      streamKey: "<STREAM_KEY>",
      },
      ];

      const config = {
      layout: {
      type: "SPOTLIGHT",
      priority: "PIN",
      gridSize: 9,
      },
      theme: "DEFAULT",
      recording: {
      enabled: true,
      },
      };

      const { startLivestream } = useRoom();

      async function beginLivestream() {
      try {
      await startLivestream(outputs, config, transcription);
      } catch (err) {
      console.log("startLivestream failed", err);
      }
      }
    • Parameters

      • OptionalwebhookUrl: string

        Webhook URL triggered when the recording state changes.

      • OptionalawsDirPath: string

        Path to the directory in your S3 bucket where recordings are stored.

      • Optionalconfig: RecordingConfig

        Recording configuration options.

        How a cloud recording looks, for useRoom's startRecording. A field left out takes the server's default.

        • Optionallayout?: ConfigLayout
        • Optionalmode?: "audio" | "video-and-audio"

          Whether video is recorded or audio only.

        • Optionalorientation?: "landscape" | "portrait"

          The output orientation.

        • Optionalquality?: "low" | "med" | "high"

          The output quality.

        • Optionaltheme?: "DEFAULT" | "DARK" | "LIGHT"

          The background theme.

      • Optionaltranscription: {
            enabled: boolean;
            language?: string;
            modelId?: string;
            summary?: { enabled: boolean; prompt?: string };
        }

        Configuration for post-recording transcription and summary generation.

        • enabled: boolean

          Enables or disables transcription.

        • Optionallanguage?: string
        • OptionalmodelId?: string

          Transcription model to use; the server default when left out.

        • Optionalsummary?: { enabled: boolean; prompt?: string }
          • enabled: boolean

            Enables or disables summary generation.

          • Optionalprompt?: string

            Custom prompt used for generating transcription summaries.

      Returns Promise<void>

      const webhookUrl = "https://webhook.your-api-server.com";

      const awsDirPath = "/room-recordings/";

      const config = {
      layout: {
      type: "SPOTLIGHT",
      priority: "PIN",
      gridSize: 9,
      },
      theme: "DEFAULT",
      };

      const transcription = {
      enabled: true,
      summary: {
      enabled: true,
      },
      };

      const { startRecording } = useRoom();

      async function beginRecording() {
      try {
      await startRecording(webhookUrl, awsDirPath, config, transcription);
      } catch (err) {
      console.log("startRecording failed", err);
      }
      }
      • This method can be used to toggle the local participant’s webcam.

      Events associated with toggleCam():

      Parameters

      • OptionalcustomVideoTrack: MediaStream

        An optional custom video track to be used instead of the default one.

        To learn more, checkout this reference

      Returns Promise<void>

      const { toggleCam } = useRoom();

      async function handleToggleWebcam() {
      try {
      await toggleCam();
      } catch (err) {
      console.log("toggleCam failed", err);
      }
      }
    • This method can be used to toggle the local participant’s microphone

      Events associated with toggleMic():

      Parameters

      • OptionalcustomAudioTrack: MediaStream

        An optional custom audio track to be used instead of the default one.

        To learn more, checkout this reference.

      Returns Promise<void>

      const { toggleMic } = useRoom();

      async function handleToggleMic() {
      try {
      await toggleMic();
      } catch (err) {
      console.log("toggleMic failed", err);
      }
      }
      • This method can be used to toggle screen sharing for the local participant.

      Events associated with toggleScreenShare():

      Parameters

      • OptionalcustomScreenShareTrack: MediaStream

        An optional custom screen share track to be used instead of the default one.

        To learn more checkout this reference.

      Returns Promise<void>

      const { toggleScreenShare } = useRoom();

      async function handleToggleScreenShare() {
      try {
      await toggleScreenShare();
      } catch (err) {
      console.log("toggleScreenShare failed", err);
      }
      }
    • Not emitted on React Native. The native modules have no event behind it, so a handler passed here never runs. Present for parity with the JS SDK.

      • Triggered when local microphone silence is detected or resolved.
      • Useful for detecting muted hardware or when the local participant's audio track is not capturing any signal.

      Parameters

      • option: { devicelabel?: string; state: "detected" | "resolved"; timestamp: number }
        • Optionaldevicelabel?: string

          Label of the audio input device associated with the event, when available.

        • state: "detected" | "resolved"

          Indicates whether silence has just been "detected" on the audio input, or previously detected silence has been "resolved".

        • timestamp: number

          Time (in milliseconds since epoch) when the event occurred.

      Returns void

      function onAudioInputSilence({ devicelabel, state, timestamp }) {
      //
      }

      const {
      roomId
      ...
      } = useRoom({
      onAudioInputSilence,
      ...
      });
      • Triggered when the room's active media codec changes because a newly joined participant does not support the current codec.
      • The room automatically negotiates and switches to a mutually compatible codec to maintain connectivity for all participants.

      Parameters

      • data: {
            causedBy?: Participant;
            currentCodec: string;
            kind: "video";
            previousCodec: string;
            unsupportedRemoteCodec: string;
        }
        • OptionalcausedBy?: Participant

          The Participant instance of the participant whose joining triggered the codec change.

        • currentCodec: string

          The new codec that the room switched to after the change.

        • kind: "video"

          The media type for which the codec changed.

        • previousCodec: string

          The codec that was in use before the change.

        • unsupportedRemoteCodec: string

          The codec that the newly joined participant did not support, which triggered the switch.

      Returns void

      function onCodecChanged(data) {
      const { previousCodec, currentCodec, kind, causedBy, unsupportedRemoteCodec} = data;
      }

      const {
      roomId
      ...
      } = useRoom({
      onCodecChanged,
      ...
      });
      • Triggered whenever a message is received over the DataStream.

      Parameters

      • data: {
            data: Uint8Array<ArrayBufferLike>;
            isBinary: boolean;
            reliable: boolean;
            senderId: string;
            text: string;
            timestamp: number;
        }
        • data: Uint8Array<ArrayBufferLike>
        • isBinary: boolean
        • reliable: boolean

          Whether the frame was sent on the reliable channel.

        • senderId: string
        • text: string
        • timestamp: number

          Timestamp (in milliseconds since epoch) when the message was sent.

      Returns void

      function onDataReceived({ senderId, text, data, isBinary, timestamp }){
      if (isBinary) {
      console.log(`Binary data from ${senderId}:`, data);
      } else {
      console.log(`Text message from ${senderId}: ${text}`);
      }

      console.log(`Received at: ${new Date(timestamp).toLocaleTimeString()}`);
      };

      const {
      roomId
      ...
      } = useRoom({
      onDataReceived,
      ...
      });
      • Triggered when a participant requests to join the room and their token includes the ask_join permission.
      • This event is emitted only to participants whose token includes the allow_join permission.

      Parameters

      • option: { allow: () => void; deny: () => void; name: string; participantId: string }
        • allow: () => void

          Call this function to allow the participant to join the room.

        • deny: () => void

          Call this function to deny the participant’s request.

        • name: string

          Display name of the participant requesting to join.

        • participantId: string

          Unique ID of the participant requesting to join the room.

      Returns void

      function onEntryRequested(data) {
      const { participantId, name, allow, deny } = data;

      console.log(`${name} requested to join the room.`);

      // If you want to allow the entry request
      allow();

      // if you want to deny the entry request
      deny();
      }

      const {
      roomId
      ...
      } = useRoom({
      onEntryRequested,
      ...
      });
      • Triggered when a participant’s join() request is responded to with an allow or deny decision.

      This event is emitted to:

      • All participants whose token includes the allow_join permission.
      • The participant who requested to join the room.

      Parameters

      • participantId: string

        ID of the participant who requested to join the room.

      • decision: string

        The final decision for the join request.

        Possible values:

        • "allowed" – The participant was allowed to join.
        • "denied" – The participant was denied entry.

      Returns void

      function onEntryResponded(participantId, decision) {
      // participantId will be id of participant who requested to join room

      if (decision === "allowed") {
      // entry allowed
      } else {
      // entry denied
      }
      }

      const {
      roomId
      ...
      } = useRoom({
      onEntryResponded,
      ...
      });
      • Triggered when an error occurs during the room lifecycle.
      • The event provides an error code and a descriptive message. Refer to VideoSDKError for a complete list of supported error codes.

      Parameters

      • option: { code: number; message: string }
        • code: number

          Numeric error code representing the type of error.

        • message: string

          Human-readable description of the error.

      Returns void

      function onError(data) {
      const { code, message } = data;
      }

      const {
      roomId
      ...
      } = useRoom({
      onError,
      ...
      });
      • Triggered when the external phone call is answered.

      Parameters

      • data: { callType: "incoming" | "outgoing" }

      Returns void

      • Triggered when an answered external call ends.

      Parameters

      • data: { callType: "incoming" | "outgoing" }

      Returns void

      • Triggered when a ringing call ends without being answered. A missed call reports here too.

      Parameters

      • data: { callType: "incoming" | "outgoing" }

      Returns void

      • Triggered when an incoming phone call starts ringing on the device.

      Parameters

      • data: { callType: "incoming" | "outgoing" }

      Returns void

      • Triggered when the HLS (HTTP Live Streaming) state changes.

      Parameters

      • option: {
            hlsUrl: { livestreamUrl: string; playbackHlsUrl: string };
            state:
                | "HLS_STARTING"
                | "HLS_STARTED"
                | "HLS_PLAYABLE"
                | "HLS_STOPPING"
                | "HLS_STOPPED";
        }
        • hlsUrl: { livestreamUrl: string; playbackHlsUrl: string }
          • livestreamUrl: string

            Live HLS without playback support

          • playbackHlsUrl: string

            Live HLS with playback support

        • state: "HLS_STARTING" | "HLS_STARTED" | "HLS_PLAYABLE" | "HLS_STOPPING" | "HLS_STOPPED"

          Possible values:

          • HLS_STARTING - Hls is in starting phase and hasn't started yet.
          • HLS_STARTED- Hls has started successfully will return playbackHlsUrl and livestreamUrl.
          • HLS_PLAYABLE - Hls has started and the playbackHlsUrl and livestreamUrl is now playable.
          • HLS_STOPPING - Hls is in stopping phase and hasn't stopped yet.
          • HLS_STOPPED- Hls has stopped successfully.

      Returns void

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

      function onHlsStateChanged(data) {
      const { state } = data;

      if (state === Constants.hlsEvents.HLS_STARTING) {
      console.log("Room Hls is starting");
      } else if (state === Constants.hlsEvents.HLS_STARTED) {
      console.log("Room Hls is started");
      } else if (state === Constants.hlsEvents.HLS_PLAYABLE) {
      // on hlsStateChanged started you will receive playbaclHlsUrl and livestreamUrl.
      const { playbackHlsUrl } = data.hlsUrl;
      console.log("Room Hls is playable");
      } else if (state === Constants.hlsEvents.HLS_STOPPING) {
      console.log("Room Hls is stopping");
      } else if (state === Constants.hlsEvents.HLS_STOPPED) {
      console.log("Room Hls is stopped");
      } else {
      //
      }
      }

      const {
      roomId
      ...
      } = useRoom({
      onHlsStateChanged,
      ...
      });
    • Returns void

      import { useRoom } from "@videosdk.live/react-native-sdk";

      function onLivestreamStarted() {
      console.log("livestream is running");
      }

      useRoom({ onLivestreamStarted });
      • Triggered when the room’s livestream state changes.

      Parameters

      • option: {
            state:
                | "LIVESTREAM_STARTING"
                | "LIVESTREAM_STARTED"
                | "LIVESTREAM_STOPPING"
                | "LIVESTREAM_STOPPED";
        }
        • state:
              | "LIVESTREAM_STARTING"
              | "LIVESTREAM_STARTED"
              | "LIVESTREAM_STOPPING"
              | "LIVESTREAM_STOPPED"

          Possible values:

          • LIVESTREAM_STARTING - Livestream is in starting phase and hasn't started yet.
          • LIVESTREAM_STARTED - Livestream has started successfully.
          • LIVESTREAM_STOPPING - Livestream is in stopping phase and hasn't stopped yet.
          • LIVESTREAM_STOPPED - Livestream has stopped successfully.

      Returns void

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

      function onLivestreamStateChanged(data) {
      const { state } = data;

      if (state === Constants.livestreamEvents.LIVESTREAM_STARTING) {
      console.log("Room livestream is starting");
      } else if (state === Constants.livestreamEvents.LIVESTREAM_STARTED) {
      console.log("Room livestream is started");
      } else if (state === Constants.livestreamEvents.LIVESTREAM_STOPPING) {
      console.log("Room livestream is stopping");
      } else if (state === Constants.livestreamEvents.LIVESTREAM_STOPPED) {
      console.log("Room livestream is stopped");
      } else {
      //
      }
      }

      const {
      roomId
      ...
      } = useRoom({
      onLivestreamStateChanged,
      });
      • Triggered when the server confirms the livestream has stopped.

      • Prefer onLivestreamStateChanged for the full lifecycle.

      Returns void

      import { useRoom } from "@videosdk.live/react-native-sdk";

      function onLivestreamStopped() {
      console.log("livestream has stopped");
      }

      useRoom({ onLivestreamStopped });
      • Triggered when an error occurs during media relay.

      Parameters

      • option: { error: string; roomId: string }
        • error: string

          Description of the error.

        • roomId: string

          ID of the room where the error occurred.

      Returns void

      function onMediaRelayError({roomId, error}) {
      console.error(`Relay error to ${roomId}: ${error}`);
      }

      const {
      roomId
      ...
      } = useRoom({
      onMediaRelayError,
      ...
      });
      • Triggered when a media relay request is received in the destination room.

      Parameters

      • option: {
            accept: () => void;
            displayName: string;
            participantId: string;
            reject: () => void;
            roomId: string;
        }
        • accept: () => void

          Call this function to accept the media relay request.

        • displayName: string

          Display name of the participant requesting the media relay.

        • participantId: string

          ID of the participant who initiated the media relay request.

        • reject: () => void

          Call this function to reject the media relay request.

        • roomId: string

          ID of the room from which the media relay request originated.

      Returns void

      function onMediaRelayRequestReceived(data) {
      const {participantId , roomId , displayName} = data;
      console.log(
      `Relay request from ${displayName} (${participantId}) in room ${roomId}`
      );
      }

      const {
      roomId
      ...
      } = useRoom({
      onMediaRelayRequestReceived,
      ...
      });
      • Triggered when a response is received for a media relay request in the source room.

      Parameters

      • option: { decidedBy: string; decision: "ACCEPTED" | "REJECTED"; participantId: string }
        • decidedBy: string

          ID of the participant who decided the decision.

        • decision: "ACCEPTED" | "REJECTED"

          Decision taken for the request.

        • participantId: string

          ID of the participant who responded to the media relay request.

      Returns void

      function onMediaRelayRequestResponse(data) {
      const {decision , decidedBy , participantId} = data;
      console.log(
      `Relay response from (${participantId}) : ${decision} `
      );
      }

      const {
      roomId
      ...
      } = useRoom({
      onMediaRelayRequestResponse,
      ...
      });
      • Triggered when media relay successfully starts for a destination room.

      Parameters

      • option: { roomId: string }
        • roomId: string

          ID of the room where the media relay has started.

      Returns void

      function onMediaRelayStarted(roomId) {
      console.log(`Media relay started to ${roomId}`);
      }

      const {
      roomId
      ...
      } = useRoom({
      onMediaRelayStarted,
      ...
      });
      • Triggered when media relay stops for a destination room.

      Parameters

      • option: { reason: string; roomId: string }
        • reason: string

          Reason why the media relay stopped.

        • roomId: string

          ID of the room where the media relay stopped.

      Returns void

      function onMediaRelayStopped(roomId) {
      console.log(`Relay to ${roomId} stopped. Reason: ${reason}`);
      }

      const {
      roomId
      ...
      } = useRoom({
      onMediaRelayStopped,
      ...
      });
      • This event will be emitted to the participant B when any other participant A requests to enable mic of participant B.
      • On accepting the request, mic of participant B will be enabled.

      Parameters

      • option: { accept: () => void; participantId: string; reject: () => void }
        • accept: () => void

          Call this function to accept the request and enable your microphone.

        • participantId: string

          ID of the participant who requested to enable your microphone.

        • reject: () => void

          Call this function to reject the request.

      Returns void

      function onMicRequested(data) {
      const { participantId, accept, reject } = data;

      // participantId, will be the id of participant who requested to enable mic

      // if accept request
      accept();

      // if reject request
      reject();
      }

      const {
      roomId
      ...
      } = useRoom({
      onMicRequested,
      ...
      });
      • Triggered when a new participant joins the room.

      Parameters

      • participant: Participant

        The Participant instance representing the newly joined participant.

      Returns void

      function onParticipantJoined(participant) {
      console.log(" onParticipantJoined", participant);
      }

      const {
      roomId
      ...
      } = useRoom({
      onParticipantJoined,
      ...
      });
      • Triggered when a participant leaves the room.
      • When this event is emitted, a reason object is provided that describes why the participant left.

      Possible reason codes:

      Reason Code Description
      WEBSOCKET_DISCONNECTED 1001 Socket disconnected
      REMOVE_PEER 1002 Participant was removed from the room
      REMOVE_PEER_VIEWER_MODE_CHANGED 1003 Participant removed because viewer mode was changed
      REMOVE_PEER_MEDIA_RELAY_STOP 1004 Participant removed because media relay was stopped
      SWITCH_ROOM 1005 Participant switched to a different room
      ROOM_CLOSE 1006 The room has been closed
      UNKNOWN 1007 Participant disconnected due to an unknown reason
      REMOVE_ALL 1008 Remove All from the room
      MEETING_END_API 1009 Room Ended.
      REMOVE_PEER_API 1010 Participant removed from the room
      DUPLICATE_PARTICIPANT 1011 Leaving room, since this participantId joined from another device.
      MANUAL_LEAVE_CALLED 1101 Participant manually called the leave() method to exit the room
      WEBSOCKET_CONNECTION_ATTEMPTS_EXHAUSTED 1102 Room left after multiple failed websocket connection attempts.
      JOIN_ROOM_FAILED 1103 Room left due to an error while joining the room.
      SWITCH_ROOM_FAILED 1104 Room left due to an error while switching rooms.

      Parameters

      • participant: Participant

        The Participant instance who left the room.

      • reason: { code: number; message: string }

        An object describing the reason and corresponding code.

      Returns void

      function onParticipantLeft(participant,reason) {
      if(reason.code === Constants.leaveReason.MANUAL_LEAVE_CALLED){
      // do something
      }
      }

      const {
      roomId
      ...
      } = useRoom({
      onParticipantLeft,
      ...
      });
      • Triggered when a participant’s mode changes.

      Parameters

      • options: {
            mode: "SEND_AND_RECV" | "SIGNALLING_ONLY" | "RECV_ONLY";
            participantId: string;
        }
        • mode: "SEND_AND_RECV" | "SIGNALLING_ONLY" | "RECV_ONLY"

          The new mode of the participant. Possible values are defined in Mode.

        • participantId: string

          ID of the participant whose mode has changed.

      Returns void

      function onParticipantModeChanged(data) {
      const { mode, participantId } = data;
      }

      const {
      roomId
      ...
      } = useRoom({
      onParticipantModeChanged,
      ...
      });
      • Triggered when all or specific media streams are paused.

      Parameters

      • option: { kind: "audio" | "video" | "share" | "all" }
        • kind: "audio" | "video" | "share" | "all"

          Indicates which media type was paused:

          • "audio" – Audio streams
          • "video" – Video streams
          • "share" – Screen-share video streams

      Returns void

      function onPausedAllStreams(data) {
      const { kind } = data;
      }

      const {
      roomId
      ...
      } = useRoom({
      onPausedAllStreams,
      ...
      });
      • Triggered when the pin state of a participant changes.
      • This event is emitted for all participants whenever a participant is pinned or unpinned.

      Parameters

      • option: { peerId: string; pinnedBy: string; state: { cam: boolean; share: boolean } }
        • peerId: string

          ID of the participant whose pin state changed.

        • pinnedBy: string

          ID of the participant who performed the pin or unpin action.

        • state: { cam: boolean; share: boolean }

          Current pin state (true if pinned, false if unpinned).

      Returns void

      function onPinStateChanged(data) {
      const { peerId, state, pinnedBy } = data;
      }

      const {
      roomId
      ...
      } = useRoom({
      onPinStateChanged,
      ...
      });
      • Triggered when a participant starts or stops screen sharing.
      • If screen sharing stops, the callback receives null.

      Parameters

      • presenterId: string

        ID of the participant currently presenting, or null if no one is presenting.

      Returns void

      function onPresenterChanged(presenterId) {
      console.log(" onPresenterChanged", presenterId);
      }

      const {
      roomId
      ...
      } = useRoom({
      onPresenterChanged,
      ...
      });
      • This callback is triggered when a quality limitation is detected or resolved during the room.

      • Triggered when a quality limitation is detected or resolved during the room.

      Parameters

      • option: {
            state: "detected" | "resolved";
            timestamp: number;
            type: "congestion" | "bandwidth" | "cpu";
        }
        • state: "detected" | "resolved"

          Indicates whether the limitation is currently active or resolved.

        • timestamp: number

          Time (in milliseconds since epoch) when the event occurred.

        • type: "congestion" | "bandwidth" | "cpu"

          Specifies the type of limitation.

      Returns void

      function onQualityLimitation({ type, state, timestamp }) {
      //
      }

      const {
      roomId
      ...
      } = useRoom({
      onQualityLimitation,
      ...
      });
      • Triggered when the server confirms cloud recording is running.

      • Prefer onRecordingStateChanged, which reports the starting and stopping phases as well; this fires only on the confirmed transition.

      Returns void

      import { useRoom } from "@videosdk.live/react-native-sdk";

      function onRecordingStarted() {
      console.log("recording is running");
      }

      useRoom({ onRecordingStarted });
      • Triggered when the room’s recording state changes.

      Parameters

      • option: {
            state:
                | "RECORDING_STARTING"
                | "RECORDING_STARTED"
                | "RECORDING_STOPPING"
                | "RECORDING_STOPPED";
        }
        • state:
              | "RECORDING_STARTING"
              | "RECORDING_STARTED"
              | "RECORDING_STOPPING"
              | "RECORDING_STOPPED"

          The current recording state:

          • RECORDING_STARTING - Recording is in starting phase and hasn't started yet.
          • RECORDING_STARTED - Recording has started successfully.
          • RECORDING_STOPPING - Recording is in stopping phase and hasn't stopped yet.
          • RECORDING_STOPPED - Recording has stopped successfully.

      Returns void

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

      function onRecordingStateChanged(data) {
      const { state } = data;

      if (state === Constants.recordingEvents.RECORDING_STARTING) {
      console.log("Room recording is starting");
      } else if (state === Constants.recordingEvents.RECORDING_STARTED) {
      console.log("Room recording is started");
      } else if (state === Constants.recordingEvents.RECORDING_STOPPING) {
      console.log("Room recording is stopping");
      } else if (state === Constants.recordingEvents.RECORDING_STOPPED) {
      console.log("Room recording is stopped");
      } else {
      //
      }
      }

      const {
      roomId
      ...
      } = useRoom({
      onRecordingStateChanged,
      ...
      });
      • Triggered when the server confirms cloud recording has stopped.

      • Prefer onRecordingStateChanged for the full lifecycle.

      Returns void

      import { useRoom } from "@videosdk.live/react-native-sdk";

      function onRecordingStopped() {
      console.log("recording has stopped");
      }

      useRoom({ onRecordingStopped });
      • Triggered when paused media streams are resumed.

      Parameters

      • option: { kind: "audio" | "video" | "share" | "all" }
        • kind: "audio" | "video" | "share" | "all"

          Indicates which media type was resumed:

          • "audio" – Audio streams
          • "video" – Video streams
          • "share" – Screen-share video streams

      Returns void

      function onResumedAllStreams(data) {
      const { kind } = data;
      }

      const {
      roomId
      ...
      } = useRoom({
      onResumedAllStreams,
      ...
      });
      • Triggered when the local participant successfully joins the room.

      Returns void

      function onRoomJoined() {
      console.log("onRoomJoined");
      }

      const {
      roomId
      ...
      } = useRoom({
      onRoomJoined,
      ...
      });
      • Triggered when the local participant leaves the room.
      • When this event is emitted, a reason object is also provided that explains why the participant left the room.

      The table below lists the possible reason codes:

      Reason Code Description
      WEBSOCKET_DISCONNECTED 1001 Socket disconnected
      REMOVE_PEER 1002 Participant was removed from the room
      REMOVE_PEER_VIEWER_MODE_CHANGED 1003 Participant removed due to viewer mode change
      REMOVE_PEER_MEDIA_RELAY_STOP 1004 Participant removed because media relay was stopped
      SWITCH_ROOM 1005 Participant switched to another room
      ROOM_CLOSE 1006 The room was closed
      UNKNOWN 1007 Participant disconnected due to an unknown reason
      REMOVE_ALL 1008 All participants were removed
      MEETING_END_API 1009 Room ended programmatically
      REMOVE_PEER_API 1010 Participant removed via API
      DUPLICATE_PARTICIPANT 1011 Participant joined from another device
      MANUAL_LEAVE_CALLED 1101 Participant manually left the room
      WEBSOCKET_CONNECTION_ATTEMPTS_EXHAUSTED 1102 WebSocket connection retries exhausted
      JOIN_ROOM_FAILED 1103 Failed to join the room
      SWITCH_ROOM_FAILED 1104 Failed to switch rooms

      Parameters

      • reason: { code: number; message: string }

        Object containing the reason and corresponding code.

      Returns void

      function onRoomLeft(reason) {
      if(reason.code === Constants.leaveReason.MANUAL_LEAVE_CALLED){
      // do - something
      }
      }

      const {
      roomId
      ...
      } = useRoom({
      onRoomLeft,
      ...
      });
      • Triggered whenever the room state changes.

      Parameters

      • option: { roomState: string }
        • roomState: string

          The current room state. Possible values:

          • CONNECTING
          • CONNECTED
          • RECONNECTING
          • DISCONNECTED
          • FAILED

      Returns void

      function onRoomStateChanged(data) {
      const { roomState } = data;

      switch(roomState){
      case 'CONNECTING':
      console.log("Room is Connecting");
      break;
      case 'CONNECTED':
      console.log("Room is Connected");
      break;
      case 'DISCONNECTED':
      console.log("Room connection disconnected abruptly");
      break;
      case 'RECONNECTING':
      console.log("Room is Reconnecting");
      break;
      case 'FAILED':
      console.log("Room is in Failed State");
      break;
      default:
      console.log("Unknown state:", roomState);
      break;
      }
      }

      const {
      roomId
      ...
      } = useRoom({
      onRoomStateChanged,
      ...
      });
      • Triggered when the active speaker changes.
      • If no participant is actively speaking, null is returned.

      Parameters

      • activeSpeakerId: string

        ID of the currently active speaker, or null if no one is speaking.

      Returns void

      function onSpeakerChanged(activeSpeakerId) {
      console.log(" onSpeakerChanged", activeSpeakerId);
      }

      const {
      roomId
      ...
      } = useRoom({
      onSpeakerChanged,
      ...
      });
      • This event will be emitted to the participant B when any other participant A requests to enable webcam of participant B.
      • On accepting the request, webcam of participant B will be enabled.

      Parameters

      • option: { accept: () => void; participantId: string; reject: () => void }
        • accept: () => void

          Call this function to accept the request and enable your webcam.

        • participantId: string

          ID of the participant who requested to enable your webcam.

        • reject: () => void

          Call this function to reject the request.

      Returns void

      function onWebcamRequested(data) {
      const { participantId, accept, reject } = data;

      // participantId, will be the id of participant who requested to enable webcam

      // if accept request
      accept();

      // if reject request
      reject();
      }

      const {
      roomId
      ...
      } = useRoom({
      onWebcamRequested,
      ...
      });