-
Notifications
You must be signed in to change notification settings - Fork 428
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
Consider object-fit when selecting playlist by player size #1051
Conversation
💖 Thanks for opening this pull request! 💖 Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
Both |
Regarding docs: A note about the feature could be added to the docs of |
Here's an example showcasing the new behavior using a build that includes the changes from the PR branch. |
Could somebody take a look at this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also see the tests failing due to a linter error here, not sure why it would fail in scripts/index-demo-page.js
as you didn't make any changes there. Perhaps a rebase would fix that?
c395d50
to
00ebda7
Compare
Changed the test case to use the original value again. Rebased onto main for linting fix. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a reasonable addition. I think we should get this into the main branch.
Refactor from positional parameters to a single `settings` argument. This makes it clearer what each argument means in calls of the function. Additional parameters can now be added without making the argument list overly long. Key names were chosen to match those of `minRebufferMaxBandwidthSelector` to align the signatures.
Inline the passed bandwidth value instead of referencing the config constant since the concrete value is needed to understand why the expected playlist is chosen. Also if the config constant should ever change the test will fail for no good reason.
So far, when `limitRenditionByPlayerDimensions` is `true`, `simpleSelector` tried to either find a rendition with a resolution that matches the size of the player exactly or, if that does not exist, a rendition with the smallest resolution that has either greater width or greater height than the player. This makes sense since by default the video will be scaled to fit inside the media element. So every resolution that exceeds player size in at least one dimension will be scaled down. Most browsers support [1] customizing this scaling behavior via the `object-fit` CSS property [2]. If it set to `cover`, the video will instead be scaled up if video and player aspect ratio do not match. The previous behavior caused renditions with low resolution to be selected for players with small width (e.g. portrait phone aspect ratio) even when videos were then scaled up to cover the whole player. We therefore detect if `object-fit` is set to `cover` and instead select the smallest rendition with a resolution that exceeds player dimensions in both width and height. [1] https://caniuse.com/?search=object-fit [2] https://developer.mozilla.org/de/docs/Web/CSS/object-fit
Only consider `object-fit` CSS property when selecting playlists based on play size when `usePlayerObjectFit` option is `true` to make new behavior an opt-in.
00ebda7
to
c6ea01a
Compare
Rebased onto main. Updated jsbin showcasing the new behavior using the latest version of Video.js: |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1051 +/- ##
=======================================
Coverage 83.99% 84.00%
=======================================
Files 44 44
Lines 11700 11707 +7
Branches 2618 2623 +5
=======================================
+ Hits 9827 9834 +7
Misses 1873 1873 ☔ View full report in Codecov by Sentry. |
Congrats on merging your first pull request! 🎉🎉🎉 |
@tf thanks! < 5 years :) |
Description
So far, when
limitRenditionByPlayerDimensions
istrue
,simpleSelector
tried to either find a rendition with a resolutionthat matches the size of the player exactly or, if that does not
exist, a rendition with the smallest resolution that has either
greater width or greater height than the player. This makes sense
since by default the video will be scaled to fit inside the media
element. So every resolution that exceeds player size in at least one
dimension will be scaled down.
Most browsers support customizing this scaling behavior via the
object-fit
CSS property. If it set tocover
, the video willinstead be scaled up if video and player aspect ratio do not match.
The previous behavior caused renditions with low resolution to be
selected for players with small width (e.g. portrait phone aspect
ratio) even when videos were then scaled up to cover the whole player.
We therefore detect if
object-fit
is set tocover
and insteadselect the smallest rendition with a resolution that exceeds player
dimensions in both width and height.
Specific Changes proposed
The first two commits are preparatory refactorings. The third commit contains the change itself.
Requirements Checklist