fix: can't resume playback at end of video

This commit is contained in:
Bnyro 2023-10-14 17:35:06 +02:00
parent a59633a726
commit 2f89bf3756

View File

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