You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Consider object-fit when selecting playlist by player size (#1051)
* Make simple playlist selecor easier to extend
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.
* Make simpleSelector test easier to understand
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.
* Consider object-fit when selecting playlist by player size
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
* Add usePlayerObjectFit option
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.
* chore: add object-fit option to the demo page
---------
Co-authored-by: Dzianis Dashkevich <98566601+dzianis-dashkevich@users.noreply.github.com>
@@ -414,6 +415,17 @@ This setting is `true` by default.
414
415
If true, this will take the device pixel ratio into account when doing rendition switching. This means that if you have a player with the width of `540px` in a high density display with a device pixel ratio of 2, a rendition of `1080p` will be allowed.
415
416
This setting is `false` by default.
416
417
418
+
419
+
##### usePlayerObjectFit
420
+
* Type: `boolean`
421
+
* can be used as an initialization option.
422
+
423
+
If true, the video element's `object-fit` CSS property will be taken
424
+
into account when doing rendition switching. This ensures that a
425
+
suitable rendition is selected for videos that are scaled up to cover
426
+
the media element. This setting is `false` by default.
427
+
428
+
417
429
##### customPixelRatio
418
430
* Type: `number`
419
431
* can be used as an initialization option.
@@ -426,6 +438,7 @@ It is worth noting that if the player dimension multiplied by the custom pixel r
426
438
427
439
If `useDevicePixelRatio` is set to `true`, the custom pixel ratio will be prioritized and overwrite any previous pixel ratio.
0 commit comments