stormcloud-video-player 0.7.17 → 0.7.18
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 +67 -13
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +68 -14
- package/lib/index.js.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +67 -13
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -0
- package/lib/utils/adcision.cjs +253 -0
- package/lib/utils/adcision.cjs.map +1 -0
- package/lib/utils/adcision.d.cts +23 -0
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -270,6 +270,7 @@ type StormcloudVideoPlayerProps = Omit<StormcloudVideoPlayerConfig, "videoElemen
|
|
|
270
270
|
wrapperStyle?: React.CSSProperties;
|
|
271
271
|
licenseKey?: string;
|
|
272
272
|
swirlProjectId?: number;
|
|
273
|
+
adcisionChannelId?: number;
|
|
273
274
|
disableOverlays?: boolean;
|
|
274
275
|
showAdsControl?: boolean;
|
|
275
276
|
showOverlaysControl?: boolean;
|
package/lib/index.d.ts
CHANGED
|
@@ -270,6 +270,7 @@ type StormcloudVideoPlayerProps = Omit<StormcloudVideoPlayerConfig, "videoElemen
|
|
|
270
270
|
wrapperStyle?: React.CSSProperties;
|
|
271
271
|
licenseKey?: string;
|
|
272
272
|
swirlProjectId?: number;
|
|
273
|
+
adcisionChannelId?: number;
|
|
273
274
|
disableOverlays?: boolean;
|
|
274
275
|
showAdsControl?: boolean;
|
|
275
276
|
showOverlaysControl?: boolean;
|
package/lib/index.js
CHANGED
|
@@ -367,7 +367,7 @@ function _ts_values(o) {
|
|
|
367
367
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
368
368
|
}
|
|
369
369
|
// src/ui/StormcloudVideoPlayer.tsx
|
|
370
|
-
import React2, { useEffect as useEffect2, useRef as useRef2, useMemo as useMemo2, useCallback as useCallback2 } from "react";
|
|
370
|
+
import React2, { useEffect as useEffect2, useRef as useRef2, useMemo as useMemo2, useCallback as useCallback2, useState as useState2 } from "react";
|
|
371
371
|
// src/player/StormcloudVideoPlayer.ts
|
|
372
372
|
import Hls from "hls.js";
|
|
373
373
|
// src/sdk/vastParser.ts
|
|
@@ -7202,6 +7202,33 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7202
7202
|
})
|
|
7203
7203
|
});
|
|
7204
7204
|
};
|
|
7205
|
+
// src/utils/adcision.ts
|
|
7206
|
+
var ADCISION_API_BASE = "https://adstorm.co/api-adstorm-dev";
|
|
7207
|
+
function fetchAdcisionChannel(_0) {
|
|
7208
|
+
return _async_to_generator(function(channelId) {
|
|
7209
|
+
var apiBaseUrl, response;
|
|
7210
|
+
var _arguments = arguments;
|
|
7211
|
+
return _ts_generator(this, function(_state) {
|
|
7212
|
+
switch(_state.label){
|
|
7213
|
+
case 0:
|
|
7214
|
+
apiBaseUrl = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : ADCISION_API_BASE;
|
|
7215
|
+
return [
|
|
7216
|
+
4,
|
|
7217
|
+
fetch("".concat(apiBaseUrl, "/adstorm/adcision/channels/").concat(channelId))
|
|
7218
|
+
];
|
|
7219
|
+
case 1:
|
|
7220
|
+
response = _state.sent();
|
|
7221
|
+
if (!response.ok) {
|
|
7222
|
+
throw new Error("Failed to fetch adcision channel ".concat(channelId, ": ").concat(response.status, " ").concat(response.statusText));
|
|
7223
|
+
}
|
|
7224
|
+
return [
|
|
7225
|
+
2,
|
|
7226
|
+
response.json()
|
|
7227
|
+
];
|
|
7228
|
+
}
|
|
7229
|
+
});
|
|
7230
|
+
}).apply(this, arguments);
|
|
7231
|
+
}
|
|
7205
7232
|
// src/ui/StormcloudVideoPlayer.tsx
|
|
7206
7233
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
7207
7234
|
var CRITICAL_PROPS = [
|
|
@@ -7221,7 +7248,7 @@ var PANEL_BASE_RIGHT_OFFSET = 10;
|
|
|
7221
7248
|
var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
7222
7249
|
var _ref;
|
|
7223
7250
|
var _aiLiveContext_context;
|
|
7224
|
-
var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, minSegmentsBeforePlay = props.minSegmentsBeforePlay, disableAds = props.disableAds, disableFiller = props.disableFiller, swirlProjectId = props.swirlProjectId, disableOverlays = props.disableOverlays, showAdsControl = props.showAdsControl, showOverlaysControl = props.showOverlaysControl, showAiContextControl = props.showAiContextControl, showDebugControl = props.showDebugControl, restVideoAttrs = _object_without_properties(props, [
|
|
7251
|
+
var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, minSegmentsBeforePlay = props.minSegmentsBeforePlay, disableAds = props.disableAds, disableFiller = props.disableFiller, swirlProjectId = props.swirlProjectId, adcisionChannelId = props.adcisionChannelId, disableOverlays = props.disableOverlays, showAdsControl = props.showAdsControl, showOverlaysControl = props.showOverlaysControl, showAiContextControl = props.showAiContextControl, showDebugControl = props.showDebugControl, restVideoAttrs = _object_without_properties(props, [
|
|
7225
7252
|
"src",
|
|
7226
7253
|
"autoplay",
|
|
7227
7254
|
"muted",
|
|
@@ -7250,12 +7277,14 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
7250
7277
|
"disableAds",
|
|
7251
7278
|
"disableFiller",
|
|
7252
7279
|
"swirlProjectId",
|
|
7280
|
+
"adcisionChannelId",
|
|
7253
7281
|
"disableOverlays",
|
|
7254
7282
|
"showAdsControl",
|
|
7255
7283
|
"showOverlaysControl",
|
|
7256
7284
|
"showAiContextControl",
|
|
7257
7285
|
"showDebugControl"
|
|
7258
7286
|
]);
|
|
7287
|
+
var _useState2 = _sliced_to_array(useState2(null), 2), adcisionSrc = _useState2[0], setAdcisionSrc = _useState2[1];
|
|
7259
7288
|
var videoRef = useRef2(null);
|
|
7260
7289
|
var playerRef = useRef2(null);
|
|
7261
7290
|
var bufferingTimeoutRef = useRef2(null);
|
|
@@ -7455,21 +7484,43 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
7455
7484
|
var debugPanelBottomOffset = shouldShowEnhancedControls ? Math.max(74, 92 * responsiveScale) : Math.max(52, 58 * responsiveScale);
|
|
7456
7485
|
var panelBaseRight = PANEL_BASE_RIGHT_OFFSET * responsiveScale;
|
|
7457
7486
|
var debugPanelRightOffset = showAiPanel && !shouldStackPanels ? panelBaseRight + analyzerPanelWidth + panelGap : panelBaseRight;
|
|
7487
|
+
useEffect2(function() {
|
|
7488
|
+
if (!adcisionChannelId) {
|
|
7489
|
+
setAdcisionSrc(null);
|
|
7490
|
+
return;
|
|
7491
|
+
}
|
|
7492
|
+
var cancelled = false;
|
|
7493
|
+
fetchAdcisionChannel(adcisionChannelId).then(function(ch) {
|
|
7494
|
+
if (!cancelled) setAdcisionSrc(ch.stream_url);
|
|
7495
|
+
}).catch(function(err) {
|
|
7496
|
+
if (!cancelled) {
|
|
7497
|
+
console.warn("[StormcloudVideoPlayer] Failed to fetch adcision channel:", err);
|
|
7498
|
+
}
|
|
7499
|
+
});
|
|
7500
|
+
return function() {
|
|
7501
|
+
cancelled = true;
|
|
7502
|
+
};
|
|
7503
|
+
}, [
|
|
7504
|
+
adcisionChannelId
|
|
7505
|
+
]);
|
|
7506
|
+
var effectiveSrc = adcisionChannelId ? adcisionSrc : src;
|
|
7458
7507
|
var criticalPropsKey = useMemo2(function() {
|
|
7459
|
-
|
|
7460
|
-
return "".concat(prop, ":").concat(props[prop]);
|
|
7508
|
+
var baseParts = CRITICAL_PROPS.map(function(prop) {
|
|
7509
|
+
return prop === "src" ? "src:".concat(effectiveSrc) : "".concat(prop, ":").concat(props[prop]);
|
|
7461
7510
|
}).join("|");
|
|
7511
|
+
return "".concat(baseParts, "|adcisionChannelId:").concat(adcisionChannelId !== null && adcisionChannelId !== void 0 ? adcisionChannelId : "");
|
|
7462
7512
|
}, [
|
|
7463
|
-
|
|
7513
|
+
effectiveSrc,
|
|
7464
7514
|
allowNativeHls,
|
|
7465
7515
|
licenseKey,
|
|
7466
7516
|
lowLatencyMode,
|
|
7467
|
-
driftToleranceMs
|
|
7517
|
+
driftToleranceMs,
|
|
7518
|
+
adcisionChannelId
|
|
7468
7519
|
]);
|
|
7469
7520
|
useEffect2(function() {
|
|
7470
7521
|
if (typeof window === "undefined") return;
|
|
7471
7522
|
var el = videoRef.current;
|
|
7472
|
-
if (!el || !
|
|
7523
|
+
if (!el || !effectiveSrc) return;
|
|
7473
7524
|
if (!licenseKey) {
|
|
7474
7525
|
setShowLicenseWarning(true);
|
|
7475
7526
|
setIsLoading(false);
|
|
@@ -7483,7 +7534,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
7483
7534
|
playerRef.current = null;
|
|
7484
7535
|
}
|
|
7485
7536
|
var cfg = {
|
|
7486
|
-
src:
|
|
7537
|
+
src: effectiveSrc,
|
|
7487
7538
|
videoElement: el
|
|
7488
7539
|
};
|
|
7489
7540
|
if (autoplay !== void 0) cfg.autoplay = autoplay;
|
|
@@ -7501,7 +7552,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
7501
7552
|
if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
|
|
7502
7553
|
if (disableAds !== void 0) cfg.disableAds = disableAds;
|
|
7503
7554
|
cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
|
|
7504
|
-
if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
|
|
7555
|
+
if (!adcisionChannelId && swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
|
|
7505
7556
|
var player = new StormcloudVideoPlayer(cfg);
|
|
7506
7557
|
playerRef.current = player;
|
|
7507
7558
|
player.load().then(function() {
|
|
@@ -7523,7 +7574,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
7523
7574
|
criticalPropsKey
|
|
7524
7575
|
]);
|
|
7525
7576
|
useEffect2(function() {
|
|
7526
|
-
if (!swirlProjectId) {
|
|
7577
|
+
if (!swirlProjectId || adcisionChannelId) {
|
|
7527
7578
|
setOverlays([]);
|
|
7528
7579
|
setOverlayCoordSpace(null);
|
|
7529
7580
|
return;
|
|
@@ -7540,7 +7591,8 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
7540
7591
|
cancelled = true;
|
|
7541
7592
|
};
|
|
7542
7593
|
}, [
|
|
7543
|
-
swirlProjectId
|
|
7594
|
+
swirlProjectId,
|
|
7595
|
+
adcisionChannelId
|
|
7544
7596
|
]);
|
|
7545
7597
|
useEffect2(function() {
|
|
7546
7598
|
if (!swirlProjectId) return;
|
|
@@ -7782,7 +7834,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
7782
7834
|
criticalPropsKey
|
|
7783
7835
|
]);
|
|
7784
7836
|
useEffect2(function() {
|
|
7785
|
-
if (!swirlProjectId) {
|
|
7837
|
+
if (!swirlProjectId || adcisionChannelId) {
|
|
7786
7838
|
setShowAiPanel(false);
|
|
7787
7839
|
setAiLiveContext({
|
|
7788
7840
|
context: null,
|
|
@@ -7792,10 +7844,11 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
7792
7844
|
});
|
|
7793
7845
|
}
|
|
7794
7846
|
}, [
|
|
7795
|
-
swirlProjectId
|
|
7847
|
+
swirlProjectId,
|
|
7848
|
+
adcisionChannelId
|
|
7796
7849
|
]);
|
|
7797
7850
|
useEffect2(function() {
|
|
7798
|
-
if (!showAiPanel || !swirlProjectId) return;
|
|
7851
|
+
if (!showAiPanel || !swirlProjectId || adcisionChannelId) return;
|
|
7799
7852
|
var cancelled = false;
|
|
7800
7853
|
var pollTimeoutId = null;
|
|
7801
7854
|
var inFlight = false;
|
|
@@ -9295,6 +9348,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
|
|
|
9295
9348
|
"poster",
|
|
9296
9349
|
"children",
|
|
9297
9350
|
"swirlProjectId",
|
|
9351
|
+
"adcisionChannelId",
|
|
9298
9352
|
"disableOverlays",
|
|
9299
9353
|
"showAdsControl",
|
|
9300
9354
|
"showOverlaysControl",
|