Merge pull request #1392 from VenusIsJaded/fix/exoplayer-unpausing-when-returning-to-foreground

fix: ExoPlayer unpausing when leaving the app and coming back
This commit is contained in:
Nayif 2026-06-22 17:59:50 +05:30 committed by GitHub
commit 36c5919407
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -90,6 +90,7 @@ actual fun PlatformPlayerSurface(
val lifecycleOwner = LocalLifecycleOwner.current
val latestOnSnapshot = rememberUpdatedState(onSnapshot)
val latestOnError = rememberUpdatedState(onError)
val latestPlayWhenReady = rememberUpdatedState(playWhenReady)
val coroutineScope = rememberCoroutineScope()
val playerSettings = remember {
@ -385,7 +386,7 @@ actual fun PlatformPlayerSurface(
val activity = context.findActivity()
val observer = LifecycleEventObserver { _, event ->
when (event) {
Lifecycle.Event.ON_START -> exoPlayer.playWhenReady = playWhenReady
Lifecycle.Event.ON_START -> exoPlayer.playWhenReady = latestPlayWhenReady.value
Lifecycle.Event.ON_STOP -> {
val isInPictureInPicture =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity?.isInPictureInPictureMode == true
@ -405,7 +406,7 @@ actual fun PlatformPlayerSurface(
}
LaunchedEffect(exoPlayer, playWhenReady) {
exoPlayer.playWhenReady = playWhenReady
exoPlayer.playWhenReady = latestPlayWhenReady.value
syncPlayerViewKeepScreenOn()
latestOnSnapshot.value(exoPlayer.snapshot())
}