mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
buffering goal
This commit is contained in:
parent
05bc010ef1
commit
f486595ab5
@ -32,7 +32,7 @@ class ChaptersAdapter(
|
||||
chapterTitle.text = chapter.title
|
||||
|
||||
holder.v.setOnClickListener {
|
||||
val chapterStart = chapter.start!!.toLong() * 1000 // multiply by thousand for ms -> s
|
||||
val chapterStart = chapter.start!!.toLong() * 1000 // s -> ms
|
||||
exoPlayer.seekTo(chapterStart)
|
||||
}
|
||||
}
|
||||
|
@ -828,6 +828,10 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun createExoPlayer(view: View) {
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
val playbackSpeed = sharedPreferences.getString("playback_speed", "1F")?.toFloat()
|
||||
val bufferingGoal = sharedPreferences.getString("buffering_goal", "50")?.toInt()!!
|
||||
|
||||
val cronetEngine: CronetEngine = CronetHelper.getCronetEngine()
|
||||
val cronetDataSourceFactory: CronetDataSource.Factory =
|
||||
CronetDataSource.Factory(cronetEngine, Executors.newCachedThreadPool())
|
||||
@ -847,6 +851,12 @@ class PlayerFragment : Fragment() {
|
||||
val loadControl = DefaultLoadControl.Builder()
|
||||
// cache the last three minutes
|
||||
.setBackBuffer(1000 * 60 * 3, true)
|
||||
.setBufferDurationsMs(
|
||||
DefaultLoadControl.DEFAULT_MIN_BUFFER_MS,
|
||||
bufferingGoal * 1000, // buffering goal, s -> ms
|
||||
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS,
|
||||
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS
|
||||
)
|
||||
.build()
|
||||
|
||||
exoPlayer = ExoPlayer.Builder(view.context)
|
||||
@ -858,8 +868,6 @@ class PlayerFragment : Fragment() {
|
||||
|
||||
exoPlayer.setAudioAttributes(audioAttributes, true)
|
||||
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
val playbackSpeed = sharedPreferences.getString("playback_speed", "1F")?.toFloat()
|
||||
exoPlayer.setPlaybackSpeed(playbackSpeed!!)
|
||||
}
|
||||
|
||||
|
10
app/src/main/res/drawable/ic_timelapse.xml
Normal file
10
app/src/main/res/drawable/ic_timelapse.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/black"
|
||||
android:pathData="M16.24,7.76C15.07,6.59 13.54,6 12,6v6l-4.24,4.24c2.34,2.34 6.14,2.34 8.49,0 2.34,-2.34 2.34,-6.14 -0.01,-8.48zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
|
||||
</vector>
|
@ -659,4 +659,12 @@
|
||||
<item>sdcard</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="bufferingGoal">
|
||||
<item>50</item>
|
||||
<item>100</item>
|
||||
<item>200</item>
|
||||
<item>300</item>
|
||||
<item>450</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
@ -181,4 +181,6 @@
|
||||
<string name="related_streams_summary">Show related streams to videos.</string>
|
||||
<string name="show_chapters">Show chapters</string>
|
||||
<string name="hide_chapters">Hide chapters</string>
|
||||
<string name="buffering_goal">Buffering goal</string>
|
||||
<string name="buffering_goal_summary">The amount of seconds videos get preloaded at maximum.</string>
|
||||
</resources>
|
||||
|
@ -22,6 +22,15 @@
|
||||
app:title="@string/playback_speed"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_timelapse"
|
||||
app:defaultValue="50"
|
||||
app:entries="@array/bufferingGoal"
|
||||
app:entryValues="@array/bufferingGoal"
|
||||
app:key="buffering_goal"
|
||||
app:title="@string/buffering_goal"
|
||||
app:summary="@string/buffering_goal_summary" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/downloads">
|
||||
|
Loading…
x
Reference in New Issue
Block a user