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 rear 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:
CallSession? callSession = CallSession.getInstance();
CallSession.getInstance() returns null if no active session exists. Always use the null-aware ?. operator when calling methods.

Pause Video

Turn off the local camera. Other participants will see a placeholder instead of your video feed.
await CallSession.getInstance()?.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.
await CallSession.getInstance()?.resumeVideo();
When you resume your video, the onVideoResumed() callback is triggered on your MediaEventsListener.

Toggle Pause Video

Convenience method that toggles between paused and resumed video. It checks the current state and calls the appropriate action automatically.
await CallSession.getInstance()?.togglePauseVideo();

Switch Camera

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

CameraFacing Enum

ValueDescription
CameraFacing.frontFront-facing camera (selfie camera)
CameraFacing.rearRear camera

Toggle Camera Source

Convenience method that toggles between front and rear camera. Equivalent to switchCamera().
await CallSession.getInstance()?.toggleCameraSource();

Check Video Pause State

Use the isVideoPaused state getter to check whether the local camera is currently paused.
bool? videoPaused = CallSession.getInstance()?.isVideoPaused;
Return TypeDescription
bool?true if video is paused, false otherwise, null if no active session

Listen for Video Events

Register a MediaEventsListener to receive callbacks when video state changes:
CallSession.getInstance()?.addMediaEventsListener(MediaEventsListener(
  onVideoPaused: () {
    debugPrint("Video paused");
    // Update UI to show video off state
  },
  onVideoResumed: () {
    debugPrint("Video resumed");
    // Update UI to show video on state
  },
  onCameraFacingChanged: (CameraFacing cameraFacing) {
    debugPrint("Camera switched to: $cameraFacing");
    // Update UI to reflect camera change
  },
));
Flutter listeners are not lifecycle-aware. You must manually remove listeners in your widget’s dispose() method to prevent memory leaks.

Initial Video Settings

You can configure the initial video state when joining a session using SessionSettings:
SessionSettings 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:
SessionSettings sessionSettings = CometChatCalls.SessionSettingsBuilder()
    .hideToggleVideoButton(true)   // Hide the video on/off button
    .hideSwitchCameraButton(true)  // Hide the camera flip button
    .build();

Next Steps

Recording

Record call sessions

Media Events Listener

Handle all media events