Skip to main content
Use call actions to create your own custom controls or trigger call functionality dynamically based on your use case. All actions are called on the CallSession singleton instance during an active call session.

Get CallSession Instance

The CallSession is a singleton that manages the active call. All actions are accessed through this instance.
CallSession? callSession = CallSession.getInstance();
CallSession.getInstance() returns null if no active session exists. Always use the null-aware ?. operator when calling actions, or check isCallSessionActive() before calling actions to ensure there’s an active call.

Actions

Mute Audio

Mutes your local microphone, stopping audio transmission to other participants.
await CallSession.getInstance()?.muteAudio();

Unmute Audio

Unmutes your local microphone, resuming audio transmission.
await CallSession.getInstance()?.unMuteAudio();

Set Audio Mode

Changes the audio output device during a call.
await CallSession.getInstance()?.setAudioModeType(AudioMode.speaker);
await CallSession.getInstance()?.setAudioModeType(AudioMode.earpiece);
await CallSession.getInstance()?.setAudioModeType(AudioMode.bluetooth);
ValueDescription
AudioMode.speakerRoutes audio through device loudspeaker
AudioMode.earpieceRoutes audio through phone earpiece
AudioMode.bluetoothRoutes audio through connected Bluetooth device

Pause Video

Turns off your local camera, stopping video transmission. Other participants see your avatar.
await CallSession.getInstance()?.pauseVideo();

Resume Video

Turns on your local camera, resuming video transmission.
await CallSession.getInstance()?.resumeVideo();

Switch Camera

Toggles between front and rear cameras without interrupting the video stream.
await CallSession.getInstance()?.switchCamera();

Start Recording

Begins server-side recording of the call. All participants are notified.
await CallSession.getInstance()?.startRecording();
Recording requires the feature to be enabled for your CometChat app.

Stop Recording

Stops the current recording. The recording is saved and accessible via the dashboard.
await CallSession.getInstance()?.stopRecording();

Mute Participant

Mutes a specific participant’s audio. This is a moderator action.
await CallSession.getInstance()?.muteParticipant(participant.uid);

Pause Participant Video

Pauses a specific participant’s video. This is a moderator action.
await CallSession.getInstance()?.pauseParticipantVideo(participant.uid);

Pin Participant

Pins a participant to keep them prominently displayed regardless of who is speaking.
await CallSession.getInstance()?.pinParticipant(participant.uid);

Unpin Participant

Removes the pin, returning to automatic speaker highlighting.
await CallSession.getInstance()?.unPinParticipant();

Set Layout

Changes the call layout. Each participant can choose their own layout independently.
await CallSession.getInstance()?.setLayout(LayoutType.tile);
await CallSession.getInstance()?.setLayout(LayoutType.spotlight);
await CallSession.getInstance()?.setLayout(LayoutType.sidebar);
ValueDescription
LayoutType.tileGrid layout with equally-sized tiles
LayoutType.spotlightLarge view for active speaker, small tiles for others
LayoutType.sidebarMain speaker with participants in a sidebar

Enable Picture In Picture Layout

Enables PiP mode, allowing the call to continue in a floating window.
await CallSession.getInstance()?.enablePictureInPictureLayout();

Disable Picture In Picture Layout

Disables PiP mode, returning to full-screen call interface.
await CallSession.getInstance()?.disablePictureInPictureLayout();

Enter PiP Mode

Enters the system Picture-in-Picture mode directly.
await CallSession.getInstance()?.enterPipMode();
PiP behavior differs between platforms. Android uses the system PiP window, while iOS uses a custom overlay. Use isPipSupported() to check availability before calling this method.

Set Chat Button Unread Count

Updates the badge count on the chat button. Pass 0 to hide the badge.
await CallSession.getInstance()?.setChatButtonUnreadCount(5);

Is Session Active

Returns true if a call session is active, false otherwise.
bool? isActive = CallSession.getInstance()?.isCallSessionActive();

Leave Session

Ends your participation and disconnects gracefully. The call continues for other participants.
await CallSession.getInstance()?.leaveSession();

Raise Hand

Shows a hand-raised indicator to get attention from other participants.
await CallSession.getInstance()?.raiseHand();

Lower Hand

Removes the hand-raised indicator.
await CallSession.getInstance()?.lowerHand();

Toggle Methods

Convenience methods that toggle between two states. These check the current state and call the appropriate action automatically.

Toggle Mute Audio

Toggles between muted and unmuted audio.
await CallSession.getInstance()?.toggleMuteAudio();

Toggle Pause Video

Toggles between paused and resumed video.
await CallSession.getInstance()?.togglePauseVideo();

Toggle Camera Source

Toggles between front and rear camera.
await CallSession.getInstance()?.toggleCameraSource();

Toggle Raise Hand

Toggles between raised and lowered hand.
await CallSession.getInstance()?.toggleRaiseHand();

Alias Methods

These methods are aliases for existing actions, provided for naming convenience.

End Call Session

Alias for leaveSession(). Ends your participation and disconnects gracefully.
await CallSession.getInstance()?.endCallSession();

Start Call Recording

Alias for startRecording(). Begins server-side recording of the call.
await CallSession.getInstance()?.startCallRecording();

Stop Call Recording

Alias for stopRecording(). Stops the current recording.
await CallSession.getInstance()?.stopCallRecording();

Set Call Layout Type

Alias for setLayout(). Changes the call layout.
await CallSession.getInstance()?.setCallLayoutType(LayoutType.tile);

Settings Panel Methods

Methods for controlling the in-call settings panel.

Hide Settings Panel

Hides the settings panel if it is currently visible.
await CallSession.getInstance()?.hideSettingsPanel();

Open Call Settings Panel

Opens the general call settings panel.
await CallSession.getInstance()?.openCallSettingsPanel();

Open Virtual Background Settings Panel

Opens the virtual background settings panel.
await CallSession.getInstance()?.openVirtualBackgroundSettingsPanel();

State Getters

Read-only properties on CallSession that return the current state of the local user in the call.
PropertyTypeDescription
isAudioMutedboolWhether local audio is currently muted
isVideoPausedboolWhether local video is currently paused
isHandRaisedboolWhether the local user’s hand is raised
isRecordingboolWhether the call is currently being recorded
CallSession? session = CallSession.getInstance();

bool? muted = session?.isAudioMuted;
bool? videoPaused = session?.isVideoPaused;
bool? handRaised = session?.isHandRaised;
bool? recording = session?.isRecording;
PropertyTypeDescription
uidStringUnique identifier (CometChat user ID)
nameStringDisplay name
avatarStringURL of avatar image
pidStringParticipant ID for this call session
roleStringRole in the call
audioMutedboolWhether audio is muted
videoPausedboolWhether video is paused
isPinnedboolWhether pinned in layout
isPresentingboolWhether screen sharing
raisedHandTimestampintTimestamp when hand was raised