Skip to content

Commit

Permalink
Removed/Reverted MediaParser support (Android 11+) due to bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
litetex committed Dec 19, 2021
1 parent e8d9095 commit eea2768
Showing 1 changed file with 8 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package org.schabi.newpipe.player.helper;

import android.content.Context;
import android.os.Build;

import androidx.annotation.NonNull;

import com.google.android.exoplayer2.source.MediaParserExtractorAdapter;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.source.SingleSampleMediaSource;
import com.google.android.exoplayer2.source.chunk.MediaParserChunkExtractor;
import com.google.android.exoplayer2.source.dash.DashMediaSource;
import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource;
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.source.hls.MediaParserHlsMediaChunkExtractor;
import com.google.android.exoplayer2.source.smoothstreaming.DefaultSsChunkSource;
import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource;
import com.google.android.exoplayer2.upstream.DataSource;
Expand Down Expand Up @@ -46,17 +42,10 @@ public SsMediaSource.Factory getLiveSsMediaSourceFactory() {
}

public HlsMediaSource.Factory getLiveHlsMediaSourceFactory() {
final HlsMediaSource.Factory factory =
new HlsMediaSource.Factory(cachelessDataSourceFactory)
.setAllowChunklessPreparation(true)
.setLoadErrorHandlingPolicy(
new DefaultLoadErrorHandlingPolicy(MANIFEST_MINIMUM_RETRY));

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
factory.setExtractorFactory(MediaParserHlsMediaChunkExtractor.FACTORY);
}

return factory;
return new HlsMediaSource.Factory(cachelessDataSourceFactory)
.setAllowChunklessPreparation(true)
.setLoadErrorHandlingPolicy(
new DefaultLoadErrorHandlingPolicy(MANIFEST_MINIMUM_RETRY));
}

public DashMediaSource.Factory getLiveDashMediaSourceFactory() {
Expand All @@ -71,26 +60,11 @@ public DashMediaSource.Factory getLiveDashMediaSourceFactory() {
private DefaultDashChunkSource.Factory getDefaultDashChunkSourceFactory(
final DataSource.Factory dataSourceFactory
) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
return new DefaultDashChunkSource.Factory(
MediaParserChunkExtractor.FACTORY,
dataSourceFactory,
1
);
}

return new DefaultDashChunkSource.Factory(dataSourceFactory);
}

public HlsMediaSource.Factory getHlsMediaSourceFactory() {
final HlsMediaSource.Factory factory = new HlsMediaSource.Factory(cacheDataSourceFactory);

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
return factory;
}

// *** >= Android 11 / R / API 30 ***
return factory.setExtractorFactory(MediaParserHlsMediaChunkExtractor.FACTORY);
return new HlsMediaSource.Factory(cacheDataSourceFactory);
}

public DashMediaSource.Factory getDashMediaSourceFactory() {
Expand All @@ -101,18 +75,9 @@ public DashMediaSource.Factory getDashMediaSourceFactory() {
}

public ProgressiveMediaSource.Factory getExtractorMediaSourceFactory() {
final ProgressiveMediaSource.Factory factory;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
factory = new ProgressiveMediaSource.Factory(
cacheDataSourceFactory,
MediaParserExtractorAdapter.FACTORY
);
} else {
factory = new ProgressiveMediaSource.Factory(cacheDataSourceFactory);
}

return factory.setLoadErrorHandlingPolicy(
new DefaultLoadErrorHandlingPolicy(EXTRACTOR_MINIMUM_RETRY));
return new ProgressiveMediaSource.Factory(cacheDataSourceFactory)
.setLoadErrorHandlingPolicy(
new DefaultLoadErrorHandlingPolicy(EXTRACTOR_MINIMUM_RETRY));
}

public SingleSampleMediaSource.Factory getSampleMediaSourceFactory() {
Expand Down

0 comments on commit eea2768

Please sign in to comment.