fix(YouTube - Remove background playback restrictions): Media controls appear in the status bar when playing Shorts from the feed

This commit is contained in:
inotia00 2025-03-29 16:51:35 +09:00
parent b8f3917b55
commit 79f933dad4

View File

@ -2,6 +2,7 @@ package app.revanced.extension.youtube.patches.misc;
import app.revanced.extension.shared.settings.BooleanSetting; import app.revanced.extension.shared.settings.BooleanSetting;
import app.revanced.extension.youtube.settings.Settings; import app.revanced.extension.youtube.settings.Settings;
import app.revanced.extension.youtube.shared.PlayerType;
import app.revanced.extension.youtube.shared.ShortsPlayerState; import app.revanced.extension.youtube.shared.ShortsPlayerState;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -14,7 +15,16 @@ public class BackgroundPlaybackPatch {
*/ */
public static boolean isBackgroundPlaybackAllowed(boolean original) { public static boolean isBackgroundPlaybackAllowed(boolean original) {
if (original) return true; if (original) return true;
return ShortsPlayerState.getCurrent().isClosed(); return ShortsPlayerState.getCurrent().isClosed() &&
// 1. Shorts background playback is enabled.
// 2. Autoplay in feed is turned on.
// 3. Play Shorts from feed.
// 4. Media controls appear in status bar.
// (For unpatched YouTube with Premium accounts, media controls do not appear in the status bar)
//
// This is just a visual bug and does not affect Shorts background play in any way.
// To fix this, just check PlayerType.
PlayerType.getCurrent() != PlayerType.INLINE_MINIMAL;
} }
/** /**