Rendering Live View

Access the Player to show the Live View

To render the Live Stream or access the player to show the Live View, The following method can be used:

viewModelScope.launch {
  client.player.collectLatest { player ->
    // The player is an instance of TextureViewRenderer which can be inflated to any view that can be used
    // to render the live view.
  }
}
// In Jetpack compose you can do client.player.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
  }
}