Created
October 5, 2021 21:00
-
-
Save Skyyo/e64d9bce5fa5bf3a090f293109a8ede9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DisposableEffect(exoPlayer) { | |
val lifecycleObserver = LifecycleEventObserver { _, event -> | |
if (playingItemIndex == null) return@LifecycleEventObserver | |
when (event) { | |
Lifecycle.Event.ON_START -> exoPlayer.play() | |
Lifecycle.Event.ON_STOP -> exoPlayer.pause() | |
} | |
} | |
lifecycleOwner.lifecycle.addObserver(lifecycleObserver) | |
onDispose { | |
lifecycleOwner.lifecycle.removeObserver(lifecycleObserver) | |
exoPlayer.release() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment