Skip to main content
Version: Android SDK v1.3.0

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

Direction

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

camera.direction = CameraDirection.Front // switch to front
camera.direction = CameraDirection.Back // switch to back
camera.toggleDirection() // switch to the other one

You can observe the direction value with an observer:

camera.addObserver(object : Camera.Observer {
override fun onDirectionChanged(direction: CameraDirection) {
// 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 an observer:

camera.addObserver(object : Camera.Observer {
override fun onFlashChanged(flash: CameraFlash) {
// 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 an observer:

camera.addObserver(object : Camera.Observer {
override fun onZoomChanged(zoom: Float) {
// Handle change.
}
})