From 4917da2d2e533f08c0050ba45151fb714a7adf7e Mon Sep 17 00:00:00 2001 From: karyogamy Date: Sun, 17 Apr 2022 13:26:39 -0400 Subject: [PATCH 1/3] fixed: disabled caption to no longer automatically re-enable on new player instance. --- .../main/java/org/schabi/newpipe/player/Player.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 82ae0df27..9f95aa519 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -3557,14 +3557,19 @@ public final class Player implements } // apply caption language from previous user preference - final List selectedPreferredLanguages = - trackSelector.getParameters().preferredTextLanguages; final String userPreferredLanguage = prefs.getString(context.getString(R.string.caption_user_set_key), null); final int textRendererIndex = getCaptionRendererIndex(); - if (userPreferredLanguage != null - && !selectedPreferredLanguages.contains(userPreferredLanguage) + if (userPreferredLanguage == null) { + trackSelector.setParameters(trackSelector.buildUponParameters() + .setRendererDisabled(textRendererIndex, true)); + return; + } + + final List selectedPreferredLanguages = + trackSelector.getParameters().preferredTextLanguages; + if (!selectedPreferredLanguages.contains(userPreferredLanguage) && textRendererIndex != RENDERER_UNAVAILABLE) { trackSelector.setParameters(trackSelector.buildUponParameters() .setPreferredTextLanguages(userPreferredLanguage, From 29fc0eff38b7480a1dcebb140302512fe5a0ccab Mon Sep 17 00:00:00 2001 From: karyogamy Date: Sun, 17 Apr 2022 18:34:31 -0400 Subject: [PATCH 2/3] fixed: added comments for DefaultTrackSelector auto-select fix. --- .../java/org/schabi/newpipe/player/Player.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 9f95aa519..30c62af39 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -3557,20 +3557,27 @@ public final class Player implements } // apply caption language from previous user preference + final int textRendererIndex = getCaptionRendererIndex(); + if (textRendererIndex == RENDERER_UNAVAILABLE) { + return; + } + + // If user prefers to show no caption, then disable the renderer. + // Otherwise, DefaultTrackSelector may automatically find an available caption + // and display that. final String userPreferredLanguage = prefs.getString(context.getString(R.string.caption_user_set_key), null); - final int textRendererIndex = getCaptionRendererIndex(); - if (userPreferredLanguage == null) { trackSelector.setParameters(trackSelector.buildUponParameters() .setRendererDisabled(textRendererIndex, true)); return; } + // Only set preferred language if it does not match the user preference, + // otherwise there might be an infinite cycle at onTextTracksChanged. final List selectedPreferredLanguages = trackSelector.getParameters().preferredTextLanguages; - if (!selectedPreferredLanguages.contains(userPreferredLanguage) - && textRendererIndex != RENDERER_UNAVAILABLE) { + if (!selectedPreferredLanguages.contains(userPreferredLanguage)) { trackSelector.setParameters(trackSelector.buildUponParameters() .setPreferredTextLanguages(userPreferredLanguage, PlayerHelper.captionLanguageStemOf(userPreferredLanguage)) From 2b8eb7ed66f0178ba8fc84c44981dde8f01574c3 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Mon, 18 Apr 2022 14:28:56 +0200 Subject: [PATCH 3/3] Also run CI when target is release branch --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13a4d8723..306b8c2c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,7 @@ on: branches: - dev - master + - release/** paths-ignore: - 'README.md' - 'doc/**'