> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-rn-guide-message-privately.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Recording (Beta)

> Recording (Beta) — CometChat documentation.

This section will guide you to implement call recording feature for the voice and video calls.

## Implementation

Once you have decided to implement [Default Calling](/sdk/javascript/3.0/calling-default-calling) or [Direct Calling](/sdk/javascript/3.0/calling-direct-calling) calling and followed the steps to implement them. Just few additional listeners and methods will help you quickly implement call recording in your app.

You need to make changes in the CometChat.startCall method and add the required listeners for recording. Please make sure your callSettings is configured accordingly for [Default Calling](/sdk/javascript/3.0/calling-default-calling) or [Direct Calling](/sdk/javascript/3.0/calling-direct-calling).

A basic example of how to make changes to implement recording for a direct call/ a default call:

<Tabs>
  <Tab title="Default Calling - JavaScript">
    ```javascript theme={null}
    // Add listeners onRecordingStarted and onRecordingStopped to the startCall method
    let sessionId = "SESSION_ID";
    let audioOnly = false;
    let defaultLayout = true;
    let showRecordingButton = true;

    let callSettings = new CometChat.CallSettingsBuilder()
      .enableDefaultLayout(defaultLayout)
      .showRecordingButton(showRecordingButton)
      .setSessionID(sessionId)
      .setIsAudioOnlyCall(audioOnly)
      .build();

    CometChat.startCall(
      callSettings,
      document.getElementById("callScreen"),
      new CometChat.OngoingCallListener({
          onRecordingStarted: recordingStartedBy => {
              // This event will work in JS SDK v3.0.2-beta1 & later.
              console.log("Listener => onRecordingStarted:", recordingStartedBy);
          },
          onRecordingStopped: recordingStoppedBy => {
              // This event will work in JS SDK v3.0.2-beta1 & later.
              console.log("Listener => onRecordingStopped:", recordingStoppedBy);
          },
      })
    );  
    ```
  </Tab>

  <Tab title="Direct Calling - JavaScript">
    ```javascript theme={null}
    // Add listeners onRecordingStarted and onRecordingStopped to the startCall method
    let sessionId = "SESSION_ID";
    let audioOnly = false;
    let defaultLayout = true;
    let showRecordingButton = true;

    var callSettings = new CometChat.CallSettingsBuilder()
      .enableDefaultLayout(defaultLayout)
      .showRecordingButton(showRecordingButton)
      .setSessionID(sessionId)
      .setIsAudioOnlyCall(audioOnly)
      .build();

    CometChat.startCall(
      callSettings,
      document.getElementById("callScreen"),
      new CometChat.OngoingCallListener({
          onRecordingStarted: recordingStartedBy => {
              // This event will work in JS SDK v3.0.2-beta1 & later.
              console.log("Listener => onRecordingStarted:", recordingStartedBy);
          },
          onRecordingStopped: recordingStoppedBy => {
              // This event will work in JS SDK v3.0.2-beta1 & later.
              console.log("Listener => onRecordingStopped:", recordingStoppedBy);
          },
      })
    ); 
    ```
  </Tab>

  <Tab title="Default Calling (Typescript)">
    ```javascript theme={null}
    // Add listeners onRecordingStarted and onRecordingStopped to the startCall method.
    let sessionId = "SESSION_ID";
    let audioOnly = false;
    let defaultLayout = true;
    let showRecordingButton = true;

    let callSettings = new CometChat.CallSettingsBuilder()
      .enableDefaultLayout(defaultLayout)
      .showRecordingButton(showRecordingButton)
      .setSessionID(sessionId)
      .setIsAudioOnlyCall(audioOnly)
      .build();

    CometChat.startCall(
      callSettings,
      document.getElementById("callScreen"),
      new CometChat.OngoingCallListener({
          onRecordingStarted: (recordingStartedBy: CometChat.User) => {
              // This event will work in JS SDK v3.0.2-beta1 & later.
              console.log("Listener => onRecordingStarted:", recordingStartedBy);
          },
          onRecordingStopped: (recordingStoppedBy: CometChat.User) => {
              // This event will work in JS SDK v3.0.2-beta1 & later.
              console.log("Listener => onRecordingStopped:", recordingStoppedBy);
          },
      })
    );
    ```
  </Tab>

  <Tab title="Direct Calling (Typescript)">
    ```javascript theme={null}
    // Add listeners onRecordingStarted and onRecordingStopped to the startCall method
    let sessionId = "SESSION_ID";
    let audioOnly = false;
    let defaultLayout = true;
    let showRecordingButton = true;

    var callSettings = new CometChat.CallSettingsBuilder()
      .enableDefaultLayout(defaultLayout)
      .showRecordingButton(showRecordingButton)
      .setSessionID(sessionId)
      .setIsAudioOnlyCall(audioOnly)
      .build();

    CometChat.startCall(
      callSettings,
      document.getElementById("callScreen"),
      new CometChat.OngoingCallListener({
          onRecordingStarted: (recordingStartedBy: CometChat.User) => {
              // This event will work in JS SDK v3.0.2-beta1 & later.
              console.log("Listener => onRecordingStarted:", recordingStartedBy);
          },
          onRecordingStopped: (recordingStoppedBy: CometChat.User) => {
              // This event will work in JS SDK v3.0.2-beta1 & later.
              console.log("Listener => onRecordingStopped:", recordingStoppedBy);
          },
      })
    );
    ```
  </Tab>
</Tabs>

## Settings for call recording

The `CallSettings`class allows you to customise the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you and object of the `CallSettings` class which you can pass to the `startCall()` method to start the call.

The **mandatory** parameters that are required to be present for any call/conference to work are:

1. sessionId - The unique session Id for the call/conference session.

The options available for recording of calls are:

| Setting                                                         | Description                                                                                                                                                                          |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `showRecordingButton(showRecordingButton: boolean)`             | If set to `true` it displays the Recording button in the button Layout. if set to `false` it hides the Recording button in the button Layout. **Default value = false**              |
| `startRecordingOnCallStart(startRecordingOnCallStart: boolean)` | If set to `true` call recording will start as soon as the call is started. if set to `false` call recording will not start as soon as the call is started. **Default value = false** |

For the use case where you wish to align your own custom buttons and not use the default layout provided by CometChat, you can embed the buttons in your layout and use the below methods to perform the corresponding operations:

### Start Recording

You can use the startRecording() method to start call recording.

<Tabs>
  <Tab title="Start Recording">
    ```javascript theme={null}
    let callController = CometChat.CallController.getInstance();
    callController.startRecording();
    ```
  </Tab>

  <Tab title="TypeScript">
    ```ts theme={null}
    let callController: CometChat.CallController = CometChat.CallController.getInstance();
    callController.startRecording();
    ```
  </Tab>
</Tabs>

### Stop Recording

You can use the stopRecording() method to stop call recording.

<Tabs>
  <Tab title="Stop Recording">
    ```javascript theme={null}
    let callController = CometChat.CallController.getInstance();
    callController.stopRecording();
    ```
  </Tab>

  <Tab title="TypeScript">
    ```ts theme={null}
    let callController: CometChat.CallController = CometChat.CallController.getInstance();
    callController.stopRecording();
    ```
  </Tab>
</Tabs>
