Camera controls
The Video SDK for Android lets you control the local user's camera during a session: switch, mirror, rotate, and toggle the flashlight. These per-device operations run through ZoomVideoSDKVideoHelper. For using two cameras at the same time, see Multiple camera support.
Get the camera list
To enumerate the cameras available on the device, call getCameraList on the VideoHelper. Each entry carries the deviceId you'll need for switchCamera and the multi-camera APIs.
val cameras = ZoomVideoSDK.getInstance().videoHelper.cameraList
for (camera in cameras) {
// Each device exposes deviceId, deviceName, isSelectDevice, isSelectedAsMultiCamera, isRunningAsMultiCamera
}
List<ZoomVideoSDKCameraDevice> cameras = ZoomVideoSDK.getInstance().getVideoHelper().getCameraList();
for (ZoomVideoSDKCameraDevice camera : cameras) {
// Each device exposes deviceId, deviceName, isSelectDevice, isSelectedAsMultiCamera, isRunningAsMultiCamera
}
To check the number of available cameras without enumerating, use getNumberOfCameras().
Switch camera
Call switchCamera() with no arguments to cycle to the next available camera. On most phones this toggles between the front and back camera.
ZoomVideoSDK.getInstance().videoHelper.switchCamera()
ZoomVideoSDK.getInstance().getVideoHelper().switchCamera();
To switch to a specific camera, pass a ZoomVideoSDKCameraDevice from getCameraList().
val videoHelper = ZoomVideoSDK.getInstance().videoHelper
val cameras = videoHelper.cameraList
videoHelper.switchCamera(cameras[1])
ZoomVideoSDKVideoHelper videoHelper = ZoomVideoSDK.getInstance().getVideoHelper();
List<ZoomVideoSDKCameraDevice> cameras = videoHelper.getCameraList();
videoHelper.switchCamera(cameras.get(1));
Mirror the local video
Mirroring is a common convention for the front-facing camera, so the user sees themselves the way they would in a mirror. Use mirrorMyVideo(true) to enable and mirrorMyVideo(false) to disable. Use isMyVideoMirrored() to read the current state.
val videoHelper = ZoomVideoSDK.getInstance().videoHelper
videoHelper.mirrorMyVideo(true)
val isMirrored = videoHelper.isMyVideoMirrored
ZoomVideoSDKVideoHelper videoHelper = ZoomVideoSDK.getInstance().getVideoHelper();
videoHelper.mirrorMyVideo(true);
boolean isMirrored = videoHelper.isMyVideoMirrored();
Rotate the local video
When the device orientation changes, call rotateMyVideo to update the orientation of the locally captured video, passing the new rotation angle.
ZoomVideoSDK.getInstance().videoHelper.rotateMyVideo(rotation)
ZoomVideoSDK.getInstance().getVideoHelper().rotateMyVideo(rotation);
A common pattern is to listen for orientation changes (for example, via the Android OrientationEventListener or by overriding onConfigurationChanged) and call rotateMyVideo with the new value.
Flashlight
You can control the device flashlight from the SDK on devices that support it. Check support before calling the toggle.
val videoHelper = ZoomVideoSDK.getInstance().videoHelper
if (videoHelper.isSupportFlashlight) {
videoHelper.turnOnOrOffFlashlight(true)
}
val isOn = videoHelper.isFlashlightOn
ZoomVideoSDKVideoHelper videoHelper = ZoomVideoSDK.getInstance().getVideoHelper();
if (videoHelper.isSupportFlashlight()) {
videoHelper.turnOnOrOffFlashlight(true);
}
boolean isOn = videoHelper.isFlashlightOn();
Aspect ratio of the local video
By default, the SDK renders video at the source aspect ratio. To force a fixed aspect, use enableOriginalAspectRatio(boolean). Check the current setting with isOriginalAspectRatioEnabled().
ZoomVideoSDK.getInstance().videoHelper.enableOriginalAspectRatio(true)
ZoomVideoSDK.getInstance().getVideoHelper().enableOriginalAspectRatio(true);
Alpha channel mode
Alpha channel mode lets the SDK render video with a transparent background, useful for compositing a user's video over other UI content (for example, a presenter video overlaid on a slide deck). Both the device hardware and the current session state gate this feature, so capability-check before enabling.
isDeviceSupportAlphaChannelMode(): does the device hardware support it? Check once.canEnableAlphaChannelMode(): can the mode be toggled in the current session state? Check before each enable call.enableAlphaChannelMode(boolean): turn the mode on or off.isAlphaChannelModeEnabled(): read the current state.
val videoHelper = ZoomVideoSDK.getInstance().videoHelper
if (videoHelper.isDeviceSupportAlphaChannelMode && videoHelper.canEnableAlphaChannelMode()) {
videoHelper.enableAlphaChannelMode(true)
}
val isOn = videoHelper.isAlphaChannelModeEnabled
ZoomVideoSDKVideoHelper videoHelper = ZoomVideoSDK.getInstance().getVideoHelper();
if (videoHelper.isDeviceSupportAlphaChannelMode() && videoHelper.canEnableAlphaChannelMode()) {
videoHelper.enableAlphaChannelMode(true);
}
boolean isOn = videoHelper.isAlphaChannelModeEnabled();
The SDK fires onVideoAlphaChannelStatusChanged whenever the mode is toggled.