Record call sessions for later playback. Recordings are stored server-side and can be accessed through call logs or the CometChat Dashboard.
Recording must be enabled for your CometChat app. Contact support or check your Dashboard settings if recording is not available.
Start Recording
Start recording during an active call session:
val callSession = CallSession.getInstance()
callSession.startRecording()
CallSession callSession = CallSession.getInstance();
callSession.startRecording();
All participants are notified when recording starts.
Stop Recording
Stop an active recording:
val callSession = CallSession.getInstance()
callSession.stopRecording()
CallSession callSession = CallSession.getInstance();
callSession.stopRecording();
Auto-Start Recording
Configure calls to automatically start recording when the session begins:
val sessionSettings = CometChatCalls.SessionSettingsBuilder()
.enableAutoStartRecording(true)
.build()
SessionSettings sessionSettings = new CometChatCalls.SessionSettingsBuilder()
.enableAutoStartRecording(true)
.build();
Hide the recording button from the default call UI:
val sessionSettings = CometChatCalls.SessionSettingsBuilder()
.hideRecordingButton(true)
.build()
SessionSettings sessionSettings = new CometChatCalls.SessionSettingsBuilder()
.hideRecordingButton(true)
.build();
Listen for Recording Events
Monitor recording state changes using MediaEventsListener:
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) {}
})
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) {}
});
Track Participant Recording
Monitor when other participants start or stop recording using ParticipantEventListener:
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...
})
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...
});
Access Recordings
Recordings are available after the call ends. You can access them in two ways:
-
CometChat Dashboard: Navigate to Calls > Call Logs in your CometChat Dashboard to view and download recordings.
-
Programmatically: Fetch recordings through Call Logs:
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}")
}
})
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());
}
});
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 |