Implement call recording for voice and video calls using the CometChat JavaScript SDK, including start/stop controls, listeners, and accessing recordings from the Dashboard.
AI Integration Quick Reference
Report incorrect code
Copy
Ask AI
// Start recordingCometChatCalls.startRecording();// Stop recordingCometChatCalls.stopRecording();// Listen for recording events (in CallSettings)const callListener = new CometChatCalls.OngoingCallListener({ onRecordingStarted: (event) => console.log("Recording started", event.user), onRecordingStopped: (event) => console.log("Recording stopped", event.user),});
After setting up Ringing or Call Session, add recording listeners and methods to your call settings.Basic example:
Always remove listeners when they’re no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
JavaScript
TypeScript
Report incorrect code
Copy
Ask AI
// Add listeners onRecordingStarted and onRecordingStopped to the startCall methodconst defaultLayout = true;const audioOnly = false;const callListener = new CometChatCalls.OngoingCallListener({ onRecordingStarted: (event) => console.log("Listener => onRecordingStarted", event.user), onRecordingStopped: (event) => console.log("Listener => onRecordingStopped", event.user),});const callSettings = new CometChatCalls.CallSettingsBuilder() .enableDefaultLayout(defaultLayout) .setIsAudioOnlyCall(audioOnly) .setCallListener(callListener) .build();const htmlElement = document.getElementById("ELEMENT_ID");CometChatCalls.startSession(callToken, callSettings, htmlElement);
Report incorrect code
Copy
Ask AI
// Add listeners onRecordingStarted and onRecordingStopped to the startCall methodconst defaultLayout = true;const audioOnly = false;const callListener = new CometChatCalls.OngoingCallListener({ onRecordingStarted: (event) => console.log("Listener => onRecordingStarted", event.user), onRecordingStopped: (event) => console.log("Listener => onRecordingStopped", event.user),});const callSettings = new CometChatCalls.CallSettingsBuilder() .enableDefaultLayout(defaultLayout) .setIsAudioOnlyCall(audioOnly) .setCallListener(callListener) .build();const htmlElement = document.getElementById("ELEMENT_ID");CometChatCalls.startSession(callToken, callSettings, htmlElement);
Configure recording options using CallSettingsBuilder:
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
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 custom UI without the default layout, use these methods to control recording: