Skip to content
This repository was archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
fix(YouTube - Disable auto captions): Turning on `Disable forced auto…
Browse files Browse the repository at this point in the history
… captions` will disable subtitles
  • Loading branch information
inotia00 authored and anddea committed Jul 29, 2024
1 parent 37a814a commit 5d31427
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
import android.widget.Button;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import java.util.Objects;

import app.revanced.integrations.music.settings.Settings;

/**
Expand All @@ -36,27 +32,8 @@ public static String changeStartPage(final String browseId) {

// region [Disable auto captions] patch

@NonNull
private static String videoId = "";
private static boolean subtitlePrefetched = true;

public static boolean disableAutoCaptions(boolean original) {
if (!Settings.DISABLE_AUTO_CAPTIONS.get())
return original;

return subtitlePrefetched;
}

public static void newVideoStarted(@NonNull String newlyLoadedVideoId) {
if (Objects.equals(newlyLoadedVideoId, videoId)) {
return;
}
videoId = newlyLoadedVideoId;
subtitlePrefetched = false;
}

public static void prefetchSubtitleTrack() {
subtitlePrefetched = true;
return Settings.DISABLE_AUTO_CAPTIONS.get() || original;
}

// endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import app.revanced.integrations.shared.utils.ResourceUtils;
import app.revanced.integrations.shared.utils.Utils;
import app.revanced.integrations.youtube.settings.Settings;
import app.revanced.integrations.youtube.shared.PlayerType;
import app.revanced.integrations.youtube.utils.ThemeUtils;

/**
Expand Down Expand Up @@ -145,29 +146,16 @@ public static ArrayList<Object> getFormatStreamModelArray(final ArrayList<Object

// region [Disable auto captions] patch

private static boolean subtitlePrefetched = true;
@NonNull
private static String videoId = "";
private static boolean captionsButtonStatus;

public static boolean disableAutoCaptions(boolean original) {
if (!Settings.DISABLE_AUTO_CAPTIONS.get())
return original;

return subtitlePrefetched;
}

public static void newVideoStarted(@NonNull String newlyLoadedChannelId, @NonNull String newlyLoadedChannelName,
@NonNull String newlyLoadedVideoId, @NonNull String newlyLoadedVideoTitle,
final long newlyLoadedVideoLength, boolean newlyLoadedLiveStreamValue) {
if (Objects.equals(newlyLoadedVideoId, videoId)) {
return;
}
videoId = newlyLoadedVideoId;
subtitlePrefetched = false;
public static boolean disableAutoCaptions() {
return Settings.DISABLE_AUTO_CAPTIONS.get() &&
!captionsButtonStatus &&
!PlayerType.getCurrent().isNoneHiddenOrSlidingMinimized();
}

public static void prefetchSubtitleTrack() {
subtitlePrefetched = true;
public static void setCaptionsButtonStatus(boolean status) {
captionsButtonStatus = status;
}

// endregion
Expand Down

0 comments on commit 5d31427

Please sign in to comment.