mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
add loading interval size option
This commit is contained in:
parent
ca86cb1768
commit
dc5a7d02d0
@ -78,6 +78,7 @@ object PreferenceKeys {
|
|||||||
const val PLAYER_RESIZE_MODE = "player_resize_mode"
|
const val PLAYER_RESIZE_MODE = "player_resize_mode"
|
||||||
const val SB_SKIP_MANUALLY = "sb_skip_manually_key"
|
const val SB_SKIP_MANUALLY = "sb_skip_manually_key"
|
||||||
const val LIMIT_HLS = "limit_hls"
|
const val LIMIT_HLS = "limit_hls"
|
||||||
|
const val PROGRESSIVE_LOADING_INTERVAL_SIZE = "progressive_loading_interval"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Background mode
|
* Background mode
|
||||||
|
@ -167,6 +167,7 @@ class PlayerFragment : BaseFragment() {
|
|||||||
private var skipButtonsEnabled = false
|
private var skipButtonsEnabled = false
|
||||||
private var pipEnabled = true
|
private var pipEnabled = true
|
||||||
private var skipSegmentsManually = false
|
private var skipSegmentsManually = false
|
||||||
|
private var progressiveLoadingIntervalSize = "64"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* for autoplay
|
* for autoplay
|
||||||
@ -339,6 +340,11 @@ class PlayerFragment : BaseFragment() {
|
|||||||
PreferenceKeys.SB_SKIP_MANUALLY,
|
PreferenceKeys.SB_SKIP_MANUALLY,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
progressiveLoadingIntervalSize = PreferenceHelper.getString(
|
||||||
|
PreferenceKeys.PROGRESSIVE_LOADING_INTERVAL_SIZE,
|
||||||
|
"64"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@ -467,7 +473,7 @@ class PlayerFragment : BaseFragment() {
|
|||||||
videosNameArray[which] == "LBRY HLS"
|
videosNameArray[which] == "LBRY HLS"
|
||||||
) {
|
) {
|
||||||
// set the progressive media source
|
// set the progressive media source
|
||||||
setProgressiveMediaSource(videosUrlArray[which])
|
setHLSMediaSource(videosUrlArray[which])
|
||||||
} else {
|
} else {
|
||||||
val videoUri = videosUrlArray[which]
|
val videoUri = videosUrlArray[which]
|
||||||
val audioUrl =
|
val audioUrl =
|
||||||
@ -1192,7 +1198,7 @@ class PlayerFragment : BaseFragment() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the currently played chapter
|
* Get the name of the currently played chapter
|
||||||
*/
|
*/
|
||||||
private fun getCurrentChapterIndex(): Int {
|
private fun getCurrentChapterIndex(): Int {
|
||||||
val currentPosition = exoPlayer.currentPosition
|
val currentPosition = exoPlayer.currentPosition
|
||||||
var chapterIndex = 0
|
var chapterIndex = 0
|
||||||
@ -1211,24 +1217,35 @@ class PlayerFragment : BaseFragment() {
|
|||||||
videoUri: Uri,
|
videoUri: Uri,
|
||||||
audioUrl: String
|
audioUrl: String
|
||||||
) {
|
) {
|
||||||
|
val checkIntervalSize = when (progressiveLoadingIntervalSize) {
|
||||||
|
"default" -> ProgressiveMediaSource.DEFAULT_LOADING_CHECK_INTERVAL_BYTES
|
||||||
|
else -> progressiveLoadingIntervalSize.toInt() * 1024
|
||||||
|
}
|
||||||
|
|
||||||
val dataSourceFactory: DataSource.Factory =
|
val dataSourceFactory: DataSource.Factory =
|
||||||
DefaultHttpDataSource.Factory()
|
DefaultHttpDataSource.Factory()
|
||||||
|
|
||||||
val videoItem: MediaItem = MediaItem.Builder()
|
val videoItem: MediaItem = MediaItem.Builder()
|
||||||
.setUri(videoUri)
|
.setUri(videoUri)
|
||||||
.setSubtitleConfigurations(subtitle)
|
.setSubtitleConfigurations(subtitle)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val videoSource: MediaSource =
|
val videoSource: MediaSource =
|
||||||
DefaultMediaSourceFactory(dataSourceFactory)
|
ProgressiveMediaSource.Factory(dataSourceFactory)
|
||||||
|
.setContinueLoadingCheckIntervalBytes(checkIntervalSize)
|
||||||
.createMediaSource(videoItem)
|
.createMediaSource(videoItem)
|
||||||
|
|
||||||
val audioSource: MediaSource =
|
val audioSource: MediaSource =
|
||||||
ProgressiveMediaSource.Factory(dataSourceFactory)
|
ProgressiveMediaSource.Factory(dataSourceFactory)
|
||||||
|
.setContinueLoadingCheckIntervalBytes(checkIntervalSize)
|
||||||
.createMediaSource(fromUri(audioUrl))
|
.createMediaSource(fromUri(audioUrl))
|
||||||
|
|
||||||
val mergeSource: MediaSource =
|
val mergeSource: MediaSource =
|
||||||
MergingMediaSource(videoSource, audioSource)
|
MergingMediaSource(videoSource, audioSource)
|
||||||
exoPlayer.setMediaSource(mergeSource)
|
exoPlayer.setMediaSource(mergeSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setProgressiveMediaSource(uri: Uri) {
|
private fun setHLSMediaSource(uri: Uri) {
|
||||||
val mediaItem: MediaItem = MediaItem.Builder()
|
val mediaItem: MediaItem = MediaItem.Builder()
|
||||||
.setUri(uri)
|
.setUri(uri)
|
||||||
.setSubtitleConfigurations(subtitle)
|
.setSubtitleConfigurations(subtitle)
|
||||||
@ -1317,7 +1334,7 @@ class PlayerFragment : BaseFragment() {
|
|||||||
|
|
||||||
// if default resolution isn't set or available, use hls if available
|
// if default resolution isn't set or available, use hls if available
|
||||||
if (streams.hls != null) {
|
if (streams.hls != null) {
|
||||||
setProgressiveMediaSource(Uri.parse(streams.hls))
|
setHLSMediaSource(Uri.parse(streams.hls))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,4 +408,22 @@
|
|||||||
<item>512</item>
|
<item>512</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="loadingInterval">
|
||||||
|
<item>1KiB</item>
|
||||||
|
<item>16KiB</item>
|
||||||
|
<item>64KiB</item>
|
||||||
|
<item>128KiB</item>
|
||||||
|
<item>256KiB</item>
|
||||||
|
<item>@string/default_load_interval</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="loadingIntervalValues">
|
||||||
|
<item>1</item>
|
||||||
|
<item>16</item>
|
||||||
|
<item>64</item>
|
||||||
|
<item>128</item>
|
||||||
|
<item>256</item>
|
||||||
|
<item>default</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -334,6 +334,9 @@
|
|||||||
<string name="select_at_least_one">Please select at least one item</string>
|
<string name="select_at_least_one">Please select at least one item</string>
|
||||||
<string name="change_region">Trending seems to be unavailable for the current region. Please select another in the settings.</string>
|
<string name="change_region">Trending seems to be unavailable for the current region. Please select another in the settings.</string>
|
||||||
<string name="limit_hls">Limit HLS to 1080p</string>
|
<string name="limit_hls">Limit HLS to 1080p</string>
|
||||||
|
<string name="progressive_load_interval">Progressive load interval size</string>
|
||||||
|
<string name="progressive_load_interval_summary">A lower value may speed up initial video loading.</string>
|
||||||
|
<string name="default_load_interval">Default</string>
|
||||||
|
|
||||||
<!-- Notification channel strings -->
|
<!-- Notification channel strings -->
|
||||||
<string name="download_channel_name">Download Service</string>
|
<string name="download_channel_name">Download Service</string>
|
||||||
|
@ -72,6 +72,15 @@
|
|||||||
android:title="@string/limit_hls"
|
android:title="@string/limit_hls"
|
||||||
app:key="limit_hls" />
|
app:key="limit_hls" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:icon="@drawable/ic_loading"
|
||||||
|
app:defaultValue="64"
|
||||||
|
app:entries="@array/loadingInterval"
|
||||||
|
app:entryValues="@array/loadingIntervalValues"
|
||||||
|
app:key="progressive_loading_interval"
|
||||||
|
app:summary="@string/progressive_load_interval_summary"
|
||||||
|
app:title="@string/progressive_load_interval" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory app:title="@string/background_mode">
|
<PreferenceCategory app:title="@string/background_mode">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user