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
|
@@ -5693,27 +5693,16 @@ var SWIRL_HD_AUTHORING_WIDTH = 1920;
|
|
|
5693
5693
|
var SWIRL_HD_AUTHORING_HEIGHT = 1080;
|
|
5694
5694
|
var NAB_DEMO_NAME_PREFIX = "NAB Demo \u2014 ";
|
|
5695
5695
|
function overlayAuthoringDimensions(overlay, decodeWidth, decodeHeight) {
|
|
5696
|
-
if (
|
|
5696
|
+
if (overlay.name.startsWith(NAB_DEMO_NAME_PREFIX)) {
|
|
5697
5697
|
return {
|
|
5698
|
-
width:
|
|
5699
|
-
height:
|
|
5700
|
-
};
|
|
5701
|
-
}
|
|
5702
|
-
if (!overlay.visible) {
|
|
5703
|
-
return {
|
|
5704
|
-
width: decodeWidth,
|
|
5705
|
-
height: decodeHeight
|
|
5698
|
+
width: SWIRL_HD_AUTHORING_WIDTH,
|
|
5699
|
+
height: SWIRL_HD_AUTHORING_HEIGHT
|
|
5706
5700
|
};
|
|
5707
5701
|
}
|
|
5708
|
-
|
|
5709
|
-
var extB = overlay.y + overlay.height;
|
|
5710
|
-
var EPS = 2;
|
|
5711
|
-
var exceedsDecode = extR > decodeWidth + EPS || extB > decodeHeight + EPS;
|
|
5712
|
-
var isNabDemo = overlay.name.startsWith(NAB_DEMO_NAME_PREFIX);
|
|
5713
|
-
if (exceedsDecode && isNabDemo) {
|
|
5702
|
+
if (!decodeWidth || !decodeHeight) {
|
|
5714
5703
|
return {
|
|
5715
|
-
width: SWIRL_HD_AUTHORING_WIDTH,
|
|
5716
|
-
height: SWIRL_HD_AUTHORING_HEIGHT
|
|
5704
|
+
width: decodeWidth || SWIRL_HD_AUTHORING_WIDTH,
|
|
5705
|
+
height: decodeHeight || SWIRL_HD_AUTHORING_HEIGHT
|
|
5717
5706
|
};
|
|
5718
5707
|
}
|
|
5719
5708
|
return {
|
|
@@ -5778,6 +5767,59 @@ function swirlProjectHasNabDemoMixedWithOther(overlays) {
|
|
|
5778
5767
|
}
|
|
5779
5768
|
return hasNab && hasOther;
|
|
5780
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
|
+
}
|
|
5781
5823
|
function inferSwirlOverlayCoordinateSpace(overlays, videoWidth, videoHeight) {
|
|
5782
5824
|
if (!videoWidth || !videoHeight) {
|
|
5783
5825
|
return {
|
|
@@ -5793,9 +5835,15 @@ function inferSwirlOverlayCoordinateSpace(overlays, videoWidth, videoHeight) {
|
|
|
5793
5835
|
}
|
|
5794
5836
|
var _overlayExtents = overlayExtents(overlays), maxR = _overlayExtents.maxR, maxB = _overlayExtents.maxB;
|
|
5795
5837
|
var EPS = 1;
|
|
5796
|
-
|
|
5797
|
-
|
|
5838
|
+
if (maxR <= 0 || maxB <= 0) {
|
|
5839
|
+
return {
|
|
5840
|
+
width: videoWidth,
|
|
5841
|
+
height: videoHeight
|
|
5842
|
+
};
|
|
5843
|
+
}
|
|
5798
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;
|
|
5799
5847
|
var decodeLargerThanHd = videoWidth > SWIRL_HD_AUTHORING_WIDTH + EPS || videoHeight > SWIRL_HD_AUTHORING_HEIGHT + EPS;
|
|
5800
5848
|
if (fitsHdCanvas && (decodeLargerThanHd || exceedsDecode && !mixed)) {
|
|
5801
5849
|
return {
|
|
@@ -5803,6 +5851,19 @@ function inferSwirlOverlayCoordinateSpace(overlays, videoWidth, videoHeight) {
|
|
|
5803
5851
|
height: SWIRL_HD_AUTHORING_HEIGHT
|
|
5804
5852
|
};
|
|
5805
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
|
+
}
|
|
5806
5867
|
return {
|
|
5807
5868
|
width: videoWidth,
|
|
5808
5869
|
height: videoHeight
|
|
@@ -7307,11 +7368,19 @@ function hexToRgb(hex) {
|
|
|
7307
7368
|
return "".concat(num >> 16 & 255, ",").concat(num >> 8 & 255, ",").concat(num & 255);
|
|
7308
7369
|
}
|
|
7309
7370
|
var FADE_DURATION_MS = 1e3;
|
|
7310
|
-
var SHOWCASE_CYCLE_MS_DEFAULT =
|
|
7311
|
-
var
|
|
7312
|
-
var
|
|
7313
|
-
var
|
|
7314
|
-
var
|
|
7371
|
+
var SHOWCASE_CYCLE_MS_DEFAULT = 36e3;
|
|
7372
|
+
var SHOWCASE_MIN_BEAT_MS = 6e3;
|
|
7373
|
+
var BEAT_POP_IN_MS = 520;
|
|
7374
|
+
var BEAT_POP_OUT_MS = 520;
|
|
7375
|
+
var SHOWCASE_PERSISTENT_TYPES = /* @__PURE__ */ new Set([
|
|
7376
|
+
"scroller",
|
|
7377
|
+
"breaking_news",
|
|
7378
|
+
"image",
|
|
7379
|
+
"text",
|
|
7380
|
+
"shape",
|
|
7381
|
+
"countdown",
|
|
7382
|
+
"qr_code"
|
|
7383
|
+
]);
|
|
7315
7384
|
function easeOutCubic(t) {
|
|
7316
7385
|
var u = 1 - t;
|
|
7317
7386
|
return 1 - u * u * u;
|
|
@@ -7324,38 +7393,108 @@ function easeOutBack(t) {
|
|
|
7324
7393
|
var c3 = c1 + 1;
|
|
7325
7394
|
return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
|
|
7326
7395
|
}
|
|
7327
|
-
function
|
|
7328
|
-
if (phase <
|
|
7329
|
-
|
|
7330
|
-
|
|
7396
|
+
function beatOpacity(phase, beatMs) {
|
|
7397
|
+
if (phase < BEAT_POP_IN_MS) return easeOutCubic(phase / BEAT_POP_IN_MS);
|
|
7398
|
+
var holdEnd = beatMs - BEAT_POP_OUT_MS;
|
|
7399
|
+
if (phase >= holdEnd) {
|
|
7400
|
+
return Math.max(0, 1 - easeInCubic((phase - holdEnd) / BEAT_POP_OUT_MS));
|
|
7331
7401
|
}
|
|
7332
7402
|
return 1;
|
|
7333
7403
|
}
|
|
7334
|
-
function
|
|
7335
|
-
if (phase <
|
|
7336
|
-
return Math.min(1, 0.
|
|
7404
|
+
function beatScale(phase, beatMs) {
|
|
7405
|
+
if (phase < BEAT_POP_IN_MS) {
|
|
7406
|
+
return Math.min(1, 0.92 + 0.08 * easeOutBack(phase / BEAT_POP_IN_MS));
|
|
7337
7407
|
}
|
|
7338
|
-
|
|
7339
|
-
|
|
7408
|
+
var holdEnd = beatMs - BEAT_POP_OUT_MS;
|
|
7409
|
+
if (phase >= holdEnd) {
|
|
7410
|
+
return 1 - 0.06 * easeInCubic((phase - holdEnd) / BEAT_POP_OUT_MS);
|
|
7340
7411
|
}
|
|
7341
7412
|
return 1;
|
|
7342
7413
|
}
|
|
7343
|
-
function
|
|
7344
|
-
var
|
|
7414
|
+
function partitionShowcase(overlays) {
|
|
7415
|
+
var visible = overlays.filter(function(o) {
|
|
7416
|
+
return o.visible;
|
|
7417
|
+
});
|
|
7418
|
+
var persistent = [];
|
|
7419
|
+
var spotlight = [];
|
|
7420
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
7421
|
+
try {
|
|
7422
|
+
for(var _iterator = visible[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
7423
|
+
var o = _step.value;
|
|
7424
|
+
if (SHOWCASE_PERSISTENT_TYPES.has(o.type)) persistent.push(o);
|
|
7425
|
+
else spotlight.push(o);
|
|
7426
|
+
}
|
|
7427
|
+
} catch (err) {
|
|
7428
|
+
_didIteratorError = true;
|
|
7429
|
+
_iteratorError = err;
|
|
7430
|
+
} finally{
|
|
7431
|
+
try {
|
|
7432
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
7433
|
+
_iterator.return();
|
|
7434
|
+
}
|
|
7435
|
+
} finally{
|
|
7436
|
+
if (_didIteratorError) {
|
|
7437
|
+
throw _iteratorError;
|
|
7438
|
+
}
|
|
7439
|
+
}
|
|
7440
|
+
}
|
|
7441
|
+
spotlight.sort(function(a, b) {
|
|
7442
|
+
return a.z_index - b.z_index || a.id - b.id;
|
|
7443
|
+
});
|
|
7444
|
+
var beats = [];
|
|
7445
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
7446
|
+
try {
|
|
7447
|
+
for(var _iterator1 = spotlight[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
7448
|
+
var o1 = _step1.value;
|
|
7449
|
+
beats.push([
|
|
7450
|
+
o1
|
|
7451
|
+
]);
|
|
7452
|
+
}
|
|
7453
|
+
} catch (err) {
|
|
7454
|
+
_didIteratorError1 = true;
|
|
7455
|
+
_iteratorError1 = err;
|
|
7456
|
+
} finally{
|
|
7457
|
+
try {
|
|
7458
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
7459
|
+
_iterator1.return();
|
|
7460
|
+
}
|
|
7461
|
+
} finally{
|
|
7462
|
+
if (_didIteratorError1) {
|
|
7463
|
+
throw _iteratorError1;
|
|
7464
|
+
}
|
|
7465
|
+
}
|
|
7466
|
+
}
|
|
7467
|
+
return {
|
|
7468
|
+
persistent: persistent,
|
|
7469
|
+
beats: beats
|
|
7470
|
+
};
|
|
7471
|
+
}
|
|
7472
|
+
function useShowcaseBeat(enabled, cycleMs, beats) {
|
|
7473
|
+
var safeBeats = Math.max(1, beats);
|
|
7474
|
+
var beatMs = Math.max(SHOWCASE_MIN_BEAT_MS, Math.floor(cycleMs / safeBeats));
|
|
7475
|
+
var totalMs = beatMs * safeBeats;
|
|
7476
|
+
var _ref = _sliced_to_array((0, import_react.useState)(function() {
|
|
7477
|
+
return Date.now();
|
|
7478
|
+
}), 2), now = _ref[0], setNow = _ref[1];
|
|
7345
7479
|
(0, import_react.useEffect)(function() {
|
|
7346
7480
|
if (!enabled) return;
|
|
7347
|
-
setPhase(Date.now() % cycleMs);
|
|
7348
7481
|
var id = window.setInterval(function() {
|
|
7349
|
-
|
|
7350
|
-
},
|
|
7482
|
+
return setNow(Date.now());
|
|
7483
|
+
}, 64);
|
|
7351
7484
|
return function() {
|
|
7352
7485
|
return clearInterval(id);
|
|
7353
7486
|
};
|
|
7354
7487
|
}, [
|
|
7355
|
-
enabled
|
|
7356
|
-
cycleMs
|
|
7488
|
+
enabled
|
|
7357
7489
|
]);
|
|
7358
|
-
|
|
7490
|
+
var phase = now % totalMs;
|
|
7491
|
+
var beatIndex = Math.min(safeBeats - 1, Math.floor(phase / beatMs));
|
|
7492
|
+
var beatPhase = phase - beatIndex * beatMs;
|
|
7493
|
+
return {
|
|
7494
|
+
beatIndex: beatIndex,
|
|
7495
|
+
beatPhase: beatPhase,
|
|
7496
|
+
beatMs: beatMs
|
|
7497
|
+
};
|
|
7359
7498
|
}
|
|
7360
7499
|
var OverlayRenderer = function OverlayRenderer(param) {
|
|
7361
7500
|
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;
|
|
@@ -7363,7 +7502,28 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7363
7502
|
var rafRef = (0, import_react.useRef)(null);
|
|
7364
7503
|
var _ref1 = _sliced_to_array((0, import_react.useState)(/* @__PURE__ */ new Map()), 2), fadeMap = _ref1[0], setFadeMap = _ref1[1];
|
|
7365
7504
|
var removeTimers = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
7366
|
-
var
|
|
7505
|
+
var _ref2 = (0, import_react.useMemo)(function() {
|
|
7506
|
+
return partitionShowcase(overlays);
|
|
7507
|
+
}, [
|
|
7508
|
+
overlays
|
|
7509
|
+
]), showcasePersistent = _ref2.persistent, showcaseBeats = _ref2.beats;
|
|
7510
|
+
var _useShowcaseBeat = useShowcaseBeat(showcaseMode, showcaseCycleMs, showcaseBeats.length), showcaseBeatIndex = _useShowcaseBeat.beatIndex, showcaseBeatPhase = _useShowcaseBeat.beatPhase, showcaseBeatMs = _useShowcaseBeat.beatMs;
|
|
7511
|
+
var showcasePersistentIds = (0, import_react.useMemo)(function() {
|
|
7512
|
+
return new Set(showcasePersistent.map(function(o) {
|
|
7513
|
+
return o.id;
|
|
7514
|
+
}));
|
|
7515
|
+
}, [
|
|
7516
|
+
showcasePersistent
|
|
7517
|
+
]);
|
|
7518
|
+
var showcaseSpotlightIds = (0, import_react.useMemo)(function() {
|
|
7519
|
+
var beat = showcaseBeats[showcaseBeatIndex];
|
|
7520
|
+
return new Set((beat !== null && beat !== void 0 ? beat : []).map(function(o) {
|
|
7521
|
+
return o.id;
|
|
7522
|
+
}));
|
|
7523
|
+
}, [
|
|
7524
|
+
showcaseBeats,
|
|
7525
|
+
showcaseBeatIndex
|
|
7526
|
+
]);
|
|
7367
7527
|
var updateDims = (0, import_react.useCallback)(function() {
|
|
7368
7528
|
var video = videoRef.current;
|
|
7369
7529
|
if (video) {
|
|
@@ -7396,10 +7556,9 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7396
7556
|
]);
|
|
7397
7557
|
var activeOverlays = (0, import_react.useMemo)(function() {
|
|
7398
7558
|
if (showcaseMode) {
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
});
|
|
7559
|
+
var _showcaseBeats_showcaseBeatIndex;
|
|
7560
|
+
var beat = (_showcaseBeats_showcaseBeatIndex = showcaseBeats[showcaseBeatIndex]) !== null && _showcaseBeats_showcaseBeatIndex !== void 0 ? _showcaseBeats_showcaseBeatIndex : [];
|
|
7561
|
+
return _to_consumable_array(showcasePersistent).concat(_to_consumable_array(beat));
|
|
7403
7562
|
}
|
|
7404
7563
|
return overlays.filter(function(o) {
|
|
7405
7564
|
return isOverlayActive(o, currentTime);
|
|
@@ -7408,14 +7567,9 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7408
7567
|
overlays,
|
|
7409
7568
|
currentTime,
|
|
7410
7569
|
showcaseMode,
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
return new Set(activeOverlays.map(function(o) {
|
|
7415
|
-
return o.id;
|
|
7416
|
-
}));
|
|
7417
|
-
}, [
|
|
7418
|
-
activeOverlays
|
|
7570
|
+
showcasePersistent,
|
|
7571
|
+
showcaseBeats,
|
|
7572
|
+
showcaseBeatIndex
|
|
7419
7573
|
]);
|
|
7420
7574
|
(0, import_react.useLayoutEffect)(function() {
|
|
7421
7575
|
var activeIds = new Set(activeOverlays.map(function(o) {
|
|
@@ -7610,10 +7764,12 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7610
7764
|
var width = overlay.width * scaleX;
|
|
7611
7765
|
var height = overlay.height * scaleY;
|
|
7612
7766
|
var baseOpacity = Math.max(0, Math.min(100, overlay.opacity)) / 100;
|
|
7613
|
-
var
|
|
7614
|
-
var
|
|
7615
|
-
var
|
|
7616
|
-
var
|
|
7767
|
+
var isShowcasePersistent = showcaseMode && showcasePersistentIds.has(overlay.id);
|
|
7768
|
+
var isShowcaseSpotlight = showcaseMode && showcaseSpotlightIds.has(overlay.id);
|
|
7769
|
+
var isShowcaseDormant = showcaseMode && !isShowcasePersistent && !isShowcaseSpotlight;
|
|
7770
|
+
var useShowcasePop = isShowcaseSpotlight;
|
|
7771
|
+
var opacity = useShowcasePop ? baseOpacity * beatOpacity(showcaseBeatPhase, showcaseBeatMs) : isShowcaseDormant ? 0 : visible ? baseOpacity : 0;
|
|
7772
|
+
var popScale = useShowcasePop ? beatScale(showcaseBeatPhase, showcaseBeatMs) : 1;
|
|
7617
7773
|
var sz = {
|
|
7618
7774
|
w: width,
|
|
7619
7775
|
h: height
|