@@ -76,6 +76,7 @@ import androidx.compose.ui.graphics.graphicsLayer
76
76
import androidx.compose.ui.graphics.vector.ImageVector
77
77
import androidx.compose.ui.graphics.vector.rememberVectorPainter
78
78
import androidx.compose.ui.layout.onLayoutRectChanged
79
+ import androidx.compose.ui.layout.onVisibilityChanged
79
80
import androidx.compose.ui.platform.LocalContext
80
81
import androidx.compose.ui.platform.LocalInspectionMode
81
82
import androidx.compose.ui.platform.LocalView
@@ -541,9 +542,10 @@ private fun VideoPlayer(
541
542
Modifier
542
543
.background(MaterialTheme .colorScheme.surfaceContainerLowest)
543
544
.onVisibilityChanged(
544
- containerWidth = LocalView .current.width,
545
- containerHeight = LocalView .current.height,
546
- ) { fullyVisible -> videoFullyOnScreen = fullyVisible }
545
+ minDurationMs = 100 ,
546
+ minFractionVisible = 1f
547
+ )
548
+ { fullyVisible -> videoFullyOnScreen = fullyVisible }
547
549
.then(modifier),
548
550
) {
549
551
player?.let { currentPlayer ->
@@ -579,16 +581,3 @@ private fun VideoPlayer(
579
581
}
580
582
}
581
583
}
582
-
583
- fun Modifier.onVisibilityChanged (
584
- containerWidth : Int ,
585
- containerHeight : Int ,
586
- onChanged : (visible: Boolean ) -> Unit ,
587
- ) = this then Modifier .onLayoutRectChanged(100 , 0 ) { layoutBounds ->
588
- onChanged(
589
- layoutBounds.boundsInRoot.top > 0 &&
590
- layoutBounds.boundsInRoot.bottom < containerHeight &&
591
- layoutBounds.boundsInRoot.left > 0 &&
592
- layoutBounds.boundsInRoot.right < containerWidth,
593
- )
594
- }
0 commit comments