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 54377e6ff..79b5d531e 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 @@ -172,17 +172,9 @@ internal class CustomExoPlayerView( ) ) { updatePlayPauseButton() + updateScreenOnState() } } - - 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 -> @@ -194,6 +186,11 @@ internal class CustomExoPlayerView( } } + private fun updateScreenOnState() { + // keep screen on if the video is playing + keepScreenOn = player?.isPlaying == true + } + private fun updatePlayPauseButton() { binding.playPauseBTN.setImageResource( when {