stormcloud-video-player 0.7.44 → 0.7.46

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.
@@ -5689,186 +5689,6 @@ function isOverlayActive(overlay, currentTime) {
5689
5689
  if (durationSec <= 0) return false;
5690
5690
  return currentTime >= startSec && currentTime < startSec + durationSec;
5691
5691
  }
5692
- var SWIRL_HD_AUTHORING_WIDTH = 1920;
5693
- var SWIRL_HD_AUTHORING_HEIGHT = 1080;
5694
- var NAB_DEMO_NAME_PREFIX = "NAB Demo \u2014 ";
5695
- function overlayAuthoringDimensions(overlay, decodeWidth, decodeHeight) {
5696
- if (overlay.name.startsWith(NAB_DEMO_NAME_PREFIX)) {
5697
- return {
5698
- width: SWIRL_HD_AUTHORING_WIDTH,
5699
- height: SWIRL_HD_AUTHORING_HEIGHT
5700
- };
5701
- }
5702
- if (!decodeWidth || !decodeHeight) {
5703
- return {
5704
- width: decodeWidth || SWIRL_HD_AUTHORING_WIDTH,
5705
- height: decodeHeight || SWIRL_HD_AUTHORING_HEIGHT
5706
- };
5707
- }
5708
- return {
5709
- width: decodeWidth,
5710
- height: decodeHeight
5711
- };
5712
- }
5713
- function overlayExtents(overlays) {
5714
- var maxR = 0;
5715
- var maxB = 0;
5716
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5717
- try {
5718
- for(var _iterator = overlays[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5719
- var o = _step.value;
5720
- if (!o.visible) continue;
5721
- maxR = Math.max(maxR, o.x + o.width);
5722
- maxB = Math.max(maxB, o.y + o.height);
5723
- }
5724
- } catch (err) {
5725
- _didIteratorError = true;
5726
- _iteratorError = err;
5727
- } finally{
5728
- try {
5729
- if (!_iteratorNormalCompletion && _iterator.return != null) {
5730
- _iterator.return();
5731
- }
5732
- } finally{
5733
- if (_didIteratorError) {
5734
- throw _iteratorError;
5735
- }
5736
- }
5737
- }
5738
- return {
5739
- maxR: maxR,
5740
- maxB: maxB
5741
- };
5742
- }
5743
- function swirlProjectHasNabDemoMixedWithOther(overlays) {
5744
- var hasNab = false;
5745
- var hasOther = false;
5746
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5747
- try {
5748
- for(var _iterator = overlays[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5749
- var o = _step.value;
5750
- if (!o.visible) continue;
5751
- if (o.name.startsWith(NAB_DEMO_NAME_PREFIX)) hasNab = true;
5752
- else hasOther = true;
5753
- }
5754
- } catch (err) {
5755
- _didIteratorError = true;
5756
- _iteratorError = err;
5757
- } finally{
5758
- try {
5759
- if (!_iteratorNormalCompletion && _iterator.return != null) {
5760
- _iterator.return();
5761
- }
5762
- } finally{
5763
- if (_didIteratorError) {
5764
- throw _iteratorError;
5765
- }
5766
- }
5767
- }
5768
- return hasNab && hasOther;
5769
- }
5770
- var STANDARD_16_9_LADDER = [
5771
- {
5772
- width: 384,
5773
- height: 216
5774
- },
5775
- {
5776
- width: 640,
5777
- height: 360
5778
- },
5779
- {
5780
- width: 854,
5781
- height: 480
5782
- },
5783
- {
5784
- width: 1280,
5785
- height: 720
5786
- },
5787
- {
5788
- width: 1920,
5789
- height: 1080
5790
- },
5791
- {
5792
- width: 2560,
5793
- height: 1440
5794
- },
5795
- {
5796
- width: 3840,
5797
- height: 2160
5798
- }
5799
- ];
5800
- function smallestLadderRungContaining(maxR, maxB, eps) {
5801
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5802
- try {
5803
- for(var _iterator = STANDARD_16_9_LADDER[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5804
- var rung = _step.value;
5805
- if (maxR <= rung.width + eps && maxB <= rung.height + eps) return rung;
5806
- }
5807
- } catch (err) {
5808
- _didIteratorError = true;
5809
- _iteratorError = err;
5810
- } finally{
5811
- try {
5812
- if (!_iteratorNormalCompletion && _iterator.return != null) {
5813
- _iterator.return();
5814
- }
5815
- } finally{
5816
- if (_didIteratorError) {
5817
- throw _iteratorError;
5818
- }
5819
- }
5820
- }
5821
- return null;
5822
- }
5823
- function inferSwirlOverlayCoordinateSpace(overlays, videoWidth, videoHeight) {
5824
- if (!videoWidth || !videoHeight) {
5825
- return {
5826
- width: videoWidth || SWIRL_HD_AUTHORING_WIDTH,
5827
- height: videoHeight || SWIRL_HD_AUTHORING_HEIGHT
5828
- };
5829
- }
5830
- if (!overlays.length) {
5831
- return {
5832
- width: videoWidth,
5833
- height: videoHeight
5834
- };
5835
- }
5836
- var _overlayExtents = overlayExtents(overlays), maxR = _overlayExtents.maxR, maxB = _overlayExtents.maxB;
5837
- var EPS = 1;
5838
- if (maxR <= 0 || maxB <= 0) {
5839
- return {
5840
- width: videoWidth,
5841
- height: videoHeight
5842
- };
5843
- }
5844
- var mixed = swirlProjectHasNabDemoMixedWithOther(overlays);
5845
- var fitsHdCanvas = maxR <= SWIRL_HD_AUTHORING_WIDTH + EPS && maxB <= SWIRL_HD_AUTHORING_HEIGHT + EPS;
5846
- var exceedsDecode = maxR > videoWidth + EPS || maxB > videoHeight + EPS;
5847
- var decodeLargerThanHd = videoWidth > SWIRL_HD_AUTHORING_WIDTH + EPS || videoHeight > SWIRL_HD_AUTHORING_HEIGHT + EPS;
5848
- if (fitsHdCanvas && (decodeLargerThanHd || exceedsDecode && !mixed)) {
5849
- return {
5850
- width: SWIRL_HD_AUTHORING_WIDTH,
5851
- height: SWIRL_HD_AUTHORING_HEIGHT
5852
- };
5853
- }
5854
- if (mixed) {
5855
- return {
5856
- width: videoWidth,
5857
- height: videoHeight
5858
- };
5859
- }
5860
- var rung = smallestLadderRungContaining(maxR, maxB, EPS);
5861
- if (rung && rung.width < videoWidth - EPS && rung.height < videoHeight - EPS) {
5862
- return {
5863
- width: rung.width,
5864
- height: rung.height
5865
- };
5866
- }
5867
- return {
5868
- width: videoWidth,
5869
- height: videoHeight
5870
- };
5871
- }
5872
5692
  function normalizeScrollerConfig(raw) {
5873
5693
  if (!raw || (typeof raw === "undefined" ? "undefined" : _type_of(raw)) !== "object") return void 0;
5874
5694
  var r = raw;
@@ -7752,13 +7572,8 @@ var OverlayRenderer = function OverlayRenderer(param) {
7752
7572
  },
7753
7573
  children: _to_consumable_array(fadeMap.values()).map(function(param) {
7754
7574
  var overlay = param.overlay, visible = param.visible;
7755
- var uniform = coordinateSpace && coordinateSpace.width > 0 && coordinateSpace.height > 0;
7756
- var auth = uniform ? {
7757
- width: coordinateSpace.width,
7758
- height: coordinateSpace.height
7759
- } : overlayAuthoringDimensions(overlay, dims.nativeWidth, dims.nativeHeight);
7760
- var scaleX = dims.displayWidth / auth.width;
7761
- var scaleY = dims.displayHeight / auth.height;
7575
+ var scaleX = (coordinateSpace === null || coordinateSpace === void 0 ? void 0 : coordinateSpace.width) ? dims.displayWidth / coordinateSpace.width : dims.scaleX;
7576
+ var scaleY = (coordinateSpace === null || coordinateSpace === void 0 ? void 0 : coordinateSpace.height) ? dims.displayHeight / coordinateSpace.height : dims.scaleY;
7762
7577
  var left = overlay.x * scaleX;
7763
7578
  var top = overlay.y * scaleY;
7764
7579
  var width = overlay.width * scaleX;
@@ -8280,9 +8095,10 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8280
8095
  var _playerRef_current;
8281
8096
  if (!swirlProjectId) return;
8282
8097
  var tryResolve = function tryResolve() {
8283
- var _ref, _ref1;
8098
+ var _player_getMinHlsResolution;
8284
8099
  var fixed = swirlOverlayCoordinateSpace;
8285
8100
  if (fixed && fixed.width > 0 && fixed.height > 0) {
8101
+ console.debug("[StormcloudVideoPlayer] overlay coord space (prop):", fixed.width, "x", fixed.height);
8286
8102
  setOverlayCoordSpace({
8287
8103
  width: fixed.width,
8288
8104
  height: fixed.height
@@ -8291,27 +8107,25 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8291
8107
  }
8292
8108
  var player = playerRef.current;
8293
8109
  if (!player) return false;
8110
+ var minRes = (_player_getMinHlsResolution = player.getMinHlsResolution) === null || _player_getMinHlsResolution === void 0 ? void 0 : _player_getMinHlsResolution.call(player);
8111
+ if (minRes && minRes.width > 0 && minRes.height > 0) {
8112
+ console.debug("[StormcloudVideoPlayer] overlay coord space (minHlsResolution):", minRes.width, "x", minRes.height);
8113
+ setOverlayCoordSpace({
8114
+ width: minRes.width,
8115
+ height: minRes.height
8116
+ });
8117
+ return true;
8118
+ }
8294
8119
  var video2 = player.videoElement;
8295
- var vw = (_ref = video2 === null || video2 === void 0 ? void 0 : video2.videoWidth) !== null && _ref !== void 0 ? _ref : 0;
8296
- var vh = (_ref1 = video2 === null || video2 === void 0 ? void 0 : video2.videoHeight) !== null && _ref1 !== void 0 ? _ref1 : 0;
8297
- if (!vw || !vh) {
8298
- var _player_getMaxHlsResolution;
8299
- var maxRes = (_player_getMaxHlsResolution = player.getMaxHlsResolution) === null || _player_getMaxHlsResolution === void 0 ? void 0 : _player_getMaxHlsResolution.call(player);
8300
- if (maxRes && maxRes.width > 0 && maxRes.height > 0) {
8301
- vw = maxRes.width;
8302
- vh = maxRes.height;
8303
- } else {
8304
- var _player_getMinHlsResolution;
8305
- var minRes = (_player_getMinHlsResolution = player.getMinHlsResolution) === null || _player_getMinHlsResolution === void 0 ? void 0 : _player_getMinHlsResolution.call(player);
8306
- if (minRes && minRes.width > 0 && minRes.height > 0) {
8307
- vw = minRes.width;
8308
- vh = minRes.height;
8309
- }
8310
- }
8120
+ if (video2 && video2.videoWidth > 0 && video2.videoHeight > 0) {
8121
+ console.debug("[StormcloudVideoPlayer] overlay coord space (videoNative):", video2.videoWidth, "x", video2.videoHeight);
8122
+ setOverlayCoordSpace({
8123
+ width: video2.videoWidth,
8124
+ height: video2.videoHeight
8125
+ });
8126
+ return true;
8311
8127
  }
8312
- if (!vw || !vh) return false;
8313
- setOverlayCoordSpace(inferSwirlOverlayCoordinateSpace(overlays, vw, vh));
8314
- return true;
8128
+ return false;
8315
8129
  };
8316
8130
  var attempts = 0;
8317
8131
  var maxAttempts = 40;
@@ -8337,8 +8151,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8337
8151
  }, [
8338
8152
  swirlProjectId,
8339
8153
  criticalPropsKey,
8340
- swirlOverlayCoordinateSpace,
8341
- overlays
8154
+ swirlOverlayCoordinateSpace
8342
8155
  ]);
8343
8156
  (0, import_react2.useEffect)(function() {
8344
8157
  if (!playerRef.current) return;
@@ -8765,11 +8578,11 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8765
8578
  }, restVideoAttrs), {
8766
8579
  children: children
8767
8580
  })),
8768
- displayOverlays.length > 0 && !adStatus.showAds && !overlaysDisabled && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OverlayRenderer, {
8581
+ displayOverlays.length > 0 && !adStatus.showAds && !overlaysDisabled && overlayCoordSpace && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OverlayRenderer, {
8769
8582
  overlays: displayOverlays,
8770
8583
  currentTime: currentTime,
8771
8584
  videoRef: videoRef,
8772
- coordinateSpace: swirlOverlayCoordinateSpace && swirlOverlayCoordinateSpace.width > 0 && swirlOverlayCoordinateSpace.height > 0 ? swirlOverlayCoordinateSpace : null,
8585
+ coordinateSpace: overlayCoordSpace,
8773
8586
  showcaseMode: !!swirlShowcaseDemo
8774
8587
  }),
8775
8588
  (isLoading || isBuffering) && !hideLoadingIndicator && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", {