File tree Expand file tree Collapse file tree
java/org/schabi/newpipe/player/helper Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,11 +31,13 @@ public class PlayerDataSource {
3131 private static final int MANIFEST_MINIMUM_RETRY = 5 ;
3232 private static final int EXTRACTOR_MINIMUM_RETRY = Integer .MAX_VALUE ;
3333
34+ private final int continueLoadingCheckIntervalBytes ;
3435 private final DataSource .Factory cacheDataSourceFactory ;
3536 private final DataSource .Factory cachelessDataSourceFactory ;
3637
3738 public PlayerDataSource (@ NonNull final Context context , @ NonNull final String userAgent ,
3839 @ NonNull final TransferListener transferListener ) {
40+ continueLoadingCheckIntervalBytes = PlayerHelper .getProgressiveLoadIntervalBytes (context );
3941 cacheDataSourceFactory = new CacheFactory (context , userAgent , transferListener );
4042 cachelessDataSourceFactory
4143 = new DefaultDataSourceFactory (context , userAgent , transferListener );
@@ -91,6 +93,7 @@ public DashMediaSource.Factory getDashMediaSourceFactory() {
9193
9294 public ProgressiveMediaSource .Factory getExtractorMediaSourceFactory () {
9395 return new ProgressiveMediaSource .Factory (cacheDataSourceFactory )
96+ .setContinueLoadingCheckIntervalBytes (continueLoadingCheckIntervalBytes )
9497 .setLoadErrorHandlingPolicy (
9598 new DefaultLoadErrorHandlingPolicy (EXTRACTOR_MINIMUM_RETRY ));
9699 }
Original file line number Diff line number Diff line change 3434import com .google .android .exoplayer2 .PlaybackParameters ;
3535import com .google .android .exoplayer2 .Player .RepeatMode ;
3636import com .google .android .exoplayer2 .SeekParameters ;
37+ import com .google .android .exoplayer2 .source .ProgressiveMediaSource ;
3738import com .google .android .exoplayer2 .trackselection .AdaptiveTrackSelection ;
3839import com .google .android .exoplayer2 .trackselection .ExoTrackSelection ;
3940import com .google .android .exoplayer2 .ui .AspectRatioFrameLayout ;
@@ -391,6 +392,19 @@ public static boolean globalScreenOrientationLocked(final Context context) {
391392 context .getContentResolver (), Settings .System .ACCELEROMETER_ROTATION , 0 ) == 0 ;
392393 }
393394
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+
394408 ////////////////////////////////////////////////////////////////////////////
395409 // Private helpers
396410 ////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change 5555 <item >30000</item >
5656 </string-array >
5757
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+
5875 <string name =" minimize_on_exit_key" >minimize_on_exit_key</string >
5976 <string name =" minimize_on_exit_value" >@string/minimize_on_exit_background_key</string >
6077 <string name =" minimize_on_exit_none_key" >minimize_on_exit_none_key</string >
Original file line number Diff line number Diff line change 7878 <string name =" use_inexact_seek_title" >Use fast inexact seek</string >
7979 <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 >
8080 <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 %s). A lower value may speed up initial video loading. Changes require a player restart.</string >
8183 <string name =" clear_queue_confirmation_title" >Ask for confirmation before clearing a queue</string >
8284 <string name =" clear_queue_confirmation_summary" >Switching from one player to another may replace your queue</string >
8385 <string name =" clear_queue_confirmation_description" >The active player queue will be replaced</string >
717719 <!-- Show Channel Details -->
718720 <string name =" error_show_channel_details" >Error at Show Channel Details</string >
719721 <string name =" loading_channel_details" >Loading Channel Details…</string >
722+ <!-- Progressive Load Interval -->
723+ <string name =" progressive_load_interval_default" >ExoPlayer default</string >
720724</resources >
Original file line number Diff line number Diff line change 6161 app : singleLineTitle =" false"
6262 app : iconSpaceReserved =" false" />
6363
64+ <ListPreference
65+ android : defaultValue =" @string/progressive_load_interval_default_value"
66+ android : entries =" @array/progressive_load_interval_descriptions"
67+ android : entryValues =" @array/progressive_load_interval_values"
68+ android : key =" @string/progressive_load_interval_key"
69+ android : summary =" @string/progressive_load_interval_summary"
70+ android : title =" @string/progressive_load_interval_title"
71+ app : singleLineTitle =" false"
72+ app : iconSpaceReserved =" false" />
73+
6474 <PreferenceCategory
6575 android : layout =" @layout/settings_category_header_layout"
6676 android : title =" @string/settings_category_player_title"
You can’t perform that action at this time.
0 commit comments