set Observer
Registers an observer to monitor the player's readiness state.
Allows integrators to react to changes in the player's readiness (e.g., when it becomes fully initialized or loses its connection) in a lifecycle-aware manner. The observer will be notified whenever the readiness state changes.
Example usage:
SurfaceView surfaceView = findViewById(R.id.surface_view);
SandboxedPlayer player = new SandboxedPlayer(context, surfaceView);
player.setObserver(this, isReady -> {
if (isReady) {
player.setPlaybackSpeed(1.5f);
Log.d("Client", "Player ready, speed set");
} else {
Log.d("Client", "Player not ready");
}
});
Content copied to clipboard
Parameters
owner
The LifecycleOwner (e.g., Activity or Fragment) that controls the observer's lifecycle. The observer will automatically stop receiving updates when the owner is destroyed.
observer
The Observer to receive updates when the player's readiness state changes. The Boolean value indicates if the player is ready (true) or not (false).