mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Keep screen on only while video is playing #2877
- Fixes Screen stays on when video is paused (no timeout)
This commit is contained in:
parent
326df3970a
commit
6795026a94
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user