diff --git a/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerView.kt b/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerView.kt index 4576d046..cfde71f5 100644 --- a/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerView.kt +++ b/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerView.kt @@ -133,9 +133,15 @@ class RNPlayerView( override fun onStop(owner: LifecycleOwner) { playerInMediaSessionService = null + removePlayerForBackgroundPlayback() + playerView?.onStop() + } + + override fun onDestroy(owner: LifecycleOwner) = dispose() - // Remove player from view so it does not get paused when entering background - // when background playback is enabled + // When background playback is enabled, + // remove player from view so it does not get paused when entering background + private fun removePlayerForBackgroundPlayback() { playerView?.player?.let { if (!enableBackgroundPlayback) { return @@ -147,11 +153,7 @@ class RNPlayerView( playerInMediaSessionService = it playerView?.player = null } - - playerView?.onStop() } - - override fun onDestroy(owner: LifecycleOwner) = dispose() } init {