Commit 88fc95b 1 parent af80d96 commit 88fc95b Copy full SHA for 88fc95b
File tree 5 files changed +48
-0
lines changed
java/org/schabi/newpipe/player/helper
5 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -31,11 +31,13 @@ public class PlayerDataSource {
31
31
private static final int MANIFEST_MINIMUM_RETRY = 5 ;
32
32
private static final int EXTRACTOR_MINIMUM_RETRY = Integer .MAX_VALUE ;
33
33
34
+ private final int continueLoadingCheckIntervalBytes ;
34
35
private final DataSource .Factory cacheDataSourceFactory ;
35
36
private final DataSource .Factory cachelessDataSourceFactory ;
36
37
37
38
public PlayerDataSource (@ NonNull final Context context , @ NonNull final String userAgent ,
38
39
@ NonNull final TransferListener transferListener ) {
40
+ continueLoadingCheckIntervalBytes = PlayerHelper .getProgressiveLoadIntervalBytes (context );
39
41
cacheDataSourceFactory = new CacheFactory (context , userAgent , transferListener );
40
42
cachelessDataSourceFactory
41
43
= new DefaultDataSourceFactory (context , userAgent , transferListener );
@@ -91,6 +93,7 @@ public DashMediaSource.Factory getDashMediaSourceFactory() {
91
93
92
94
public ProgressiveMediaSource .Factory getExtractorMediaSourceFactory () {
93
95
return new ProgressiveMediaSource .Factory (cacheDataSourceFactory )
96
+ .setContinueLoadingCheckIntervalBytes (continueLoadingCheckIntervalBytes )
94
97
.setLoadErrorHandlingPolicy (
95
98
new DefaultLoadErrorHandlingPolicy (EXTRACTOR_MINIMUM_RETRY ));
96
99
}
Original file line number Diff line number Diff line change 34
34
import com .google .android .exoplayer2 .PlaybackParameters ;
35
35
import com .google .android .exoplayer2 .Player .RepeatMode ;
36
36
import com .google .android .exoplayer2 .SeekParameters ;
37
+ import com .google .android .exoplayer2 .source .ProgressiveMediaSource ;
37
38
import com .google .android .exoplayer2 .trackselection .AdaptiveTrackSelection ;
38
39
import com .google .android .exoplayer2 .trackselection .ExoTrackSelection ;
39
40
import com .google .android .exoplayer2 .ui .AspectRatioFrameLayout ;
@@ -391,6 +392,19 @@ public static boolean globalScreenOrientationLocked(final Context context) {
391
392
context .getContentResolver (), Settings .System .ACCELEROMETER_ROTATION , 0 ) == 0 ;
392
393
}
393
394
395
+ public static int getProgressiveLoadIntervalBytes (@ NonNull final Context context ) {
396
+ final String preferredIntervalBytes = getPreferences (context ).getString (
397
+ context .getString (R .string .progressive_load_interval_key ),
398
+ context .getString (R .string .progressive_load_interval_default_value ));
399
+
400
+ if (context .getString (R .string .progressive_load_interval_default_value )
401
+ .equals (preferredIntervalBytes )) {
402
+ return ProgressiveMediaSource .DEFAULT_LOADING_CHECK_INTERVAL_BYTES ;
403
+ }
404
+ // Keeping the same KiB unit used by ProgressiveMediaSource
405
+ return Integer .parseInt (preferredIntervalBytes ) * 1024 ;
406
+ }
407
+
394
408
////////////////////////////////////////////////////////////////////////////
395
409
// Private helpers
396
410
////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change 55
55
<item >30000</item >
56
56
</string-array >
57
57
58
+ <string name =" progressive_load_interval_key" >progressive_load_interval</string >
59
+ <string name =" progressive_load_interval_default_value" >default</string >
60
+ <string-array name =" progressive_load_interval_descriptions" >
61
+ <item >1 KiB</item >
62
+ <item >16 KiB</item >
63
+ <item >64 KiB</item >
64
+ <item >256 KiB</item >
65
+ <item >@string/progressive_load_interval_default</item >
66
+ </string-array >
67
+ <string-array name =" progressive_load_interval_values" >
68
+ <item >1</item >
69
+ <item >16</item >
70
+ <item >64</item >
71
+ <item >256</item >
72
+ <item >default</item >
73
+ </string-array >
74
+
58
75
<string name =" minimize_on_exit_key" >minimize_on_exit_key</string >
59
76
<string name =" minimize_on_exit_value" >@string/minimize_on_exit_background_key</string >
60
77
<string name =" minimize_on_exit_none_key" >minimize_on_exit_none_key</string >
Original file line number Diff line number Diff line change 78
78
<string name =" use_inexact_seek_title" >Use fast inexact seek</string >
79
79
<string name =" use_inexact_seek_summary" >Inexact seek allows the player to seek to positions faster with reduced precision. Seeking for 5, 15 or 25 seconds doesn\'t work with this</string >
80
80
<string name =" seek_duration_title" >Fast-forward/-rewind seek duration</string >
81
+ <string name =" progressive_load_interval_title" >Playback load interval size</string >
82
+ <string name =" progressive_load_interval_summary" >Change the load interval size (currently at %s). A lower value may speed up initial video loading. Changes require a player restart.</string >
81
83
<string name =" clear_queue_confirmation_title" >Ask for confirmation before clearing a queue</string >
82
84
<string name =" clear_queue_confirmation_summary" >Switching from one player to another may replace your queue</string >
83
85
<string name =" clear_queue_confirmation_description" >The active player queue will be replaced</string >
702
704
<!-- Show Channel Details -->
703
705
<string name =" error_show_channel_details" >Error at Show Channel Details</string >
704
706
<string name =" loading_channel_details" >Loading Channel Details…</string >
707
+ <!-- Progressive Load Interval -->
708
+ <string name =" progressive_load_interval_default" >ExoPlayer default</string >
705
709
</resources >
Original file line number Diff line number Diff line change 206
206
app : singleLineTitle =" false"
207
207
app : iconSpaceReserved =" false" />
208
208
209
+ <ListPreference
210
+ android : defaultValue =" @string/progressive_load_interval_default_value"
211
+ android : entries =" @array/progressive_load_interval_descriptions"
212
+ android : entryValues =" @array/progressive_load_interval_values"
213
+ android : key =" @string/progressive_load_interval_key"
214
+ android : summary =" @string/progressive_load_interval_summary"
215
+ android : title =" @string/progressive_load_interval_title"
216
+ app : singleLineTitle =" false"
217
+ app : iconSpaceReserved =" false" />
218
+
209
219
<SwitchPreferenceCompat
210
220
android : defaultValue =" false"
211
221
android : key =" @string/clear_queue_confirmation_key"
You can’t perform that action at this time.
0 commit comments