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 ->
    // status is updated when ever something happens to the connection the possible values
    // are CONNECTING, STARTED or FAILED
  }
}

This site uses Just the Docs, a documentation theme for Jekyll.