mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-28 21:00:19 +02:00
fix(YouTube - Remove background playback restriction): Play/Pause button not working in PiP mode https://github.com/inotia00/ReVanced_Extended/issues/2764
This commit is contained in:
parent
e97f37e224
commit
6f1fc6116b
@ -1,10 +1,14 @@
|
||||
package app.revanced.extension.youtube.patches.misc;
|
||||
|
||||
import app.revanced.extension.shared.settings.BooleanSetting;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.youtube.shared.PlayerType;
|
||||
import app.revanced.extension.youtube.shared.ShortsPlayerState;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class BackgroundPlaybackPatch {
|
||||
private static final BooleanSetting DISABLE_SHORTS_BACKGROUND_PLAYBACK =
|
||||
Settings.DISABLE_SHORTS_BACKGROUND_PLAYBACK;
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
@ -14,11 +18,21 @@ public class BackgroundPlaybackPatch {
|
||||
return ShortsPlayerState.getCurrent().isClosed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static boolean isBackgroundShortsPlaybackAllowed() {
|
||||
if (PlayerType.getCurrent().isNoneHiddenOrMinimized()) {
|
||||
return !DISABLE_SHORTS_BACKGROUND_PLAYBACK.get();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static boolean isBackgroundShortsPlaybackAllowed(boolean original) {
|
||||
return !Settings.DISABLE_SHORTS_BACKGROUND_PLAYBACK.get();
|
||||
return !DISABLE_SHORTS_BACKGROUND_PLAYBACK.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package app.revanced.patches.youtube.misc.backgroundplayback
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.instructions
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
@ -39,7 +40,7 @@ val backgroundPlaybackPatch = bytecodePatch(
|
||||
arrayOf(
|
||||
backgroundPlaybackManagerFingerprint to "isBackgroundPlaybackAllowed",
|
||||
backgroundPlaybackManagerShortsFingerprint to "isBackgroundShortsPlaybackAllowed",
|
||||
).forEach { (fingerprint, integrationsMethod) ->
|
||||
).forEach { (fingerprint, extensionsMethod) ->
|
||||
fingerprint.methodOrThrow().apply {
|
||||
findInstructionIndicesReversedOrThrow(Opcode.RETURN).forEach { index ->
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
@ -47,7 +48,7 @@ val backgroundPlaybackPatch = bytecodePatch(
|
||||
addInstructionsAtControlFlowLabel(
|
||||
index,
|
||||
"""
|
||||
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->$integrationsMethod(Z)Z
|
||||
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->$extensionsMethod(Z)Z
|
||||
move-result v$register
|
||||
""",
|
||||
)
|
||||
@ -68,7 +69,17 @@ val backgroundPlaybackPatch = bytecodePatch(
|
||||
}
|
||||
|
||||
// Force allowing background play for Shorts.
|
||||
shortsBackgroundPlaybackFeatureFlagFingerprint.methodOrThrow().returnEarly(true)
|
||||
shortsBackgroundPlaybackFeatureFlagFingerprint.methodOrThrow().addInstructionsWithLabels(
|
||||
0,
|
||||
"""
|
||||
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->isBackgroundShortsPlaybackAllowed()Z
|
||||
move-result v0
|
||||
if-eqz v0, :disabled
|
||||
return v0
|
||||
:disabled
|
||||
nop
|
||||
"""
|
||||
)
|
||||
|
||||
// Force allowing background play for videos labeled for kids.
|
||||
kidsBackgroundPlaybackPolicyControllerFingerprint.methodOrThrow(
|
||||
|
Loading…
x
Reference in New Issue
Block a user