Merge pull request #4983 from Bnyro/master

fix: can't resume playback at end of video
This commit is contained in:
Bnyro 2023-10-14 17:34:01 +02:00 committed by GitHub
commit a89bdf45a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,8 @@ 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()
@ -14,7 +16,7 @@ fun Player.togglePlayPauseState() {
seekTo(0)
}
!isPlaying && totalBufferedDuration > PlayerHelper.MINIMUM_BUFFER_DURATION -> play()
!isPlaying && minBufferingReached -> play()
else -> pause()
}
}