Kotlin

Launching Picture-in-Picture

1. Add a Button to Enter Picture-in-Picture

Hide the button while already in PiP. Wire it from VideoCallScreen:

if (!isInPipMode) {
    Button(
        onClick = onEnterPictureInPicture,
        modifier = Modifier.align(Alignment.TopStart).padding(8.dp),
    ) {
        Text("Enter Picture-In-Picture")
    }
}

2. Enter PiP with Aspect Ratio and Device Checks

Use PictureInPictureParams on API 26+ and verify the device supports PiP:

Adjust Rational(width, height) to match your preferred PiP window shape (the sample uses portrait 9:16).