Skip to main content
setCamera(cameraDeviceId) Switches the local camera stream to the device identified by cameraDeviceId. The cameraDeviceId should match a deviceId value returned by enumerateDevices(). Because enumerateDevices() classifies cameras by their facing value ('user' or 'environment'), this method can be used to switch between front and rear cameras. Has no effect if cameraDeviceId matches the camera already in use. This method can only be invoked while video is unmuted.

Parameters

cameraDeviceId
string
required
The deviceId of the camera to switch to. Must match a deviceId from enumerateDevices().

Return value

Returns a Promise<{ device: { facingMode: DailyCameraFacingMode } | null }> with the newly active camera’s facing mode ('user' or 'environment'), or null if no device was found.

Example

const { devices } = await call.enumerateDevices();
const rearCamera = devices.find(
  (d) => d.kind === 'videoinput' && d.facing === 'environment'
);
if (rearCamera) {
  await call.setCamera(rearCamera.deviceId);
}

See also