Core features

View as Markdown

The Video SDK for Android lets you programmatically control user video during a session: check video status, start video, stop video, and render one or many users. For switching, mirroring, rotating, and other per-device camera operations, see Camera controls.

Check whether video is on

To check whether a user has their video on, call isOn on videoStatus to get a boolean response indicating whether the user has their video on or not in the session.

val isVideoOn = user.videoCanvas.videoStatus.isOn

Start video

Start video by calling startVideo() on the VideoHelper. Be sure your app has been granted CAMERA permission before calling or the SDK can't capture from the camera.

val videoHelper = ZoomVideoSDK.getInstance().videoHelper
videoHelper.startVideo()

Stop video

Stop video by calling stopVideo() on the VideoHelper.

ZoomVideoSDK.getInstance().videoHelper.stopVideo()

Render a user's video

To render a user's video, get the user's ZoomVideoSDKVideoCanvas and subscribe a ZoomVideoSDKVideoView to it. The view can be created programmatically or declared in XML.

val videoView = ZoomVideoSDKVideoView(this)
val canvas = user.videoCanvas
canvas.subscribe(videoView, ZoomVideoSDKVideoAspect.ZoomVideoSDKVideoAspect_Original)

The aspect parameter controls how Zoom fits the video into the view.

TypeDescription
ZoomVideoSDKVideoAspect_OriginalDisplay video without any modifications.
ZoomVideoSDKVideoAspect_Full_FilledStretch the video to fill the canvas.
ZoomVideoSDKVideoAspect_LetterBoxAdd black bars (top/bottom or left/right) so the full frame is visible without cropping.
ZoomVideoSDKVideoAspect_PanAndScanCrop the frame to fill the canvas without bars.

For more on choosing an aspect mode and on responsive layouts, see Aspect ration and orientation.

Remove a user's video from a canvas

When a user leaves the session, or when you want to recycle a ZoomVideoSDKVideoView for a different user, unsubscribe from the canvas.

videoCanvas.unsubscribe(videoView)

Render multiple users

To render multiple users at once (gallery view), iterate over the users in the session and subscribe a ZoomVideoSDKVideoView for each. Respond to onUserJoin to add new users as they enter, and onUserLeave to unsubscribe.

override fun onUserJoin(userHelper: ZoomVideoSDKUserHelper, userList: MutableList<ZoomVideoSDKUser>) {
    userList.forEach { user ->
        val videoView = ZoomVideoSDKVideoView(this@MyActivity)
        user.videoCanvas.subscribe(videoView, ZoomVideoSDKVideoAspect.ZoomVideoSDKVideoAspect_Original)
        // add videoView to your gallery container
    }
}

override fun onUserLeave(userHelper: ZoomVideoSDKUserHelper, userList: MutableList<ZoomVideoSDKUser>) {
    userList.forEach { user ->
        // unsubscribe and remove the corresponding view from the container
    }
}

For grid layout, density recommendations, and pagination guidance, see Layout and density.