| name | video-controls |
| description | Control video during calls — pause/resume camera, switch video input device. Use when implementing camera toggle, device switching, or custom video buttons. Triggers on "pause video", "resume video", "switch camera", "camera toggle", "video controls", "video device". |
| inclusion | manual |
CometChat Calls SDK v5 — Video Controls
Overview
Programmatically control the local camera (pause/resume) and switch between video input devices during an active call.
Key Imports
import { CometChatCalls } from '@cometchat/calls-sdk-javascript';
Implementation
Pause / Resume Video
CometChatCalls.pauseVideo();
CometChatCalls.resumeVideo();
CometChatCalls.toggleVideo();
Switch Camera (Mobile Web)
CometChatCalls.switchCamera();
Get Available Video Devices
const videoInputs = CometChatCalls.getVideoInputDevices();
Get Current Video Device
const currentCamera = CometChatCalls.getCurrentVideoInputDevice();
Switch Video Input Device
const devices = CometChatCalls.getVideoInputDevices();
CometChatCalls.setVideoInputDevice(devices[1].deviceId);
Listen for Video Events
CometChatCalls.addEventListener('onVideoPaused', () => {
});
CometChatCalls.addEventListener('onVideoResumed', () => {
});
CometChatCalls.addEventListener('onVideoInputDeviceChanged', (device) => {
console.log('Camera switched to:', device.label);
});
CometChatCalls.addEventListener('onVideoInputDevicesChanged', (devices) => {
});
Pre-select Device (Before Joining)
const sessionSettings: SessionSettings = {
sessionType: 'VIDEO',
videoInputDeviceId: 'specific-camera-id',
startVideoPaused: false,
};
Gotchas
pauseVideo() / resumeVideo() only work during an active session
switchCamera() is primarily for mobile web (front/back toggle) — on desktop, use setVideoInputDevice()
- Device lists return
MediaDeviceInfo objects with deviceId, label, kind, groupId
- Device labels may be empty strings until the user grants camera permission
- For voice calls (
sessionType: 'VOICE'), set startVideoPaused: true
- Camera permissions must be granted before joining — the SDK requests them automatically