Skip to main content
Control video during an active call session. These methods allow you to pause/resume the local camera and switch between front and back cameras.

Prerequisites

  • An active call session
  • Access to the CallSession instance
  • Camera permissions granted

Get CallSession Instance

All video control methods are called on the CallSession singleton:
val callSession = CallSession.getInstance()

Pause Video

Turn off the local camera. Other participants will see a placeholder instead of your video feed.
callSession.pauseVideo()
When you pause your video, the onVideoPaused() callback is triggered on your MediaEventsListener.

Resume Video

Turn on the local camera to resume transmitting video.
callSession.resumeVideo()
When you resume your video, the onVideoResumed() callback is triggered on your MediaEventsListener.

Switch Camera

Toggle between the front-facing and rear cameras.
callSession.switchCamera()
When the camera is switched, the onCameraFacingChanged(CameraFacing) callback is triggered on your MediaEventsListener.

CameraFacing Enum

ValueDescription
FRONTFront-facing camera (selfie camera)
BACKRear camera

Listen for Video Events

Register a MediaEventsListener to receive callbacks when video state changes:
callSession.addMediaEventsListener(this, object : MediaEventsListener {
    override fun onVideoPaused() {
        Log.d(TAG, "Video paused")
        // Update UI to show video off state
    }

    override fun onVideoResumed() {
        Log.d(TAG, "Video resumed")
        // Update UI to show video on state
    }

    override fun onCameraFacingChanged(cameraFacing: CameraFacing) {
        Log.d(TAG, "Camera switched to: ${cameraFacing.value}")
        // Update UI to reflect camera change
    }

    // Other MediaEventsListener callbacks...
    override fun onRecordingStarted() {}
    override fun onRecordingStopped() {}
    override fun onScreenShareStarted() {}
    override fun onScreenShareStopped() {}
    override fun onAudioModeChanged(audioMode: AudioMode) {}
    override fun onAudioMuted() {}
    override fun onAudioUnMuted() {}
})

Initial Video Settings

You can configure the initial video state when joining a session using SessionSettings:
val sessionSettings = CometChatCalls.SessionSettingsBuilder()
    .startVideoPaused(true)                      // Start with camera off
    .setInitialCameraFacing(CameraFacing.FRONT)  // Start with front camera
    .setType(SessionType.VIDEO)                  // Video call (not audio-only)
    .build()

Hide Video Controls in UI

You can hide the built-in video control buttons using SessionSettings:
val sessionSettings = CometChatCalls.SessionSettingsBuilder()
    .hideToggleVideoButton(true)   // Hide the video on/off button
    .hideSwitchCameraButton(true)  // Hide the camera flip button
    .build()

Next Steps