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:
parent
009cf71462
commit
53318c48ee
5 changed files with 141 additions and 16 deletions
|
|
@ -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()}.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue