captureImage

open suspend fun captureImage(width: Int = 0, height: Int = 0, flash: CaptureFlash = CaptureFlash.OFF): String

Takes a still from your own camera and returns it base64-encoded, ready for an ImageView or an upload.

Local participant only, and only while the camera is on — the SDK caches frames just while the video encoder runs.

With CaptureFlash.ON the camera's flash unit is used when it has one; a front camera without one uses the ScreenFlash from VideoSDK.setScreenFlash, and with none set the image is captured unlit. The light stays on about half a second so the exposure can adjust, and is turned off even when the capture fails. The room and the published video keep running throughout.

Code Example:

lifecycleScope.launch {
val jpeg = room.localParticipant.captureImage(width = 1280, height = 720)
}

Return

the JPEG bytes, base64-encoded, with no data-URI prefix.

Parameters

width

maximum output width in pixels; 0, the default, keeps the camera's own.

height

maximum output height in pixels; 0, the default, keeps the camera's own.

flash

whether to light the subject. Defaults to CaptureFlash.OFF.

Throws

when called on a remote participant.

3062 when the camera is off, thrown only and never sent to onError — checked before any light turns on; 3069 when the capture itself failed, which is both sent to onError and thrown.