fix(YouTube - Video quality): Fix 144p default not always used
This commit is contained in:
parent
1a8146dbc8
commit
9afa7d2ac6
2 changed files with 15 additions and 7 deletions
|
|
@ -44,6 +44,8 @@ public class RememberVideoQualityPatch {
|
||||||
private static final IntegerSetting shortsQualityWifi = Settings.SHORTS_QUALITY_DEFAULT_WIFI;
|
private static final IntegerSetting shortsQualityWifi = Settings.SHORTS_QUALITY_DEFAULT_WIFI;
|
||||||
private static final IntegerSetting shortsQualityMobile = Settings.SHORTS_QUALITY_DEFAULT_MOBILE;
|
private static final IntegerSetting shortsQualityMobile = Settings.SHORTS_QUALITY_DEFAULT_MOBILE;
|
||||||
|
|
||||||
|
private static boolean qualityNeedsUpdating;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The available qualities of the current video.
|
* The available qualities of the current video.
|
||||||
*/
|
*/
|
||||||
|
|
@ -152,18 +154,25 @@ public class RememberVideoQualityPatch {
|
||||||
VideoQualityDialogButton.updateButtonIcon(updatedCurrentQuality);
|
VideoQualityDialogButton.updateButtonIcon(updatedCurrentQuality);
|
||||||
}
|
}
|
||||||
|
|
||||||
// After changing videos the qualities can initially be for the prior video.
|
|
||||||
// If the qualities have changed and the default is not auto then an update is needed.
|
|
||||||
final int preferredQuality = getDefaultQualityResolution();
|
final int preferredQuality = getDefaultQualityResolution();
|
||||||
if (preferredQuality == AUTOMATIC_VIDEO_QUALITY_VALUE || !availableQualitiesChanged) {
|
if (preferredQuality == AUTOMATIC_VIDEO_QUALITY_VALUE) {
|
||||||
return originalQualityIndex; // Nothing to do.
|
return originalQualityIndex; // Nothing to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// After changing videos the qualities can initially be for the prior video.
|
||||||
|
// If the qualities have changed and the default is not auto then an update is needed.
|
||||||
|
if (!qualityNeedsUpdating && !availableQualitiesChanged) {
|
||||||
|
return originalQualityIndex;
|
||||||
|
}
|
||||||
|
qualityNeedsUpdating = false;
|
||||||
|
|
||||||
// Find the highest quality that is equal to or less than the preferred.
|
// Find the highest quality that is equal to or less than the preferred.
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (VideoQuality quality : qualities) {
|
for (VideoQuality quality : qualities) {
|
||||||
final int qualityResolution = quality.patch_getResolution();
|
final int qualityResolution = quality.patch_getResolution();
|
||||||
if (qualityResolution != AUTOMATIC_VIDEO_QUALITY_VALUE && qualityResolution <= preferredQuality) {
|
if ((qualityResolution != AUTOMATIC_VIDEO_QUALITY_VALUE && qualityResolution <= preferredQuality)
|
||||||
|
// Use the lowest video quality if the default is lower than all available.
|
||||||
|
|| i == qualities.length - 1) {
|
||||||
final boolean qualityNeedsChange = (i != originalQualityIndex);
|
final boolean qualityNeedsChange = (i != originalQualityIndex);
|
||||||
Logger.printDebug(() -> qualityNeedsChange
|
Logger.printDebug(() -> qualityNeedsChange
|
||||||
? "Changing video quality from: " + updatedCurrentQuality + " to: " + quality
|
? "Changing video quality from: " + updatedCurrentQuality + " to: " + quality
|
||||||
|
|
@ -235,6 +244,7 @@ public class RememberVideoQualityPatch {
|
||||||
currentQualities = null;
|
currentQualities = null;
|
||||||
currentQuality = null;
|
currentQuality = null;
|
||||||
currentMenuInterface = null;
|
currentMenuInterface = null;
|
||||||
|
qualityNeedsUpdating = true;
|
||||||
|
|
||||||
// Hide the quality button until playback starts and the qualities are available.
|
// Hide the quality button until playback starts and the qualities are available.
|
||||||
VideoQualityDialogButton.updateButtonIcon(null);
|
VideoQualityDialogButton.updateButtonIcon(null);
|
||||||
|
|
|
||||||
|
|
@ -205,11 +205,9 @@ public class VideoQualityDialogButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -1 adjustment for automatic quality at first index.
|
// -1 adjustment for automatic quality at first index.
|
||||||
int listViewSelectedIndex = 0;
|
int listViewSelectedIndex = -1;
|
||||||
for (VideoQuality quality : currentQualities) {
|
for (VideoQuality quality : currentQualities) {
|
||||||
if (quality == currentQuality) {
|
if (quality == currentQuality) {
|
||||||
// -1 adjustment for the missing automatic quality in the dialog list.
|
|
||||||
listViewSelectedIndex--;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
listViewSelectedIndex++;
|
listViewSelectedIndex++;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue