@wistia/wistia-player 0.8.3 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @wistia/wistia-player
2
2
 
3
+ ## 0.8.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 8f5d62e: Quality labels in the settings menu now name a video's full-resolution rendition by its real size, so videos that aren't exactly widescreen (such as 4:3, 5:4, 16:10 or tall vertical) can show their top quality, and vertical videos are named by their width so each quality option is distinct. Labels for standard-width widescreen renditions are unchanged.
8
+
3
9
  ## 0.8.3
4
10
 
5
11
  ### Patch Changes
@@ -8856,8 +8856,8 @@ const PROD_EMBED_HOST = 'embed.wistia.com';
8856
8856
  const PROD_SSL_EMBED_HOST = 'embed-ssl.wistia.com';
8857
8857
  const PROD_FASTLY_SSL_HOST = 'embed-fastly.wistia.com';
8858
8858
  const SSL_EMBED_HOST = "embed-ssl.wistia.com";
8859
- const TAGGED_VERSION = "0.8.3" || 0;
8860
- const CURRENT_SHA = "7e28a3678323b43bc66e7146d5e95a444ad30a5e" || 0;
8859
+ const TAGGED_VERSION = "0.8.4" || 0;
8860
+ const CURRENT_SHA = "c4d23790ab87519b4a5dfd0240c6d9275e27ed64" || 0;
8861
8861
  const DEFAULT_PROTOCOL = (() => {
8862
8862
  if (typeof window !== 'undefined' && utilities_root_js__WEBPACK_IMPORTED_MODULE_0__/* .root */ .z === window && utilities_root_js__WEBPACK_IMPORTED_MODULE_0__/* .root */ .z.location) {
8863
8863
  return utilities_root_js__WEBPACK_IMPORTED_MODULE_0__/* .root */ .z.location.protocol;
@@ -10100,8 +10100,24 @@ const withinQualityRange = (assets, qualityMin = 100, qualityMax = 10000) => {
10100
10100
  }
10101
10101
  });
10102
10102
  };
10103
+
10104
+ // Widths of the standard rungs in the encoding ladder. Keep in sync with
10105
+ // VideoDerivativeBuilder::HORIZONTAL_DERIVATIVE_WIDTHS and
10106
+ // VERTICAL_DERIVATIVE_WIDTHS in wistia/wistia.
10107
+ const HORIZONTAL_LADDER_WIDTHS = [400, 640, 960, 1280, 1920, 2560, 3200, 3840];
10108
+ const VERTICAL_LADDER_WIDTHS = [240, 360, 540, 720, 1080, 1440, 1800, 2160];
10109
+
10110
+ // [label, minimum long side, minimum short side]. Keep in sync with
10111
+ // AssetDimensions::SNAP_TIERS in wistia/wistia.
10112
+ const SNAP_TIERS = [[2160, 3740, 2104], [1800, 3100, 1744], [1440, 2460, 1384], [1080, 1820, 1024], [720, 1180, 664], [540, 860, 484], [360, 540, 304]];
10103
10113
  const numericSizeSnapped = (width, height) => {
10104
- if (height > width) {
10114
+ // A zero side is named 0, matching AssetDimensions. A missing side (an HLS
10115
+ // level without dimensions) still falls through to be named by the other.
10116
+ if (width === 0 || height === 0) {
10117
+ return 0;
10118
+ }
10119
+ const vertical = height > width;
10120
+ if (vertical) {
10105
10121
  // let's mathematically rotate vertical videos when determining their
10106
10122
  // snapped size.
10107
10123
  const tmpWidth = width;
@@ -10110,33 +10126,31 @@ const numericSizeSnapped = (width, height) => {
10110
10126
  }
10111
10127
  const aspectRatio = width / height;
10112
10128
 
10129
+ // Each rendition is named by the side its ladder rung is sized on: a
10130
+ // horizontal rung by its width, a vertical rung by its short side. So a
10131
+ // 4:3 ladder's 960x720 and 1280x960 stay 540p and 720p. A rung clamped off
10132
+ // the ladder (the full-resolution rung) or a square is also named by its
10133
+ // other side, so a 900x2100 top rung is 1080p beside the 720x1680 720p.
10134
+ const square = aspectRatio < 1.05;
10135
+ const offLadder = vertical ? !VERTICAL_LADDER_WIDTHS.includes(height) : !HORIZONTAL_LADDER_WIDTHS.includes(width);
10136
+ const byLongSide = square || !vertical || offLadder;
10137
+ const byShortSide = square || vertical || offLadder;
10138
+
10113
10139
  // If given a square video, expand the width so we'll name it as if
10114
10140
  // it's 16:9 with the given height.
10115
- if (aspectRatio < 1.05) {
10141
+ if (square) {
10116
10142
  width = height * (16 / 9);
10117
10143
  }
10118
- if (width >= 3740) {
10119
- return 2160;
10120
- }
10121
- if (width >= 3100) {
10122
- return 1800;
10144
+ const tier = SNAP_TIERS.find(([, minLong, minShort]) => byLongSide && width >= minLong || byShortSide && height >= minShort);
10145
+ if (tier) {
10146
+ return tier[0];
10123
10147
  }
10124
- if (width >= 2460) {
10125
- return 1440;
10126
- }
10127
- if (width >= 1820) {
10128
- return 1080;
10129
- }
10130
- if (width >= 1180) {
10131
- return 720;
10132
- }
10133
- if (width >= 860) {
10134
- return 540;
10135
- }
10136
- if (width >= 540) {
10137
- return 360;
10138
- }
10139
- return height;
10148
+
10149
+ // Below the lowest tier a rendition is named by its height, unless that
10150
+ // would reach the lowest tier's label: a near-square 10:9 ladder's 400x360
10151
+ // rung would otherwise share 360p with 640x576. Name that one as if 16:9.
10152
+ const lowestLabel = SNAP_TIERS[SNAP_TIERS.length - 1][0];
10153
+ return height < lowestLabel ? height : Math.round(width * 9 / 16);
10140
10154
  };
10141
10155
 
10142
10156
  // Expect that assets are a subset of assets that we are allowed to select.