Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playing at lower definition #1666

Closed
harryray33 opened this issue Apr 27, 2023 · 6 comments
Closed

Playing at lower definition #1666

harryray33 opened this issue Apr 27, 2023 · 6 comments
Labels
Completion / Revision Rethink, complete, improve, tweak our feature or structure. help wanted Just an old github standard we add automatically. (The team can remove it when working on it.)

Comments

@harryray33
Copy link

I have this set to play videos at 480p definition. Unfortunately, if 480p isn't available, Youtube defaults to the highest definition.

Is it possible to include an option to play at a lower definition if 480p isn't available?
Thanks.

@harryray33 harryray33 added Bug Bug or required update after YouTube changes help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) labels Apr 27, 2023
@ImprovedTube
Copy link
Member

ImprovedTube commented Apr 27, 2023

Hi @harryray33! :) Please confirm "highest". The next higher neighbor would be intentional as 360p and 240p might be considered too low. Of course we could by default have a priority order like 480p > 720p > 360p > 1080p > 240p .

Always looking forward to any input / pull requests.

@ImprovedTube ImprovedTube added Completion / Revision Rethink, complete, improve, tweak our feature or structure. and removed Bug Bug or required update after YouTube changes labels Apr 27, 2023
@harryray33
Copy link
Author

480p > 360p > 720p.

@raszpl
Copy link
Contributor

raszpl commented May 2, 2023

this is the line that needs work

quality = available_quality_levels[0];

You cant just plonk '240p' into player.setPlaybackQuality(quality); it expects those weird levels like hd720
label = ['tiny', 'small', 'medium', 'large', 'hd720', 'hd1080', 'hd1440', 'hd2160', 'hd2880', 'highres']
resolution = ['144', '240', '360', '480', '720', '1080', '1440', '2160', '2880', '4320']
translate quality label to resolution, find nearest inside player.getAvailableQualityLevels() with this stackoverflow function:

function closest (num, arr) {
                var curr = arr[0];
                var diff = Math.abs (num - curr);
                for (var val = 0; val < arr.length; val++) {
                    var newdiff = Math.abs (num - arr[val]);
                    if (newdiff < diff) {
                        diff = newdiff;
                        curr = arr[val];
                    }
                }
                return curr;
            }
//array = [2, 42, 82, 122, 162, 202, 242, 282, 322, 362];
//number = 112;
//closest (number, array));

translate back to label and use that

@ImprovedTube
Copy link
Member

480p > 360p > 720p.

for bandwidth? low resolution seems relaxing sometimes, retro

@raszpl
Copy link
Contributor

raszpl commented May 4, 2023

#1672 I didnt test it extensively

@ImprovedTube
Copy link
Member

@harryray33 let us know if you ever come here again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Completion / Revision Rethink, complete, improve, tweak our feature or structure. help wanted Just an old github standard we add automatically. (The team can remove it when working on it.)
Projects
None yet
Development

No branches or pull requests

3 participants