Kotlin

Managing PiP Mode Changes

1. Update the UI When PiP Mode Changes

Override onPictureInPictureModeChanged to track PiP state and hide the local preview in the floating window (subscriber video remains):

Expose isInPipMode to Compose (for example with mutableStateOf) so the PiP button hides automatically.

2. Keep the Session Alive in PiP

Do not call session.onPause() while in PiP, or the call may pause when the user leaves the full-screen activity:

3. Clean Up Views in onStop

Remove publisher and subscriber views when the activity stops: