11package org .schabi .newpipe .player .helper ;
22
33import android .content .Context ;
4- import android .os .Build ;
54
65import androidx .annotation .NonNull ;
76
8- import com .google .android .exoplayer2 .source .MediaParserExtractorAdapter ;
97import com .google .android .exoplayer2 .source .ProgressiveMediaSource ;
108import com .google .android .exoplayer2 .source .SingleSampleMediaSource ;
11- import com .google .android .exoplayer2 .source .chunk .MediaParserChunkExtractor ;
129import com .google .android .exoplayer2 .source .dash .DashMediaSource ;
1310import com .google .android .exoplayer2 .source .dash .DefaultDashChunkSource ;
1411import com .google .android .exoplayer2 .source .hls .HlsMediaSource ;
15- import com .google .android .exoplayer2 .source .hls .MediaParserHlsMediaChunkExtractor ;
1612import com .google .android .exoplayer2 .source .smoothstreaming .DefaultSsChunkSource ;
1713import com .google .android .exoplayer2 .source .smoothstreaming .SsMediaSource ;
1814import com .google .android .exoplayer2 .upstream .DataSource ;
@@ -46,17 +42,10 @@ public SsMediaSource.Factory getLiveSsMediaSourceFactory() {
4642 }
4743
4844 public HlsMediaSource .Factory getLiveHlsMediaSourceFactory () {
49- final HlsMediaSource .Factory factory =
50- new HlsMediaSource .Factory (cachelessDataSourceFactory )
51- .setAllowChunklessPreparation (true )
52- .setLoadErrorHandlingPolicy (
53- new DefaultLoadErrorHandlingPolicy (MANIFEST_MINIMUM_RETRY ));
54-
55- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .R ) {
56- factory .setExtractorFactory (MediaParserHlsMediaChunkExtractor .FACTORY );
57- }
58-
59- return factory ;
45+ return new HlsMediaSource .Factory (cachelessDataSourceFactory )
46+ .setAllowChunklessPreparation (true )
47+ .setLoadErrorHandlingPolicy (
48+ new DefaultLoadErrorHandlingPolicy (MANIFEST_MINIMUM_RETRY ));
6049 }
6150
6251 public DashMediaSource .Factory getLiveDashMediaSourceFactory () {
@@ -71,26 +60,11 @@ public DashMediaSource.Factory getLiveDashMediaSourceFactory() {
7160 private DefaultDashChunkSource .Factory getDefaultDashChunkSourceFactory (
7261 final DataSource .Factory dataSourceFactory
7362 ) {
74- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .R ) {
75- return new DefaultDashChunkSource .Factory (
76- MediaParserChunkExtractor .FACTORY ,
77- dataSourceFactory ,
78- 1
79- );
80- }
81-
8263 return new DefaultDashChunkSource .Factory (dataSourceFactory );
8364 }
8465
8566 public HlsMediaSource .Factory getHlsMediaSourceFactory () {
86- final HlsMediaSource .Factory factory = new HlsMediaSource .Factory (cacheDataSourceFactory );
87-
88- if (Build .VERSION .SDK_INT < Build .VERSION_CODES .R ) {
89- return factory ;
90- }
91-
92- // *** >= Android 11 / R / API 30 ***
93- return factory .setExtractorFactory (MediaParserHlsMediaChunkExtractor .FACTORY );
67+ return new HlsMediaSource .Factory (cacheDataSourceFactory );
9468 }
9569
9670 public DashMediaSource .Factory getDashMediaSourceFactory () {
@@ -101,18 +75,9 @@ public DashMediaSource.Factory getDashMediaSourceFactory() {
10175 }
10276
10377 public ProgressiveMediaSource .Factory getExtractorMediaSourceFactory () {
104- final ProgressiveMediaSource .Factory factory ;
105- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .R ) {
106- factory = new ProgressiveMediaSource .Factory (
107- cacheDataSourceFactory ,
108- MediaParserExtractorAdapter .FACTORY
109- );
110- } else {
111- factory = new ProgressiveMediaSource .Factory (cacheDataSourceFactory );
112- }
113-
114- return factory .setLoadErrorHandlingPolicy (
115- new DefaultLoadErrorHandlingPolicy (EXTRACTOR_MINIMUM_RETRY ));
78+ return new ProgressiveMediaSource .Factory (cacheDataSourceFactory )
79+ .setLoadErrorHandlingPolicy (
80+ new DefaultLoadErrorHandlingPolicy (EXTRACTOR_MINIMUM_RETRY ));
11681 }
11782
11883 public SingleSampleMediaSource .Factory getSampleMediaSourceFactory () {
0 commit comments