Skip to content

Commit

Permalink
Export bg playback handling in a func for onStop
Browse files Browse the repository at this point in the history
  • Loading branch information
123mpozzi committed Nov 6, 2024
1 parent 36e88e6 commit 8d2fdb3
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -147,11 +153,7 @@ class RNPlayerView(
playerInMediaSessionService = it
playerView?.player = null
}

playerView?.onStop()
}

override fun onDestroy(owner: LifecycleOwner) = dispose()
}

init {
Expand Down

0 comments on commit 8d2fdb3

Please sign in to comment.