stormcloud-video-player 0.7.42 → 0.7.44
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/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +214 -58
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +214 -58
- package/lib/index.js.map +1 -1
- package/lib/ui/OverlayRenderer.cjs +140 -56
- package/lib/ui/OverlayRenderer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +214 -58
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/overlays.cjs +80 -19
- package/lib/utils/overlays.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -5892,27 +5892,16 @@ var SWIRL_HD_AUTHORING_WIDTH = 1920;
|
|
|
5892
5892
|
var SWIRL_HD_AUTHORING_HEIGHT = 1080;
|
|
5893
5893
|
var NAB_DEMO_NAME_PREFIX = "NAB Demo \u2014 ";
|
|
5894
5894
|
function overlayAuthoringDimensions(overlay, decodeWidth, decodeHeight) {
|
|
5895
|
-
if (
|
|
5896
|
-
return {
|
|
5897
|
-
width: decodeWidth || SWIRL_HD_AUTHORING_WIDTH,
|
|
5898
|
-
height: decodeHeight || SWIRL_HD_AUTHORING_HEIGHT
|
|
5899
|
-
};
|
|
5900
|
-
}
|
|
5901
|
-
if (!overlay.visible) {
|
|
5895
|
+
if (overlay.name.startsWith(NAB_DEMO_NAME_PREFIX)) {
|
|
5902
5896
|
return {
|
|
5903
|
-
width:
|
|
5904
|
-
height:
|
|
5897
|
+
width: SWIRL_HD_AUTHORING_WIDTH,
|
|
5898
|
+
height: SWIRL_HD_AUTHORING_HEIGHT
|
|
5905
5899
|
};
|
|
5906
5900
|
}
|
|
5907
|
-
|
|
5908
|
-
var extB = overlay.y + overlay.height;
|
|
5909
|
-
var EPS = 2;
|
|
5910
|
-
var exceedsDecode = extR > decodeWidth + EPS || extB > decodeHeight + EPS;
|
|
5911
|
-
var isNabDemo = overlay.name.startsWith(NAB_DEMO_NAME_PREFIX);
|
|
5912
|
-
if (exceedsDecode && isNabDemo) {
|
|
5901
|
+
if (!decodeWidth || !decodeHeight) {
|
|
5913
5902
|
return {
|
|
5914
|
-
width: SWIRL_HD_AUTHORING_WIDTH,
|
|
5915
|
-
height: SWIRL_HD_AUTHORING_HEIGHT
|
|
5903
|
+
width: decodeWidth || SWIRL_HD_AUTHORING_WIDTH,
|
|
5904
|
+
height: decodeHeight || SWIRL_HD_AUTHORING_HEIGHT
|
|
5916
5905
|
};
|
|
5917
5906
|
}
|
|
5918
5907
|
return {
|
|
@@ -5977,6 +5966,59 @@ function swirlProjectHasNabDemoMixedWithOther(overlays) {
|
|
|
5977
5966
|
}
|
|
5978
5967
|
return hasNab && hasOther;
|
|
5979
5968
|
}
|
|
5969
|
+
var STANDARD_16_9_LADDER = [
|
|
5970
|
+
{
|
|
5971
|
+
width: 384,
|
|
5972
|
+
height: 216
|
|
5973
|
+
},
|
|
5974
|
+
{
|
|
5975
|
+
width: 640,
|
|
5976
|
+
height: 360
|
|
5977
|
+
},
|
|
5978
|
+
{
|
|
5979
|
+
width: 854,
|
|
5980
|
+
height: 480
|
|
5981
|
+
},
|
|
5982
|
+
{
|
|
5983
|
+
width: 1280,
|
|
5984
|
+
height: 720
|
|
5985
|
+
},
|
|
5986
|
+
{
|
|
5987
|
+
width: 1920,
|
|
5988
|
+
height: 1080
|
|
5989
|
+
},
|
|
5990
|
+
{
|
|
5991
|
+
width: 2560,
|
|
5992
|
+
height: 1440
|
|
5993
|
+
},
|
|
5994
|
+
{
|
|
5995
|
+
width: 3840,
|
|
5996
|
+
height: 2160
|
|
5997
|
+
}
|
|
5998
|
+
];
|
|
5999
|
+
function smallestLadderRungContaining(maxR, maxB, eps) {
|
|
6000
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
6001
|
+
try {
|
|
6002
|
+
for(var _iterator = STANDARD_16_9_LADDER[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
6003
|
+
var rung = _step.value;
|
|
6004
|
+
if (maxR <= rung.width + eps && maxB <= rung.height + eps) return rung;
|
|
6005
|
+
}
|
|
6006
|
+
} catch (err) {
|
|
6007
|
+
_didIteratorError = true;
|
|
6008
|
+
_iteratorError = err;
|
|
6009
|
+
} finally{
|
|
6010
|
+
try {
|
|
6011
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
6012
|
+
_iterator.return();
|
|
6013
|
+
}
|
|
6014
|
+
} finally{
|
|
6015
|
+
if (_didIteratorError) {
|
|
6016
|
+
throw _iteratorError;
|
|
6017
|
+
}
|
|
6018
|
+
}
|
|
6019
|
+
}
|
|
6020
|
+
return null;
|
|
6021
|
+
}
|
|
5980
6022
|
function inferSwirlOverlayCoordinateSpace(overlays, videoWidth, videoHeight) {
|
|
5981
6023
|
if (!videoWidth || !videoHeight) {
|
|
5982
6024
|
return {
|
|
@@ -5992,9 +6034,15 @@ function inferSwirlOverlayCoordinateSpace(overlays, videoWidth, videoHeight) {
|
|
|
5992
6034
|
}
|
|
5993
6035
|
var _overlayExtents = overlayExtents(overlays), maxR = _overlayExtents.maxR, maxB = _overlayExtents.maxB;
|
|
5994
6036
|
var EPS = 1;
|
|
5995
|
-
|
|
5996
|
-
|
|
6037
|
+
if (maxR <= 0 || maxB <= 0) {
|
|
6038
|
+
return {
|
|
6039
|
+
width: videoWidth,
|
|
6040
|
+
height: videoHeight
|
|
6041
|
+
};
|
|
6042
|
+
}
|
|
5997
6043
|
var mixed = swirlProjectHasNabDemoMixedWithOther(overlays);
|
|
6044
|
+
var fitsHdCanvas = maxR <= SWIRL_HD_AUTHORING_WIDTH + EPS && maxB <= SWIRL_HD_AUTHORING_HEIGHT + EPS;
|
|
6045
|
+
var exceedsDecode = maxR > videoWidth + EPS || maxB > videoHeight + EPS;
|
|
5998
6046
|
var decodeLargerThanHd = videoWidth > SWIRL_HD_AUTHORING_WIDTH + EPS || videoHeight > SWIRL_HD_AUTHORING_HEIGHT + EPS;
|
|
5999
6047
|
if (fitsHdCanvas && (decodeLargerThanHd || exceedsDecode && !mixed)) {
|
|
6000
6048
|
return {
|
|
@@ -6002,6 +6050,19 @@ function inferSwirlOverlayCoordinateSpace(overlays, videoWidth, videoHeight) {
|
|
|
6002
6050
|
height: SWIRL_HD_AUTHORING_HEIGHT
|
|
6003
6051
|
};
|
|
6004
6052
|
}
|
|
6053
|
+
if (mixed) {
|
|
6054
|
+
return {
|
|
6055
|
+
width: videoWidth,
|
|
6056
|
+
height: videoHeight
|
|
6057
|
+
};
|
|
6058
|
+
}
|
|
6059
|
+
var rung = smallestLadderRungContaining(maxR, maxB, EPS);
|
|
6060
|
+
if (rung && rung.width < videoWidth - EPS && rung.height < videoHeight - EPS) {
|
|
6061
|
+
return {
|
|
6062
|
+
width: rung.width,
|
|
6063
|
+
height: rung.height
|
|
6064
|
+
};
|
|
6065
|
+
}
|
|
6005
6066
|
return {
|
|
6006
6067
|
width: videoWidth,
|
|
6007
6068
|
height: videoHeight
|
|
@@ -7506,11 +7567,19 @@ function hexToRgb(hex) {
|
|
|
7506
7567
|
return "".concat(num >> 16 & 255, ",").concat(num >> 8 & 255, ",").concat(num & 255);
|
|
7507
7568
|
}
|
|
7508
7569
|
var FADE_DURATION_MS = 1e3;
|
|
7509
|
-
var SHOWCASE_CYCLE_MS_DEFAULT =
|
|
7510
|
-
var
|
|
7511
|
-
var
|
|
7512
|
-
var
|
|
7513
|
-
var
|
|
7570
|
+
var SHOWCASE_CYCLE_MS_DEFAULT = 36e3;
|
|
7571
|
+
var SHOWCASE_MIN_BEAT_MS = 6e3;
|
|
7572
|
+
var BEAT_POP_IN_MS = 520;
|
|
7573
|
+
var BEAT_POP_OUT_MS = 520;
|
|
7574
|
+
var SHOWCASE_PERSISTENT_TYPES = /* @__PURE__ */ new Set([
|
|
7575
|
+
"scroller",
|
|
7576
|
+
"breaking_news",
|
|
7577
|
+
"image",
|
|
7578
|
+
"text",
|
|
7579
|
+
"shape",
|
|
7580
|
+
"countdown",
|
|
7581
|
+
"qr_code"
|
|
7582
|
+
]);
|
|
7514
7583
|
function easeOutCubic(t) {
|
|
7515
7584
|
var u = 1 - t;
|
|
7516
7585
|
return 1 - u * u * u;
|
|
@@ -7523,38 +7592,108 @@ function easeOutBack(t) {
|
|
|
7523
7592
|
var c3 = c1 + 1;
|
|
7524
7593
|
return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
|
|
7525
7594
|
}
|
|
7526
|
-
function
|
|
7527
|
-
if (phase <
|
|
7528
|
-
|
|
7529
|
-
|
|
7595
|
+
function beatOpacity(phase, beatMs) {
|
|
7596
|
+
if (phase < BEAT_POP_IN_MS) return easeOutCubic(phase / BEAT_POP_IN_MS);
|
|
7597
|
+
var holdEnd = beatMs - BEAT_POP_OUT_MS;
|
|
7598
|
+
if (phase >= holdEnd) {
|
|
7599
|
+
return Math.max(0, 1 - easeInCubic((phase - holdEnd) / BEAT_POP_OUT_MS));
|
|
7530
7600
|
}
|
|
7531
7601
|
return 1;
|
|
7532
7602
|
}
|
|
7533
|
-
function
|
|
7534
|
-
if (phase <
|
|
7535
|
-
return Math.min(1, 0.
|
|
7603
|
+
function beatScale(phase, beatMs) {
|
|
7604
|
+
if (phase < BEAT_POP_IN_MS) {
|
|
7605
|
+
return Math.min(1, 0.92 + 0.08 * easeOutBack(phase / BEAT_POP_IN_MS));
|
|
7536
7606
|
}
|
|
7537
|
-
|
|
7538
|
-
|
|
7607
|
+
var holdEnd = beatMs - BEAT_POP_OUT_MS;
|
|
7608
|
+
if (phase >= holdEnd) {
|
|
7609
|
+
return 1 - 0.06 * easeInCubic((phase - holdEnd) / BEAT_POP_OUT_MS);
|
|
7539
7610
|
}
|
|
7540
7611
|
return 1;
|
|
7541
7612
|
}
|
|
7542
|
-
function
|
|
7543
|
-
var
|
|
7613
|
+
function partitionShowcase(overlays) {
|
|
7614
|
+
var visible = overlays.filter(function(o) {
|
|
7615
|
+
return o.visible;
|
|
7616
|
+
});
|
|
7617
|
+
var persistent = [];
|
|
7618
|
+
var spotlight = [];
|
|
7619
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
7620
|
+
try {
|
|
7621
|
+
for(var _iterator = visible[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
7622
|
+
var o = _step.value;
|
|
7623
|
+
if (SHOWCASE_PERSISTENT_TYPES.has(o.type)) persistent.push(o);
|
|
7624
|
+
else spotlight.push(o);
|
|
7625
|
+
}
|
|
7626
|
+
} catch (err) {
|
|
7627
|
+
_didIteratorError = true;
|
|
7628
|
+
_iteratorError = err;
|
|
7629
|
+
} finally{
|
|
7630
|
+
try {
|
|
7631
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
7632
|
+
_iterator.return();
|
|
7633
|
+
}
|
|
7634
|
+
} finally{
|
|
7635
|
+
if (_didIteratorError) {
|
|
7636
|
+
throw _iteratorError;
|
|
7637
|
+
}
|
|
7638
|
+
}
|
|
7639
|
+
}
|
|
7640
|
+
spotlight.sort(function(a, b) {
|
|
7641
|
+
return a.z_index - b.z_index || a.id - b.id;
|
|
7642
|
+
});
|
|
7643
|
+
var beats = [];
|
|
7644
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
7645
|
+
try {
|
|
7646
|
+
for(var _iterator1 = spotlight[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
7647
|
+
var o1 = _step1.value;
|
|
7648
|
+
beats.push([
|
|
7649
|
+
o1
|
|
7650
|
+
]);
|
|
7651
|
+
}
|
|
7652
|
+
} catch (err) {
|
|
7653
|
+
_didIteratorError1 = true;
|
|
7654
|
+
_iteratorError1 = err;
|
|
7655
|
+
} finally{
|
|
7656
|
+
try {
|
|
7657
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
7658
|
+
_iterator1.return();
|
|
7659
|
+
}
|
|
7660
|
+
} finally{
|
|
7661
|
+
if (_didIteratorError1) {
|
|
7662
|
+
throw _iteratorError1;
|
|
7663
|
+
}
|
|
7664
|
+
}
|
|
7665
|
+
}
|
|
7666
|
+
return {
|
|
7667
|
+
persistent: persistent,
|
|
7668
|
+
beats: beats
|
|
7669
|
+
};
|
|
7670
|
+
}
|
|
7671
|
+
function useShowcaseBeat(enabled, cycleMs, beats) {
|
|
7672
|
+
var safeBeats = Math.max(1, beats);
|
|
7673
|
+
var beatMs = Math.max(SHOWCASE_MIN_BEAT_MS, Math.floor(cycleMs / safeBeats));
|
|
7674
|
+
var totalMs = beatMs * safeBeats;
|
|
7675
|
+
var _ref = _sliced_to_array((0, import_react.useState)(function() {
|
|
7676
|
+
return Date.now();
|
|
7677
|
+
}), 2), now = _ref[0], setNow = _ref[1];
|
|
7544
7678
|
(0, import_react.useEffect)(function() {
|
|
7545
7679
|
if (!enabled) return;
|
|
7546
|
-
setPhase(Date.now() % cycleMs);
|
|
7547
7680
|
var id = window.setInterval(function() {
|
|
7548
|
-
|
|
7549
|
-
},
|
|
7681
|
+
return setNow(Date.now());
|
|
7682
|
+
}, 64);
|
|
7550
7683
|
return function() {
|
|
7551
7684
|
return clearInterval(id);
|
|
7552
7685
|
};
|
|
7553
7686
|
}, [
|
|
7554
|
-
enabled
|
|
7555
|
-
cycleMs
|
|
7687
|
+
enabled
|
|
7556
7688
|
]);
|
|
7557
|
-
|
|
7689
|
+
var phase = now % totalMs;
|
|
7690
|
+
var beatIndex = Math.min(safeBeats - 1, Math.floor(phase / beatMs));
|
|
7691
|
+
var beatPhase = phase - beatIndex * beatMs;
|
|
7692
|
+
return {
|
|
7693
|
+
beatIndex: beatIndex,
|
|
7694
|
+
beatPhase: beatPhase,
|
|
7695
|
+
beatMs: beatMs
|
|
7696
|
+
};
|
|
7558
7697
|
}
|
|
7559
7698
|
var OverlayRenderer = function OverlayRenderer(param) {
|
|
7560
7699
|
var overlays = param.overlays, currentTime = param.currentTime, videoRef = param.videoRef, coordinateSpace = param.coordinateSpace, _param_showcaseMode = param.showcaseMode, showcaseMode = _param_showcaseMode === void 0 ? false : _param_showcaseMode, _param_showcaseCycleMs = param.showcaseCycleMs, showcaseCycleMs = _param_showcaseCycleMs === void 0 ? SHOWCASE_CYCLE_MS_DEFAULT : _param_showcaseCycleMs;
|
|
@@ -7562,7 +7701,28 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7562
7701
|
var rafRef = (0, import_react.useRef)(null);
|
|
7563
7702
|
var _ref1 = _sliced_to_array((0, import_react.useState)(/* @__PURE__ */ new Map()), 2), fadeMap = _ref1[0], setFadeMap = _ref1[1];
|
|
7564
7703
|
var removeTimers = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
7565
|
-
var
|
|
7704
|
+
var _ref2 = (0, import_react.useMemo)(function() {
|
|
7705
|
+
return partitionShowcase(overlays);
|
|
7706
|
+
}, [
|
|
7707
|
+
overlays
|
|
7708
|
+
]), showcasePersistent = _ref2.persistent, showcaseBeats = _ref2.beats;
|
|
7709
|
+
var _useShowcaseBeat = useShowcaseBeat(showcaseMode, showcaseCycleMs, showcaseBeats.length), showcaseBeatIndex = _useShowcaseBeat.beatIndex, showcaseBeatPhase = _useShowcaseBeat.beatPhase, showcaseBeatMs = _useShowcaseBeat.beatMs;
|
|
7710
|
+
var showcasePersistentIds = (0, import_react.useMemo)(function() {
|
|
7711
|
+
return new Set(showcasePersistent.map(function(o) {
|
|
7712
|
+
return o.id;
|
|
7713
|
+
}));
|
|
7714
|
+
}, [
|
|
7715
|
+
showcasePersistent
|
|
7716
|
+
]);
|
|
7717
|
+
var showcaseSpotlightIds = (0, import_react.useMemo)(function() {
|
|
7718
|
+
var beat = showcaseBeats[showcaseBeatIndex];
|
|
7719
|
+
return new Set((beat !== null && beat !== void 0 ? beat : []).map(function(o) {
|
|
7720
|
+
return o.id;
|
|
7721
|
+
}));
|
|
7722
|
+
}, [
|
|
7723
|
+
showcaseBeats,
|
|
7724
|
+
showcaseBeatIndex
|
|
7725
|
+
]);
|
|
7566
7726
|
var updateDims = (0, import_react.useCallback)(function() {
|
|
7567
7727
|
var video = videoRef.current;
|
|
7568
7728
|
if (video) {
|
|
@@ -7595,10 +7755,9 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7595
7755
|
]);
|
|
7596
7756
|
var activeOverlays = (0, import_react.useMemo)(function() {
|
|
7597
7757
|
if (showcaseMode) {
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
});
|
|
7758
|
+
var _showcaseBeats_showcaseBeatIndex;
|
|
7759
|
+
var beat = (_showcaseBeats_showcaseBeatIndex = showcaseBeats[showcaseBeatIndex]) !== null && _showcaseBeats_showcaseBeatIndex !== void 0 ? _showcaseBeats_showcaseBeatIndex : [];
|
|
7760
|
+
return _to_consumable_array(showcasePersistent).concat(_to_consumable_array(beat));
|
|
7602
7761
|
}
|
|
7603
7762
|
return overlays.filter(function(o) {
|
|
7604
7763
|
return isOverlayActive(o, currentTime);
|
|
@@ -7607,14 +7766,9 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7607
7766
|
overlays,
|
|
7608
7767
|
currentTime,
|
|
7609
7768
|
showcaseMode,
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
return new Set(activeOverlays.map(function(o) {
|
|
7614
|
-
return o.id;
|
|
7615
|
-
}));
|
|
7616
|
-
}, [
|
|
7617
|
-
activeOverlays
|
|
7769
|
+
showcasePersistent,
|
|
7770
|
+
showcaseBeats,
|
|
7771
|
+
showcaseBeatIndex
|
|
7618
7772
|
]);
|
|
7619
7773
|
(0, import_react.useLayoutEffect)(function() {
|
|
7620
7774
|
var activeIds = new Set(activeOverlays.map(function(o) {
|
|
@@ -7809,10 +7963,12 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7809
7963
|
var width = overlay.width * scaleX;
|
|
7810
7964
|
var height = overlay.height * scaleY;
|
|
7811
7965
|
var baseOpacity = Math.max(0, Math.min(100, overlay.opacity)) / 100;
|
|
7812
|
-
var
|
|
7813
|
-
var
|
|
7814
|
-
var
|
|
7815
|
-
var
|
|
7966
|
+
var isShowcasePersistent = showcaseMode && showcasePersistentIds.has(overlay.id);
|
|
7967
|
+
var isShowcaseSpotlight = showcaseMode && showcaseSpotlightIds.has(overlay.id);
|
|
7968
|
+
var isShowcaseDormant = showcaseMode && !isShowcasePersistent && !isShowcaseSpotlight;
|
|
7969
|
+
var useShowcasePop = isShowcaseSpotlight;
|
|
7970
|
+
var opacity = useShowcasePop ? baseOpacity * beatOpacity(showcaseBeatPhase, showcaseBeatMs) : isShowcaseDormant ? 0 : visible ? baseOpacity : 0;
|
|
7971
|
+
var popScale = useShowcasePop ? beatScale(showcaseBeatPhase, showcaseBeatMs) : 1;
|
|
7816
7972
|
var sz = {
|
|
7817
7973
|
w: width,
|
|
7818
7974
|
h: height
|