fix(YouTube - Shorts components): Shorts player automatically goes to next Short (Closes https://github.com/inotia00/ReVanced_Extended/issues/2873)

This commit is contained in:
inotia00 2025-03-26 15:03:55 +09:00
parent cf90f7b94e
commit 0bfabbc384
3 changed files with 11 additions and 24 deletions

View File

@ -30,8 +30,8 @@ public class ShortsRepeatStatePatch {
END_SCREEN;
static void setYTEnumValue(Enum<?> ytBehavior) {
String ytName = ytBehavior.name();
for (ShortsLoopBehavior rvBehavior : values()) {
String ytName = ytBehavior.name();
if (ytName.endsWith(rvBehavior.name())) {
if (rvBehavior.ytEnumValue != null) {
Logger.printException(() -> "Conflicting behavior names: " + rvBehavior
@ -87,22 +87,19 @@ public class ShortsRepeatStatePatch {
@Nullable
public static Enum<?> changeShortsRepeatBehavior(@Nullable Enum<?> original) {
try {
if (original == null) {
Logger.printDebug(() -> "Original is null, returning null");
return null;
}
ShortsLoopBehavior behavior = ExtendedUtils.IS_19_34_OR_GREATER &&
isAppInBackgroundPiPMode()
? Settings.CHANGE_SHORTS_BACKGROUND_REPEAT_STATE.get()
: Settings.CHANGE_SHORTS_REPEAT_STATE.get();
Enum<?> overrideBehavior = behavior.ytEnumValue;
if (overrideBehavior != null) {
Logger.printDebug(() -> overrideBehavior == original
? "Behavior setting is same as original. Using original: " + original.name()
: "Changing Shorts repeat behavior from: " + original.name() + " to: " + overrideBehavior.name()
);
if (behavior != ShortsLoopBehavior.UNKNOWN && overrideBehavior != null) {
Logger.printDebug(() -> {
String name = original == null ? "unknown (null)" : original.name();
return overrideBehavior == original
? "Behavior setting is same as original. Using original: " + name
: "Changing Shorts repeat behavior from: " + name + " to: " + overrideBehavior.name();
});
return overrideBehavior;
}
@ -117,6 +114,6 @@ public class ShortsRepeatStatePatch {
* Injection point.
*/
public static boolean isAutoPlay(@Nullable Enum<?> original) {
return original != null && ShortsLoopBehavior.SINGLE_PLAY.ytEnumValue == original;
return ShortsLoopBehavior.SINGLE_PLAY.ytEnumValue == original;
}
}

View File

@ -486,7 +486,6 @@ private val shortsRepeatPatch = bytecodePatch(
// As of YouTube 20.09, Google has removed the code for 'Autoplay' and 'Pause' from this method.
// Manually add the 'Autoplay' code that Google removed.
// Tested on YouTube 20.10.
// TODO: add the 'Pause' code that Google removed.
if (is_20_09_or_greater) {
val (directReference, virtualReference) = with (reelPlaybackFingerprint.methodOrThrow(videoIdFingerprintShorts)) {
val directIndex = indexOfInitializationInstruction(this)
@ -537,17 +536,6 @@ private val shortsRepeatPatch = bytecodePatch(
"""
)
}
} else {
getContext().apply {
addEntryValues(
"revanced_change_shorts_repeat_state_entries",
"@string/revanced_change_shorts_repeat_state_entry_pause",
)
addEntryValues(
"revanced_change_shorts_repeat_state_entry_values",
"END_SCREEN",
)
}
}
if (is_19_34_or_greater) {

View File

@ -98,11 +98,13 @@
<item>@string/revanced_change_shorts_repeat_state_entry_default</item>
<item>@string/revanced_change_shorts_repeat_state_entry_repeat</item>
<item>@string/revanced_change_shorts_repeat_state_entry_auto_play</item>
<item>@string/revanced_change_shorts_repeat_state_entry_pause</item>
</string-array>
<string-array name="revanced_change_shorts_repeat_state_entry_values">
<item>UNKNOWN</item>
<item>REPEAT</item>
<item>SINGLE_PLAY</item>
<item>END_SCREEN</item>
</string-array>
<string-array name="revanced_default_video_quality_entries">
<item>@string/quality_auto</item>