mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
Merge pull request #5587 from manish99verma/Give-up-timer-on-long-buffering
feat: stop loading after long unsuccessful buffering
This commit is contained in:
commit
f9fa732cb4
@ -52,7 +52,12 @@ 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
|
private const val MINIMUM_BUFFER_DURATION = 1000 * 10 // exo default is 50s
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum amount of time to wait until the video starts playing: 10 minutes
|
||||||
|
*/
|
||||||
|
const val MAX_BUFFER_DELAY = 10 * 60 * 1000L
|
||||||
|
|
||||||
val repeatModes = listOf(
|
val repeatModes = listOf(
|
||||||
Player.REPEAT_MODE_OFF to R.string.repeat_mode_none,
|
Player.REPEAT_MODE_OFF to R.string.repeat_mode_none,
|
||||||
|
@ -254,6 +254,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
// schedule task to save the watch position each second
|
// schedule task to save the watch position each second
|
||||||
private var watchPositionTimer: Timer? = null
|
private var watchPositionTimer: Timer? = null
|
||||||
|
|
||||||
|
private var bufferingTimeoutTask: Runnable? = null
|
||||||
|
|
||||||
private val playerListener = object : Player.Listener {
|
private val playerListener = object : Player.Listener {
|
||||||
override fun onIsPlayingChanged(isPlaying: Boolean) {
|
override fun onIsPlayingChanged(isPlaying: Boolean) {
|
||||||
if (PlayerHelper.pipEnabled) {
|
if (PlayerHelper.pipEnabled) {
|
||||||
@ -347,6 +349,20 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
// finish PiP by finishing the activity
|
// finish PiP by finishing the activity
|
||||||
activity?.finish()
|
activity?.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Buffering timeout after 10 Minutes
|
||||||
|
if (playbackState == Player.STATE_BUFFERING) {
|
||||||
|
if (bufferingTimeoutTask == null) {
|
||||||
|
bufferingTimeoutTask = Runnable {
|
||||||
|
exoPlayer.pause()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.postDelayed(bufferingTimeoutTask!!, PlayerHelper.MAX_BUFFER_DELAY)
|
||||||
|
} else {
|
||||||
|
bufferingTimeoutTask?.let { handler.removeCallbacks(it) }
|
||||||
|
}
|
||||||
|
|
||||||
super.onPlaybackStateChanged(playbackState)
|
super.onPlaybackStateChanged(playbackState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user