| name | video-controls |
| description | Control video during calls — pause/resume camera, switch front/back camera. Use when implementing camera toggle, camera switch, or custom video buttons. Triggers on "pause video", "resume video", "switch camera", "camera toggle", "video controls". |
| inclusion | manual |
CometChat Calls SDK v5 — Video Controls
Overview
Programmatically control the local camera (pause/resume) and switch between front/back cameras during an active call.
Key Imports
import com.cometchat.calls.core.CallSession
import com.cometchat.calls.model.CameraFacing
import com.cometchat.calls.listeners.MediaEventsListener
Implementation
Pause / Resume Video
val callSession = CallSession.getInstance()
callSession.pauseVideo()
callSession.resumeVideo()
Switch Camera
callSession.switchCamera()
Listen for Video Events
callSession.addMediaEventsListener(this, object : MediaEventsListener() {
override fun onVideoPaused() {
}
override fun onVideoResumed() {
}
override fun onCameraFacingChanged(facing: CameraFacing) {
when (facing) {
CameraFacing.FRONT -> { }
CameraFacing.REAR -> { }
}
}
override fun onAudioMuted() {}
override fun onAudioUnMuted() {}
override fun onRecordingStarted() {}
override fun onRecordingStopped() {}
override fun onAudioModeChanged(audioMode: AudioMode) {}
})
Initial Video Settings (Pre-Session)
val sessionSettings = CometChatCalls.SessionSettingsBuilder()
.setSessionType(SessionType.VIDEO)
.startVideoPaused(false)
.setInitialCameraFacing(CameraFacing.FRONT)
.hideToggleVideoButton(false)
.hideSwitchCameraButton(false)
.build()
Gotchas
pauseVideo() / resumeVideo() only work during an active session
switchCamera() toggles between front and back — no parameter needed
CameraFacing enum: FRONT, REAR
- For voice calls (
SessionType.VOICE), set .startVideoPaused(true)
- Camera permissions must be granted at runtime before joining
Sample App Reference
CallActivity.kt — Sets startVideoPaused(true) for voice calls