mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-06-12 21:27:38 +02:00
fix(YouTube - Remove background playback restrictions): Enable for Shorts as well (#3671)
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package app.revanced.extension.youtube.patches;
|
||||
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.youtube.shared.PlayerType;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ -8,10 +9,10 @@ public class BackgroundPlaybackPatch {
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static boolean allowBackgroundPlayback(boolean original) {
|
||||
public static boolean isBackgroundPlaybackAllowed(boolean original) {
|
||||
if (original) return true;
|
||||
|
||||
// Steps to verify most edge cases:
|
||||
// Steps to verify most edge cases (with Shorts background playback set to off):
|
||||
// 1. Open a regular video
|
||||
// 2. Minimize app (PIP should appear)
|
||||
// 3. Reopen app
|
||||
@ -22,13 +23,13 @@ public class BackgroundPlaybackPatch {
|
||||
// 7. Close the Short
|
||||
// 8. Resume playing the regular video
|
||||
// 9. Minimize the app (PIP should appear)
|
||||
|
||||
if (!VideoInformation.lastVideoIdIsShort()) {
|
||||
return true; // Definitely is not a Short.
|
||||
}
|
||||
|
||||
// Might be a Short, or might be a prior regular video on screen again after a Short was closed.
|
||||
// This incorrectly prevents PIP if player is in WATCH_WHILE_MINIMIZED after closing a Short,
|
||||
// TODO: Add better hook.
|
||||
// Might be a Shorts, or might be a prior regular video on screen again after a Shorts was closed.
|
||||
// This incorrectly prevents PIP if player is in WATCH_WHILE_MINIMIZED after closing a Shorts,
|
||||
// But there's no way around this unless an additional hook is added to definitively detect
|
||||
// the Shorts player is on screen. This use case is unusual anyways so it's not a huge concern.
|
||||
return !PlayerType.getCurrent().isNoneHiddenOrMinimized();
|
||||
@ -37,10 +38,7 @@ public class BackgroundPlaybackPatch {
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static boolean overrideBackgroundPlaybackAvailable() {
|
||||
// This could be done entirely in the patch,
|
||||
// but having a unique method to search for makes manually inspecting the patched apk much easier.
|
||||
return true;
|
||||
public static boolean isBackgroundShortsPlaybackAllowed(boolean original) {
|
||||
return !Settings.DISABLE_SHORTS_BACKGROUND_PLAYBACK.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -214,6 +214,7 @@ public class Settings extends BaseSettings {
|
||||
public static final BooleanSetting SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON = new BooleanSetting("revanced_switch_create_with_notifications_button", TRUE, true);
|
||||
|
||||
// Shorts
|
||||
public static final BooleanSetting DISABLE_SHORTS_BACKGROUND_PLAYBACK = new BooleanSetting("revanced_shorts_disable_background_playback", FALSE);
|
||||
public static final BooleanSetting DISABLE_RESUMING_SHORTS_PLAYER = new BooleanSetting("revanced_disable_resuming_shorts_player", FALSE);
|
||||
public static final BooleanSetting HIDE_SHORTS_HOME = new BooleanSetting("revanced_hide_shorts_home", FALSE);
|
||||
public static final BooleanSetting HIDE_SHORTS_SUBSCRIPTIONS = new BooleanSetting("revanced_hide_shorts_subscriptions", FALSE);
|
||||
|
Reference in New Issue
Block a user