fix: video can't be resumed after pausing it

This commit is contained in:
Bnyro 2023-11-15 16:13:45 +01:00
parent f93f72e5a0
commit 5245e62f97
2 changed files with 2 additions and 11 deletions

View File

@ -1,11 +1,8 @@
package com.github.libretube.extensions
import androidx.media3.common.Player
import com.github.libretube.helpers.PlayerHelper
fun Player.togglePlayPauseState() {
val minBufferingReached = totalBufferedDuration >= PlayerHelper.MINIMUM_BUFFER_DURATION ||
currentPosition + PlayerHelper.MINIMUM_BUFFER_DURATION >= duration
when {
playerError != null -> {
prepare()
@ -16,7 +13,7 @@ fun Player.togglePlayPauseState() {
seekTo(0)
}
!isPlaying && minBufferingReached -> play()
!isPlaying -> play()
else -> pause()
}
}

View File

@ -625,13 +625,7 @@ open class CustomExoPlayerView(
}
override fun onDoubleTapCenterScreen() {
player?.let { player ->
if (player.isPlaying) {
player.pause()
} else {
player.play()
}
}
player?.togglePlayPauseState()
}
override fun onDoubleTapLeftScreen() {