mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
fix: allow pausing when buffer is less than min buffer
Fixes a regression in 42d081f04e132bc4ff5dbf408c596bd1f6927992. The player should pause when it is unable to play, as long as the buffered time is less than the minimum buffer needed for playing.
This commit is contained in:
parent
98334270de
commit
adb051e24f
@ -1,6 +1,7 @@
|
|||||||
package com.github.libretube.extensions
|
package com.github.libretube.extensions
|
||||||
|
|
||||||
import androidx.media3.common.Player
|
import androidx.media3.common.Player
|
||||||
|
import com.github.libretube.helpers.PlayerHelper
|
||||||
|
|
||||||
fun Player.togglePlayPauseState() {
|
fun Player.togglePlayPauseState() {
|
||||||
when {
|
when {
|
||||||
@ -13,7 +14,7 @@ fun Player.togglePlayPauseState() {
|
|||||||
seekTo(0)
|
seekTo(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
!isPlaying && totalBufferedDuration > 0 -> play()
|
!isPlaying && totalBufferedDuration > PlayerHelper.MINIMUM_BUFFER_DURATION -> play()
|
||||||
else -> pause()
|
else -> pause()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ object PlayerHelper {
|
|||||||
const val CONTROL_TYPE = "control_type"
|
const val CONTROL_TYPE = "control_type"
|
||||||
const val SPONSOR_HIGHLIGHT_CATEGORY = "poi_highlight"
|
const val SPONSOR_HIGHLIGHT_CATEGORY = "poi_highlight"
|
||||||
const val ROLE_FLAG_AUTO_GEN_SUBTITLE = C.ROLE_FLAG_SUPPLEMENTARY
|
const val ROLE_FLAG_AUTO_GEN_SUBTITLE = C.ROLE_FLAG_SUPPLEMENTARY
|
||||||
|
const val MINIMUM_BUFFER_DURATION = 1000 * 10 // exo default is 50s
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of all categories that are not disabled by default
|
* A list of all categories that are not disabled by default
|
||||||
@ -437,7 +438,7 @@ object PlayerHelper {
|
|||||||
// cache the last three minutes
|
// cache the last three minutes
|
||||||
.setBackBuffer(1000 * 60 * 3, true)
|
.setBackBuffer(1000 * 60 * 3, true)
|
||||||
.setBufferDurationsMs(
|
.setBufferDurationsMs(
|
||||||
1000 * 10, // exo default is 50s
|
MINIMUM_BUFFER_DURATION,
|
||||||
bufferingGoal,
|
bufferingGoal,
|
||||||
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS,
|
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS,
|
||||||
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS
|
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user