Keep the screen on while playing in the offline player

This commit is contained in:
Bnyro 2023-01-22 19:27:08 +01:00
parent f119e39a1e
commit ff6a0f1138
3 changed files with 10 additions and 6 deletions

View File

@ -167,7 +167,7 @@ class MainActivity : BaseActivity() {
}
R.id.searchResultFragment -> {
navController.popBackStack(R.id.searchFragment, true) ||
navController.popBackStack()
navController.popBackStack()
}
else -> {
navController.popBackStack()

View File

@ -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

View File

@ -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 ->