Skip to content

Commit

Permalink
adding pip to snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicalMeghan committed Jan 30, 2024
1 parent 64f2642 commit dc01085
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fun EnterPiPThroughButton() {

// [START android_compose_pip_is_in_pip_mode]
@Composable
fun isInPipMode(): Boolean {
fun rememberIsInPipMode(): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val activity = LocalContext.current.findActivity()
var pipMode by remember { mutableStateOf(activity.isInPictureInPictureMode) }
Expand Down Expand Up @@ -143,7 +143,7 @@ fun ToggleUIBasedOnPiP(
modifier: Modifier = Modifier,
) {
// [START android_compose_pip_ui_toggle]
val inPipMode = isInPipMode()
val inPipMode = rememberIsInPipMode()

Column(modifier = modifier) {
// This text will only show up when the app is in PiP mode
Expand Down Expand Up @@ -262,7 +262,8 @@ fun PiPBuilderSetAspectRatio(
@RequiresApi(Build.VERSION_CODES.O)
@Composable
fun PlayerBroadcastReceiver(player: Player?) {
if (!isInPipMode() || player == null) {
val isInPipMode = rememberIsInPipMode()
if (!isInPipMode || player == null) {
// Broadcast receiver is only used if app is in PiP mode and player is non null
return
}
Expand Down

0 comments on commit dc01085

Please sign in to comment.