Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

fix(YouTube - Remove background playback restrictions): Enable for Short as well #701

Closed
wants to merge 11 commits into from
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package app.revanced.integrations.youtube.patches;

import app.revanced.integrations.youtube.settings.Settings;
import app.revanced.integrations.youtube.shared.PlayerType;

@SuppressWarnings("unused")
Expand All @@ -8,7 +9,7 @@ public class BackgroundPlaybackPatch {
/**
* Injection point.
*/
public static boolean playbackIsNotShort() {
public static boolean isBackgroundPlaybackAllowed() {
// Steps to verify most edge cases:
// 1. Open a regular video
// 2. Minimize app (PIP should appear)
Expand All @@ -20,16 +21,11 @@ public static boolean playbackIsNotShort() {
// 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.
if (VideoInformation.lastVideoIdIsShort()) {
return !Settings.DISABLE_BACKGROUND_SHORTS.get();
}

// 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,
// 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();
zainarbani marked this conversation as resolved.
Show resolved Hide resolved
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,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_BACKGROUND_SHORTS = new BooleanSetting("revanced_disable_background_shorts", 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);
Expand Down
Loading