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

Fix capLevelToPlayerSize after hiding player and maintain stable selection when aspect ratio changes #5614

Merged
merged 2 commits into from
Jul 4, 2023

Conversation

robwalch
Copy link
Collaborator

@robwalch robwalch commented Jun 30, 2023

This PR will...

Why is this Pull Request needed?

Makes cap-level-controller continue to detect player size changes after it has been hidden and shown again.

Also prevents autoLevelCapping from bouncing back and forth when aspect ratio changes slightly between renditions because of rounded height values. To repro set player size to 426px with first BBB test stream.

Are there any points in the code the reviewer needs to double check?

The first issue (#5611) can be worked around by toggling capping after displaying the media element again:

hls.capLevelToPlayerSize = false;
hls.capLevelToPlayerSize = true;

This could be done at any time the size/layout of the media element is changed to perform a timely update of autoLevelCapping on requestAnimationFrame.

If you are already using HLS.js in a player that reads/writes page layout and controls the media element and observes its dimensions, then it is recommended to not use cap-level-controller. Instead batch the work of reading player width and height with existing checks in your player, and set hls.maxAutoLevel externally.

Resolves issues:

Fixes #5611

Checklist

  • changes have been done against master branch, and PR does not conflict

@robwalch robwalch added this to the 1.5.0 milestone Jun 30, 2023
@robwalch robwalch changed the title Bugfix/poll player size while hidden Fix capLevelToPlayerSize after hiding player and maintain stable selection when aspect ratio changes Jul 3, 2023
@pmmf85
Copy link

pmmf85 commented Jul 4, 2023

Tested locally. After these changes I can confirm that width and height are detected correctly, even after video HTML element becomes hidden and then visible again.

Copy link

@pmmf85 pmmf85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, both in demo as in my app, capLevelToPlayerSize behaves as intended after changes. Reported issue resolved as well.

@robwalch robwalch merged commit e0d73ac into master Jul 4, 2023
17 checks passed
@robwalch robwalch deleted the bugfix/poll-player-size-while-hidden branch July 4, 2023 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

capLevelToPlayerSize incorrect behaviour after HTML video element is not displayed
2 participants