jitsi / jitsi-meet-react-sdk

React SDK for Jitsi Meet
Apache License 2.0
65 stars 36 forks source link

startRecording not working #30

Open Gaurav-Gosain opened 1 year ago

Gaurav-Gosain commented 1 year ago

I'm trying to automatically start the recording for the meeting as soon as the user joins. So far I have tried both of the following:

onApiReady={(externalApi) => {
  externalApi.executeCommand("startRecording", {
    mode: "file",
  });
}}

and

onApiReady={(externalApi) => {

  externalApi.startRecording({
    mode: "file",
  });
}}

but neither approach has worked for me. I have jibri setup (the jitsi server is self hosted using jitsi-docker). Starting and stopping the recording manually works as expected. Any help to do this programmatically would be appreciated!

damencho commented 1 year ago

Make sure you are in the meeting and a moderator before starting the recording.

Gaurav-Gosain commented 1 year ago

Hey @damencho,thank you for your prompt response to my previous inquiry. I initially attempted to use an alternative approach, but ultimately found success with the following code snippet:

onApiReady={(externalApi) => {
  apiRef.current = externalApi;
  // add listener for participant joined
  externalApi.addListener("participantJoined", (data) => {
    // get the total number of participants
    const numParticipants = externalApi.getNumberOfParticipants();
    if (numParticipants >= 2 && !recording) {
      // start recording
      externalApi.startRecording({
        mode: "file",
      });
      setRecording(true);
    }
  });
}}

However, I am currently facing a new challenge with stopping the recording programmatically when the moderator (the person who initiated the call) leaves the meeting. Specifically, I am wondering if there is a way to disable the "Leave Meeting" option using the React SDK and only allow the "End Meeting for All" option, as I believe this will automatically stop the recording. Although I acknowledge that this may not be the most elegant solution, I am open to any suggestions or references that you may have.

Ultimately, my ideal outcome would be for the meeting to end for all participants and for the recording to stop only when the moderator exits. Thus far, I have attempted to use the external API reference to call the stopRecording function inside the onReadyToClose callback function, but without success.

Thank you once again for your time and expertise. I look forward to hearing from you soon.

damencho commented 1 year ago

You cannot stop recording on ready to close, as it is too late for that, the participant had left the meeting already.