fix(YouTube - Video quality): Initial video quality is not overridden

Co-authored-by: inotia00 <108592928+inotia00@users.noreply.github.com>
This commit is contained in:
oSumAtrIX 2026-03-19 20:41:02 +01:00
parent 009cf71462
commit 53318c48ee
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
5 changed files with 141 additions and 16 deletions

View file

@ -11,8 +11,9 @@ import app.revanced.extension.youtube.patches.VideoInformation;
import app.revanced.extension.youtube.patches.VideoInformation.*;
import app.revanced.extension.youtube.settings.Settings;
import app.revanced.extension.youtube.shared.ShortsPlayerState;
import j$.util.Optional;
@SuppressWarnings("unused")
@SuppressWarnings({"rawtypes", "unused"})
public class RememberVideoQualityPatch {
private static final IntegerSetting videoQualityWifi = Settings.VIDEO_QUALITY_DEFAULT_WIFI;
@ -66,6 +67,25 @@ public class RememberVideoQualityPatch {
}
}
/**
* Injection point.
* <p>
* Overrides the initial video quality to not follow the 'Video quality preferences' in YouTube settings.
* (e.g. 'Auto (recommended)' - 360p/480p, 'Higher picture quality' - 720p/1080p...)
* If the maximum video quality available is 1080p and the default video quality is 2160p,
* 1080p is used as an initial video quality.
* <p>
* Called before {@link #newVideoStarted(VideoInformation.PlaybackController)}.
*/
public static Optional getInitialVideoQuality(Optional optional) {
int preferredQuality = getDefaultQualityResolution();
if (preferredQuality != VideoInformation.AUTOMATIC_VIDEO_QUALITY_VALUE) {
Logger.printDebug(() -> "initialVideoQuality: " + preferredQuality);
return Optional.of(preferredQuality);
}
return optional;
}
/**
* Injection point.
* @param userSelectedQualityIndex Element index of {@link VideoInformation#getCurrentQualities()}.

View file

@ -0,0 +1,18 @@
package j$.util;
public final class Optional<T> {
/**
* Returns an {@code Optional} describing the given non-{@code null}
* value.
*
* @param value the value to describe, which must be non-{@code null}
* @param <T> the type of the value
* @return an {@code Optional} with the value present
* @throws NullPointerException if value is {@code null}
*/
public static <T> Optional<T> of(T value) {
return null;
}
}