Skip to content

Commit 94f774b

Browse files
committed
Use a custom HlsPlaylistTracker, based on DefaultHlsPlaylistTracker to allow more stucking on HLS livestreams
ExoPlayer's default behavior is to use a multiplication of target segment by a coefficient (3,5). This coefficient (and this behavior) cannot be customized without using a custom HlsPlaylistTracker right now. New behavior is to wait 15 seconds before throwing a PlaylistStuckException. This should improve a lot HLS live streaming on (very) low-latency livestreams with buffering issues, especially on YouTube with their HLS manifests.
1 parent 651b79d commit 94f774b

2 files changed

Lines changed: 787 additions & 2 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/helper/PlayerDataSource.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
1717
import com.google.android.exoplayer2.upstream.TransferListener;
1818

19+
import org.schabi.newpipe.player.playback.CustomHlsPlaylistTracker;
20+
1921
public class PlayerDataSource {
2022
private static final int MANIFEST_MINIMUM_RETRY = 5;
2123
private static final int EXTRACTOR_MINIMUM_RETRY = Integer.MAX_VALUE;
@@ -44,8 +46,9 @@ public SsMediaSource.Factory getLiveSsMediaSourceFactory() {
4446
public HlsMediaSource.Factory getLiveHlsMediaSourceFactory() {
4547
return new HlsMediaSource.Factory(cachelessDataSourceFactory)
4648
.setAllowChunklessPreparation(true)
47-
.setLoadErrorHandlingPolicy(
48-
new DefaultLoadErrorHandlingPolicy(MANIFEST_MINIMUM_RETRY));
49+
.setLoadErrorHandlingPolicy(new DefaultLoadErrorHandlingPolicy(
50+
MANIFEST_MINIMUM_RETRY))
51+
.setPlaylistTrackerFactory(CustomHlsPlaylistTracker.FACTORY);
4952
}
5053

5154
public DashMediaSource.Factory getLiveDashMediaSourceFactory() {

0 commit comments

Comments
 (0)