> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Recording

> CometChat Calling SDK v5 - Recording for Android

Record call sessions for later playback. Recordings are stored server-side and can be accessed through call logs or the CometChat Dashboard.

<Warning>
  Recording must be enabled for your CometChat app. Contact support or check your Dashboard settings if recording is not available.
</Warning>

## Start Recording

Start recording during an active call session:

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    val callSession = CallSession.getInstance()
    callSession.startRecording()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    CallSession callSession = CallSession.getInstance();
    callSession.startRecording();
    ```
  </Tab>
</Tabs>

All participants are notified when recording starts.

## Stop Recording

Stop an active recording:

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    val callSession = CallSession.getInstance()
    callSession.stopRecording()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    CallSession callSession = CallSession.getInstance();
    callSession.stopRecording();
    ```
  </Tab>
</Tabs>

## Auto-Start Recording

Configure calls to automatically start recording when the session begins:

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    val sessionSettings = CometChatCalls.SessionSettingsBuilder()
        .enableAutoStartRecording(true)
        .build()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    SessionSettings sessionSettings = new CometChatCalls.SessionSettingsBuilder()
        .enableAutoStartRecording(true)
        .build();
    ```
  </Tab>
</Tabs>

## Hide Recording Button

Hide the recording button from the default call UI:

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    val sessionSettings = CometChatCalls.SessionSettingsBuilder()
        .hideRecordingButton(true)
        .build()
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    SessionSettings sessionSettings = new CometChatCalls.SessionSettingsBuilder()
        .hideRecordingButton(true)
        .build();
    ```
  </Tab>
</Tabs>

## Listen for Recording Events

Monitor recording state changes using `MediaEventsListener`:

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    val callSession = CallSession.getInstance()

    callSession.addMediaEventsListener(this, object : MediaEventsListener() {
        override fun onRecordingStarted() {
            Log.d(TAG, "Recording started")
            showRecordingIndicator()
        }

        override fun onRecordingStopped() {
            Log.d(TAG, "Recording stopped")
            hideRecordingIndicator()
        }

        // Other callbacks...
        override fun onAudioMuted() {}
        override fun onAudioUnMuted() {}
        override fun onVideoPaused() {}
        override fun onVideoResumed() {}
        override fun onScreenShareStarted() {}
        override fun onScreenShareStopped() {}
        override fun onAudioModeChanged(audioMode: AudioMode) {}
        override fun onCameraFacingChanged(facing: CameraFacing) {}
    })
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    CallSession callSession = CallSession.getInstance();

    callSession.addMediaEventsListener(this, new MediaEventsListener() {
        @Override
        public void onRecordingStarted() {
            Log.d(TAG, "Recording started");
            showRecordingIndicator();
        }

        @Override
        public void onRecordingStopped() {
            Log.d(TAG, "Recording stopped");
            hideRecordingIndicator();
        }

        // Other callbacks...
        @Override public void onAudioMuted() {}
        @Override public void onAudioUnMuted() {}
        @Override public void onVideoPaused() {}
        @Override public void onVideoResumed() {}
        @Override public void onScreenShareStarted() {}
        @Override public void onScreenShareStopped() {}
        @Override public void onAudioModeChanged(AudioMode audioMode) {}
        @Override public void onCameraFacingChanged(CameraFacing facing) {}
    });
    ```
  </Tab>
</Tabs>

## Track Participant Recording

Monitor when other participants start or stop recording using `ParticipantEventListener`:

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    callSession.addParticipantEventListener(this, object : ParticipantEventListener() {
        override fun onParticipantStartedRecording(participant: Participant) {
            Log.d(TAG, "${participant.name} started recording")
        }

        override fun onParticipantStoppedRecording(participant: Participant) {
            Log.d(TAG, "${participant.name} stopped recording")
        }

        // Other callbacks...
    })
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    callSession.addParticipantEventListener(this, new ParticipantEventListener() {
        @Override
        public void onParticipantStartedRecording(Participant participant) {
            Log.d(TAG, participant.getName() + " started recording");
        }

        @Override
        public void onParticipantStoppedRecording(Participant participant) {
            Log.d(TAG, participant.getName() + " stopped recording");
        }

        // Other callbacks...
    });
    ```
  </Tab>
</Tabs>

## Access Recordings

Recordings are available after the call ends. You can access them in two ways:

1. **CometChat Dashboard**: Navigate to **Calls > Call Logs** in your [CometChat Dashboard](https://app.cometchat.com) to view and download recordings.

2. **Programmatically**: Fetch recordings through [Call Logs](/calls/android/call-logs):

<Tabs>
  <Tab title="Kotlin">
    ```kotlin theme={null}
    val callLogRequest = CallLogRequest.CallLogRequestBuilder()
        .setHasRecording(true)
        .build()

    callLogRequest.fetchNext(object : CometChatCalls.CallbackListener<List<CallLog>>() {
        override fun onSuccess(callLogs: List<CallLog>) {
            for (callLog in callLogs) {
                callLog.recordings?.forEach { recording ->
                    Log.d(TAG, "Recording URL: ${recording.recordingURL}")
                    Log.d(TAG, "Duration: ${recording.duration} seconds")
                    Log.d(TAG, "Start Time: ${recording.startTime}")
                    Log.d(TAG, "End Time: ${recording.endTime}")
                }
            }
        }

        override fun onError(e: CometChatException) {
            Log.e(TAG, "Error: ${e.message}")
        }
    })
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    CallLogRequest callLogRequest = new CallLogRequest.CallLogRequestBuilder()
        .setHasRecording(true)
        .build();

    callLogRequest.fetchNext(new CometChatCalls.CallbackListener<List<CallLog>>() {
        @Override
        public void onSuccess(List<CallLog> callLogs) {
            for (CallLog callLog : callLogs) {
                for (Recording recording : callLog.getRecordings()) {
                    Log.d(TAG, "Recording URL: " + recording.getRecordingURL());
                    Log.d(TAG, "Duration: " + recording.getDuration() + " seconds");
                    Log.d(TAG, "Start Time: " + recording.getStartTime());
                    Log.d(TAG, "End Time: " + recording.getEndTime());
                }
            }
        }

        @Override
        public void onError(CometChatException e) {
            Log.e(TAG, "Error: " + e.getMessage());
        }
    });
    ```
  </Tab>
</Tabs>

## Recording Object

| Property       | Type   | Description                          |
| -------------- | ------ | ------------------------------------ |
| `rid`          | String | Unique recording identifier          |
| `recordingURL` | String | URL to download/stream the recording |
| `startTime`    | int    | Timestamp when recording started     |
| `endTime`      | int    | Timestamp when recording ended       |
| `duration`     | double | Recording duration in seconds        |
