diff --git a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt index 12aea12ef..05f4d25e5 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt @@ -167,7 +167,7 @@ class MainActivity : BaseActivity() { } R.id.searchResultFragment -> { navController.popBackStack(R.id.searchFragment, true) || - navController.popBackStack() + navController.popBackStack() } else -> { navController.popBackStack() diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index fdd295f8a..a038814e7 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -919,11 +919,6 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { } override fun onPlaybackStateChanged(playbackState: Int) { - exoPlayerView.keepScreenOn = !( - playbackState == Player.STATE_IDLE || - playbackState == Player.STATE_ENDED - ) - // save the watch position to the database // only called when the position is unequal to 0, otherwise it would become reset // before the player can seek to the saved position from videos of the queue diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index c740b5d78..568b5ef5d 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -177,6 +177,15 @@ internal class CustomExoPlayerView( updatePlayPauseButton() } } + + override fun onPlaybackStateChanged(playbackState: Int) { + // keep the screen on if the video is not ended or paused + keepScreenOn = !( + listOf(Player.STATE_IDLE, Player.STATE_ENDED) + .contains(playbackState) + ) + super.onPlaybackStateChanged(playbackState) + } }) playerViewModel?.isFullscreen?.observe(viewLifecycleOwner!!) { isFullscreen ->