Rendering Live View
Access the Player to show the Live View
To render the Live Stream or access the player(s) to show the Live View, The following method can be used:
viewModelScope.launch {
client.players.collectLatest { players ->
// players is a List<TextureViewRenderer?> - one renderer per camera sensor. Most cameras
// expose a single sensor, so this list will usually have one element. Each renderer can be
// inflated into any view used to render the live view.
}
}
// In Jetpack compose you can do client.players.collectStateWithLifecycle()
Checking if the Live View Stream loaded
One you have created the LiveStreamClient the camera should have already woken up if battery cam and start to live stream.
To get the status if the camera has started streaming, The following can be used:
viewModelScope.launch {
client.hasLoadedStream.collectLatest { hasLoaded ->
// hasLoaded will report true as soon as the first video frame is received.
}
}
Observing the status of Live View
To observer the status of the Live View, The following observer can be used:
viewModelScope.launch {
client.status.collectLatest { status ->
// CONNECTING, STARTED (first frame rendered), FAILED(message) — recoverable —
// or AUTO_DISCONNECT (the autoDisconnectAfter timer fired; the client closes itself)
}
}
If a failure occurs while the stream is running, the status moves to FAILED rather than bringing down the app, so treat FAILED as a state to recover from.
HD only
toggleHdOnly() flips the camera’s bitrate mode between HD and Auto through the backend (in Auto the camera, not the SDK, adapts). It is a toggle — call it again to return to Auto. isHdOnly updates only when the request succeeds; a failed request moves status to FAILED:
client.toggleHdOnly()
Keeping an MCU camera awake
On MCU cameras (device.isMcuSupported) the SDK confirms the camera is awake when connecting. keepAwake() sends one wake_up message on such cameras and does nothing on others:
client.keepAwake()
Pausing auto-disconnect
Recording, talkback (enableMic) and the siren pause the autoDisconnectAfter timer automatically and restart it when they stop. Call these only for interactions the SDK does not know about; enableAutoDisconnect() restarts the full interval (and is a no-op when autoDisconnectAfter == 0):
client.disableAutoDisconnect()
client.enableAutoDisconnect()