-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Disable video and text tracks in background player and prefer DASH manifests over HLS ones for livestreams #12601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Stypox
merged 7 commits into
TeamNewPipe:dev
from
AudricV:live-prefer-dash-and-fetch-bg-audio-only
Jan 28, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
077f34c
Add a YouTube DASH manifest parser to make live DASH manifests usable
AudricV c670ad8
Use DASH first instead of HLS and YouTube's DASH parser for lives
AudricV 0578e7f
Rename useVideoSource to useVideoAndSubtitles in Player
AudricV 4648cac
Allow changing video and text tracks state without stream info
AudricV 1d8ea01
Disable fetching video and text tracks in background player
AudricV 216867c
Address review comments
Stypox c272309
Avoid rebuilding BackgroundPlayerUi if already in place
Stypox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
app/src/main/java/org/schabi/newpipe/player/helper/YoutubeDashLiveManifestParser.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package org.schabi.newpipe.player.helper; | ||
|
|
||
| import android.net.Uri; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.Nullable; | ||
|
|
||
| import com.google.android.exoplayer2.source.dash.manifest.DashManifest; | ||
| import com.google.android.exoplayer2.source.dash.manifest.DashManifestParser; | ||
| import com.google.android.exoplayer2.source.dash.manifest.Period; | ||
| import com.google.android.exoplayer2.source.dash.manifest.ProgramInformation; | ||
| import com.google.android.exoplayer2.source.dash.manifest.ServiceDescriptionElement; | ||
| import com.google.android.exoplayer2.source.dash.manifest.UtcTimingElement; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * A {@link DashManifestParser} fixing YouTube DASH manifests to allow starting playback from the | ||
| * newest period available instead of the earliest one in some cases. | ||
| * | ||
| * <p> | ||
| * It changes the {@code availabilityStartTime} passed to a custom value doing the workaround. | ||
| * A better approach to fix the issue should be investigated and used in the future. | ||
| * </p> | ||
| */ | ||
| public class YoutubeDashLiveManifestParser extends DashManifestParser { | ||
|
|
||
| // Result of Util.parseXsDateTime("1970-01-01T00:00:00Z") | ||
| private static final long AVAILABILITY_START_TIME_TO_USE = 0; | ||
|
|
||
| // There is no computation made with the availabilityStartTime value in the | ||
| // parseMediaPresentationDescription method itself, so we can just override methods called in | ||
| // this method using the workaround value | ||
| // Overriding parsePeriod does not seem to be needed | ||
|
|
||
| @SuppressWarnings("checkstyle:ParameterNumber") | ||
| @NonNull | ||
| @Override | ||
| protected DashManifest buildMediaPresentationDescription( | ||
| final long availabilityStartTime, | ||
| final long durationMs, | ||
| final long minBufferTimeMs, | ||
| final boolean dynamic, | ||
| final long minUpdateTimeMs, | ||
| final long timeShiftBufferDepthMs, | ||
| final long suggestedPresentationDelayMs, | ||
| final long publishTimeMs, | ||
| @Nullable final ProgramInformation programInformation, | ||
| @Nullable final UtcTimingElement utcTiming, | ||
| @Nullable final ServiceDescriptionElement serviceDescription, | ||
| @Nullable final Uri location, | ||
| @NonNull final List<Period> periods) { | ||
| return super.buildMediaPresentationDescription( | ||
| AVAILABILITY_START_TIME_TO_USE, | ||
| durationMs, | ||
| minBufferTimeMs, | ||
| dynamic, | ||
| minUpdateTimeMs, | ||
| timeShiftBufferDepthMs, | ||
| suggestedPresentationDelayMs, | ||
| publishTimeMs, | ||
| programInformation, | ||
| utcTiming, | ||
| serviceDescription, | ||
| location, | ||
| periods); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/src/main/java/org/schabi/newpipe/player/ui/BackgroundPlayerUi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package org.schabi.newpipe.player.ui; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
|
|
||
| import org.schabi.newpipe.player.Player; | ||
|
|
||
| /** | ||
| * This is not a "graphical" UI for the background player, but it is used to disable fetching video | ||
| * and text tracks with it. | ||
| * | ||
| * <p> | ||
| * This allows reducing data usage for manifest sources with demuxed audio and video, | ||
| * such as livestreams. | ||
| * </p> | ||
| */ | ||
| public class BackgroundPlayerUi extends PlayerUi { | ||
|
|
||
| public BackgroundPlayerUi(@NonNull final Player player) { | ||
| super(player); | ||
| } | ||
|
|
||
| @Override | ||
| public void initPlayback() { | ||
| super.initPlayback(); | ||
|
|
||
| // Make sure to disable video and subtitles track types | ||
| player.useVideoAndSubtitles(false); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.