Skip to main content
Version: Android SDK v1.2.1

Camera

Some VideoKit components (like Recorder or StreamHost) will automatically open a connection with the camera sensor available on the device. We offer control over some core camera features through the Camera interface and its listeners.

You can typically access the camera object from the parent component, for example:

val camera = recorder.camera // from recorder module
val camera = streamHost.camera // from live stream module

Facing

You can choose which sensor is active by changing the camera facing value:

camera.facing = CameraFacing.FRONT // switch to front
camera.facing = CameraFacing.BACK // switch to back
camera.toggleFacing() // switch to the other one

You can observe the facing value with a listener:

camera.addListener(object : CameraListener {
override fun onFacingChanged(@CameraFacing.Value facing: Int) {
// Handle change.
}
})

Flash

You can control the flash behavior by changing the camera flash value:

camera.flash = CameraFlash.ON // turn torch on
camera.flash = CameraFlash.OFF // turn it on
camera.toggleFlash() // switch to the other one

You can observe the flash value with a listener:

camera.addListener(object : CameraListener {
override fun onFlashChanged(@CameraFlash.Value flash: Int) {
// Handle change.
}
})

Zoom

You can control the sensor zoom by changing the camera zoom value. This value goes from 0 to 1, where 0 means no zoom and 1 means that maximum zoom will been applied.

camera.zoom = 0F // zoom out
camera.zoom = 1F // zoom in as much as possible

You can observe the zoom value with a listener:

camera.addListener(object : CameraListener {
override fun onZoomChanged(zoom: Float) {
// Handle change.
}
})