React Api Reference
    Preparing search index...

    Class useMeeting

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

    Index

    Constructors

    Properties

    activeSpeakerId: string

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

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

    This represents the current state of the HLS stream.

    hlsUrls: {
        downstreamUrl?: string;
        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.
    • downstreamUrlDeprecated. Use playbackHlsUrl or livestreamUrl instead.

    Note

    downstreamUrl is deprecated and should no longer be used.

    isRecording: boolean

    This represents whether the meeting is currently being recorded.

    livestreamState:
        | "LIVESTREAM_STARTING"
        | "LIVESTREAM_STARTED"
        | "LIVESTREAM_STOPPING"
        | "LIVESTREAM_STOPPED"

    This represents the current state of the livestream.

    localMicOn: boolean

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

    localParticipant: Participant

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

    localScreenShareOn: boolean

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

    localWebcamOn: boolean

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

    meeting: Meeting

    This represents the underlying Meeting instance.

    meetingId: string

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

    participants: Map<string, Participant>

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

    • 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 meeting.

    • 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 meeting. 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 meeting recording.

    selectedCameraDevice: CameraDeviceInfo

    This represents the currently selected camera device used during the meeting,returned as a CameraDeviceInfo object containing details about the active camera.

    selectedMicrophoneDevice: MicrophoneDeviceInfo

    This represents the currently selected microphone device used during the meeting,returned as a MicrophoneDeviceInfo object containing details about the active microphone.

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

    This represents the current state of real-time transcription.

    Methods

      • 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 meeting.

      Parameters

      • object: string | MediaStream

        Either:

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

      Returns void

      const { getMics, changeMic } = useMeeting();

      const handleChangeMics = async () => {
      const mics = await getMics();
      const { deviceId, label } = mics[0];
      changeMic(deviceId);
      };

      handleChangeMics();
      • This method can be used to change the local participant's mode.
      • You can switch between the following modes: modes.

      Info

      Important changes introduced in React SDK v0.2.0:

      • CONFERENCE has been replaced with SEND_AND_RECV
      • VIEWER has been replaced with SIGNALLING_ONLY

      Events associated with changeMode():

      Parameters

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

      Returns void

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

      const { changeMode } = useMeeting();

      changeMode(Constants.modes.SEND_AND_RECV);
      • 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 meeting.

      Parameters

      • object: string | MediaStream

        Either:

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

      Returns void

      const { getWebcam, changeWebcam } = useMeeting();

      const handleChangeMics = async () => {
      const webcams = await getWebcams();
      const { deviceId, label } = webcams[0];
      changeWebcam(deviceId);
      };

      handleChangeMics();
      • This method can be used to disable Adaptive Subscription.
      • When disabled, all video streams remain subscribed regardless of visibility or network conditions.

      Returns void

      const { disableAdaptiveSubscription } = useMeeting();

      disableAdaptiveSubscription();
      • This method can be used to disable screen sharing for the local participant.

      Events associated with disableScreenShare():

      Returns void

      const { disableScreenShare } = useMeeting();

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

      Events associated with disableWebcam():

      Returns void

      const { disableWebcam } = useMeeting();

      disableWebcam();
      • This method can be used to enable Adaptive Subscription.
      • Adaptive Subscription dynamically adjusts which video streams are subscribed to, based on participant visibility and current network conditions.

      Returns void

      const { enableAdaptiveSubscription } = useMeeting();

      enableAdaptiveSubscription();
      • This method can be used to enable screen sharing for the local participant.

      Events associated with enableScreenShare():

      Parameters

      • OptionalcustomScreenShareTrack: MediaStream

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

        To learn more checkout this reference

      Returns void

      const { enableScreenShare } = useMeeting();

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

      Events associated with enableWebcam():

      Parameters

      • OptionalcustomVideoTrack: MediaStream

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

        To learn more, checkout this reference

      Returns void

      const { enableWebcam } = useMeeting();

      enableWebcam();
      • This method can be used to end the current meeting session for all participants.
      • Calling end() removes all participants, including the local participant, and permanently terminates the meeting.

      Events associated with end():

      Returns void

      const { end } = useMeeting();

      end();
      • This method can be used to retrieve all available microphone devices connected to the system.

      Returns Promise<{ deviceId: string; label: string }[]>

      const { getMics } = useMeeting();

      const handleGetMics = async () => {
      const mics = await getMics();

      console.log(mics);
      };

      handleGetMics();
      • This method can be used to retrieve all available camera devices connected to the system.

      Returns Promise<
          { deviceId: string; facingMode: "front"
          | "environment"; label: string }[],
      >

      const { getWebcams } = useMeeting();

      const handleGetWebcams = async () => {
      const webcams = await getWebcams();

      console.log(webcams);
      };

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

      Events associated with join():

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

      Returns void

      const { join } = useMeeting();

      join();
      • This method can be used to leave the currently joined meeting.

      Events associated with leave():

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

      Returns void

      const { leave } = useMeeting();

      leave();
      • This method can be used to disable the local participant’s microphone.

      Events associated with muteMic():

      Returns void

      const { muteMic } = useMeeting();

      muteMic();
      • This method can be used to pause active media streams in the meeting.
      • The local participant will receive the onPausedAllStreams event.

      Parameters

      • Optionalkind: "audio" | "video" | "share" | "shareAudio" | "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 void

      const { pauseAllStreams } = useMeeting();

      pauseAllStreams("video");
      • 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" | "shareAudio" | "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 void

      const { resumeAllStreams } = useMeeting();

      resumeAllStreams("video");
      • This method can be used to send a message to all participants in the meeting using the data channel.

      Parameters

      • payload: string | Blob | ArrayBuffer | ArrayBufferView

        The data to be sent.

        • Supported types: string, Blob, ArrayBuffer, ArrayBufferView
        • Maximum allowed size: 15 KiB
      • Optionaloptions: { reliability?: "RELIABLE" | "UNRELIABLE" }
        • Optionalreliability?: "RELIABLE" | "UNRELIABLE"

          Determines how the message is delivered:

      Returns Promise<boolean>

      const { send } = useMeeting();

      send("Hello everyone!", {
      reliability: Constants.reliabilityMode.UNRELIABLE,
      });
      • This method can be used to start HLS streaming for the meeting.
      • This allows participants and viewers to watch the meeting via HLS playback.
      • All participants, including the local participant, will receive the HLS_STARTING event state in the onHlsStateChanged event.

      Parameters

      • Optionalconfig: {
            layout?: {
                gridSize?: number;
                priority?: "SPEAKER" | "PIN";
                type?: "GRID" | "SPOTLIGHT" | "SIDEBAR";
            };
            mode?: "audio"
            | "video-and-audio";
            quality?: "low" | "med" | "high";
            recording?: { enabled: boolean };
            theme?: "DEFAULT" | "DARK" | "LIGHT";
        }

        Configuration used to control the HLS stream.

        • Optionallayout?: {
              gridSize?: number;
              priority?: "SPEAKER" | "PIN";
              type?: "GRID" | "SPOTLIGHT" | "SIDEBAR";
          }
          • OptionalgridSize?: number

            Specifies the maximum number of participants shown in the grid.

          • Optionalpriority?: "SPEAKER" | "PIN"

            Determines participant priority when composing the layout.

          • Optionaltype?: "GRID" | "SPOTLIGHT" | "SIDEBAR"

            Defines the layout used in the HLS stream.

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

          Determines whether the stream includes video and audio or audio only.

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

          Defines the output video quality of the HLS stream.

        • Optionalrecording?: { enabled: boolean }

          This can be used to enable or disable recording.

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

          Defines the visual theme of the HLS stream.

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

        Configuration for post-meeting transcription and summary generation.

        • enabled: boolean

          Enables or disables transcription.

        • 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 } = useMeeting();

      startHls(config, transcription);
      • This method can be used to start live streaming the meeting.
      • This allows you to stream the meeting 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: { streamKey: string; url: string }[]

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

      • Optionalconfig: {
            layout?: {
                gridSize?: number;
                priority?: "SPEAKER" | "PIN";
                type?: "GRID" | "SPOTLIGHT" | "SIDEBAR";
            };
            recording?: { enabled: boolean };
            theme?: "DEFAULT" | "DARK" | "LIGHT";
        }

        Configuration options for the RTMP livestream.

        • Optionallayout?: {
              gridSize?: number;
              priority?: "SPEAKER" | "PIN";
              type?: "GRID" | "SPOTLIGHT" | "SIDEBAR";
          }
          • OptionalgridSize?: number

            Specifies the maximum number of participants displayed in the grid.

          • Optionalpriority?: "SPEAKER" | "PIN"

            Determines participant priority when composing the livestream layout.

          • Optionaltype?: "GRID" | "SPOTLIGHT" | "SIDEBAR"

            Defines the layout used for the livestream.

        • Optionalrecording?: { enabled: boolean }

          This can be used to enable or disable recording.

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

          Defines the color theme of the livestream.

      Returns 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 } = useMeeting();

      startLiveStream(outputs, config, transcription);
    • 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: {
            layout: {
                gridSize: number;
                priority: "SPEAKER" | "PIN";
                type: "GRID" | "SPOTLIGHT" | "SIDEBAR";
            };
            mode: "audio"
            | "video-and-audio";
            orientation: "landscape" | "portrait";
            quality: "low" | "med" | "high";
            theme: "DEFAULT" | "DARK" | "LIGHT";
        }

        Recording configuration options.

        • layout: {
              gridSize: number;
              priority: "SPEAKER" | "PIN";
              type: "GRID" | "SPOTLIGHT" | "SIDEBAR";
          }

          Defines how participants are arranged in the recording.

          • gridSize: number

            Maximum number of participants displayed simultaneously.

          • priority: "SPEAKER" | "PIN"

            Determines participant prioritization.

          • type: "GRID" | "SPOTLIGHT" | "SIDEBAR"

            Layout type for the recording.

        • mode: "audio" | "video-and-audio"

          Defines whether the recording includes video or audio only.

        • orientation: "landscape" | "portrait"
        • quality: "low" | "med" | "high"

          Controls the output quality of the recording.

        • theme: "DEFAULT" | "DARK" | "LIGHT"

          Visual theme applied to the recording.

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

        Configuration for post-recording transcription and summary generation.

        • enabled: boolean

          Enables or disables transcription.

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

            Enables or disables summary generation.

          • Optionalprompt?: string

            Custom prompt used for generating transcription summaries.

      Returns void

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

      const awsDirPath = "/meeting-recordings/";

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

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

      const { startRecording } = useMeeting();

      startRecording(webhookUrl, awsDirPath, config, transcription);
      • This method can be used to stop the active HLS stream.
      • All participants, including the local participant, will receive the HLS_STOPPING event state in the onHlsStateChanged event.

      Returns void

      const { stopHls } = useMeeting();

      stopHls();
    • Returns void

      const { stopLiveStream } = useMeeting();

      stopLiveStream();
    • Returns void

      const { stopRecording } = useMeeting();

      stopRecording();
      • This method can be used to switch the current session to another meeting without disconnecting.
      • This allows a seamless transition between meetings while preserving the active session context.

      Parameters

      • options: { meetingId: string; token?: string }
        • meetingId: string

          The ID of the meeting to switch to.

        • Optionaltoken?: string

          Authentication token for the destination meeting.

      Returns void

      const { switchTo } = useMeeting();

      switchTo({
      meetingId: "new-meeting-id",
      token: "optional-auth-token",
      });
    • 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 void

      const { toggleMic } = useMeeting();

      toggleMic();
      • 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 void

      const { toggleScreenShare } = useMeeting();

      toggleScreenShare();
      • This method can be used to toggle the local participant’s webcam.

      Events associated with toggleWebcam():

      Parameters

      • OptionalcustomVideoTrack: MediaStream

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

        To learn more, checkout this reference

      Returns void

      const { toggleWebcam } = useMeeting();

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

      Events associated with unmuteMic():

      Parameters

      • OptionalcustomAudioTrack: MediaStream

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

        To learn more, checkout this reference

      Returns void

      const { unmuteMic } = useMeeting();

      unmuteMic();

    Events

      • Triggered whenever a message is received over the DataStream.

      Parameters

      • data: {
            from: string;
            payload: string | Uint8Array;
            reliability: string;
            timestamp: string;
        }
        • from: string

          ID of the participant who sent the message.

        • payload: string | Uint8Array

          The received message payload.

          • string for text messages
          • Uint8Array for binary data
        • reliability: string

          Indicates whether the message delivery was reliable or unreliable.

        • timestamp: string

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

      Returns void

      function onData({ payload, from, timestamp, reliability }){
      if (typeof payload === "string") {
      console.log(`Text message from ${from}: ${payload}`);
      } else {
      console.log(`Binary data from ${from}:`, payload);
      }

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

      const {
      meetingId
      ...
      } = useMeeting({
      onData,
      ...
      });
      • Triggered when a participant requests to join the meeting 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 meeting.

        • 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 meeting.

      Returns void

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

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

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

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

      const {
      meetingId
      ...
      } = useMeeting({
      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 meeting.

      Parameters

      • participantId: string

        ID of the participant who requested to join the meeting.

      • 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 meeting

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

      const {
      meetingId
      ...
      } = useMeeting({
      onEntryResponded,
      ...
      });
      • Triggered when an error occurs during the meeting lifecycle.
      • The event provides an error code and a descriptive message. Refer to Errors 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 {
      meetingId
      ...
      } = useMeeting({
      onError,
      ...
      });
      • Triggered when the HLS (HTTP Live Streaming) state changes.

      Parameters

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

          Live HLS without playback support

        • playbackHlsUrl: string

          Live HLS with playback support

        • status: "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, useMeeting } from "@videosdk.live/react-sdk";

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

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

      const {
      meetingId
      ...
      } = useMeeting({
      onHlsStateChanged,
      ...
      });
      • Triggered when the meeting’s livestream state changes.

      Parameters

      • option: {
            status:
                | "LIVESTREAM_STARTING"
                | "LIVESTREAM_STARTED"
                | "LIVESTREAM_STOPPING"
                | "LIVESTREAM_STOPPED";
        }
        • status:
              | "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, useMeeting } from "@videosdk.live/react-sdk";

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

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

      const {
      meetingId
      ...
      } = useMeeting({
      onLivestreamStateChanged,
      });
      • Triggered when the main participant in the meeting changes.

      Parameters

      • participant: Participant

        The Participant instance who is now the main participant.

      Returns void

      function onMainParticipantChanged(participantId) {
      console.log("onMainParticipantChanged", participantId);
      }

      const {
      meetingId
      ...
      } = useMeeting({
      onMainParticipantChanged,
      ...
      });
      • Triggered when an error occurs during media relay.

      Parameters

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

          Description of the error.

        • meetingId: string

          ID of the meeting where the error occurred.

      Returns void

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

      const {
      meetingId
      ...
      } = useMeeting({
      onMediaRelayError,
      ...
      });
      • Triggered when a media relay request is received in the destination meeting.

      Parameters

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

          Call this function to accept the media relay request.

        • displayName: string

          Display name of the participant requesting the media relay.

        • meetingId: string

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

        • participantId: string

          ID of the participant who initiated the media relay request.

        • reject: () => void

          Call this function to reject the media relay request.

      Returns void

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

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

      Parameters

      • option: { decidedBy: string; decision: "accepted" | "declined"; participantId: string }
        • decidedBy: string

          ID of the participant who decided the decision.

        • decision: "accepted" | "declined"

          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 {
      meetingId
      ...
      } = useMeeting({
      onMediaRelayRequestResponse,
      ...
      });
      • Triggered when media relay successfully starts for a destination meeting.

      Parameters

      • option: { meetingId: string }
        • meetingId: string

          ID of the meeting where the media relay has started.

      Returns void

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

      const {
      meetingId
      ...
      } = useMeeting({
      onMediaRelayStarted,
      ...
      });
      • Triggered when media relay stops for a destination meeting.

      Parameters

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

          ID of the meeting where the media relay stopped.

        • reason: string

          Reason why the media relay stopped.

      Returns void

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

      const {
      meetingId
      ...
      } = useMeeting({
      onMediaRelayStopped,
      ...
      });
      • Triggered when the local participant successfully joins the meeting.

      Returns void

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

      const {
      meetingId
      ...
      } = useMeeting({
      onMeetingJoined,
      ...
      });
      • Triggered when the local participant leaves the meeting.
      • When this event is emitted, a reason object is also provided that explains why the participant left the meeting.

      The table below lists the possible reason codes:

      Reason Code Description
      WEBSOCKET_DISCONNECTED 1001 Socket disconnected
      REMOVE_PEER 1002 Participant was removed from the meeting
      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 meeting was closed
      UNKNOWN 1007 Participant disconnected due to an unknown reason
      REMOVE_ALL 1008 All participants were removed
      MEETING_END_API 1009 Meeting 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 meeting
      WEBSOCKET_CONNECTION_ATTEMPTS_EXHAUSTED 1102 WebSocket connection retries exhausted
      JOIN_ROOM_FAILED 1103 Failed to join the meeting
      SWITCH_ROOM_FAILED 1104 Failed to switch rooms

      Parameters

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

        Object containing the reason and corresponding code.

      Returns void

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

      const {
      meetingId
      ...
      } = useMeeting({
      onMeetingLeft,
      ...
      });
      • Triggered whenever the meeting state changes.

      Parameters

      • option: { state: string }
        • state: string

          The current meeting state. Possible values:

          • CONNECTING
          • CONNECTED
          • RECONNECTING
          • DISCONNECTED
          • FAILED

      Returns void

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

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

      const {
      meetingId
      ...
      } = useMeeting({
      onMeetingStateChanged,
      ...
      });
      • 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 {
      meetingId
      ...
      } = useMeeting({
      onMicRequested,
      ...
      });
      • Triggered when a new participant joins the meeting.

      Parameters

      • participant: Participant

        The Participant instance representing the newly joined participant.

      Returns void

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

      const {
      meetingId
      ...
      } = useMeeting({
      onParticipantJoined,
      ...
      });
      • Triggered when a participant leaves the meeting.
      • 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 meeting
      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 meeting has been closed
      UNKNOWN 1007 Participant disconnected due to an unknown reason
      REMOVE_ALL 1008 Remove All from the meeting
      MEETING_END_API 1009 Meeting Ended.
      REMOVE_PEER_API 1010 Participant removed from the meeting
      DUPLICATE_PARTICIPANT 1011 Leaving meeting, since this participantId joined from another device.
      MANUAL_LEAVE_CALLED 1101 Participant manually called the leave() method to exit the meeting
      WEBSOCKET_CONNECTION_ATTEMPTS_EXHAUSTED 1102 Meeting left after multiple failed websocket connection attempts.
      JOIN_ROOM_FAILED 1103 Meeting left due to an error while joining the room.
      SWITCH_ROOM_FAILED 1104 Meeting left due to an error while switching rooms.

      Parameters

      • participant: Participant

        The Participant instance who left the meeting.

      • 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 {
      meetingId
      ...
      } = useMeeting({
      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 modes.

        • participantId: string

          ID of the participant whose mode has changed.

      Returns void

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

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

      Parameters

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

          Indicates which media type was paused:

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

      Returns void

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

      const {
      meetingId
      ...
      } = useMeeting({
      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 {
      meetingId
      ...
      } = useMeeting({
      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 {
      meetingId
      ...
      } = useMeeting({
      onPresenterChanged,
      ...
      });
      • This callback is triggered when a quality limitation is detected or resolved during the meeting.

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

      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 {
      meetingId
      ...
      } = useMeeting({
      onQualityLimitation,
      ...
      });
      • Triggered when the meeting’s recording state changes.

      Parameters

      • option: {
            status:
                | "RECORDING_STARTING"
                | "RECORDING_STARTED"
                | "RECORDING_STOPPING"
                | "RECORDING_STOPPED";
        }
        • status:
              | "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, useMeeting } from "@videosdk.live/react-sdk";

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

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

      const {
      meetingId
      ...
      } = useMeeting({
      onRecordingStateChanged,
      ...
      });
      • Triggered when paused media streams are resumed.

      Parameters

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

          Indicates which media type was resumed:

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

      Returns void

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

      const {
      meetingId
      ...
      } = useMeeting({
      onResumedAllStreams,
      ...
      });
      • 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 {
      meetingId
      ...
      } = useMeeting({
      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 {
      meetingId
      ...
      } = useMeeting({
      onWebcamRequested,
      ...
      });