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.
@@ -7190,6 +7190,33 @@ var OverlayRenderer = function OverlayRenderer(param) {
7190
7190
  })
7191
7191
  });
7192
7192
  };
7193
+ // src/utils/adcision.ts
7194
+ var ADCISION_API_BASE = "https://adstorm.co/api-adstorm-dev";
7195
+ function fetchAdcisionChannel(_0) {
7196
+ return _async_to_generator(function(channelId) {
7197
+ var apiBaseUrl, response;
7198
+ var _arguments = arguments;
7199
+ return _ts_generator(this, function(_state) {
7200
+ switch(_state.label){
7201
+ case 0:
7202
+ apiBaseUrl = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : ADCISION_API_BASE;
7203
+ return [
7204
+ 4,
7205
+ fetch("".concat(apiBaseUrl, "/adstorm/adcision/channels/").concat(channelId))
7206
+ ];
7207
+ case 1:
7208
+ response = _state.sent();
7209
+ if (!response.ok) {
7210
+ throw new Error("Failed to fetch adcision channel ".concat(channelId, ": ").concat(response.status, " ").concat(response.statusText));
7211
+ }
7212
+ return [
7213
+ 2,
7214
+ response.json()
7215
+ ];
7216
+ }
7217
+ });
7218
+ }).apply(this, arguments);
7219
+ }
7193
7220
  // src/ui/StormcloudVideoPlayer.tsx
7194
7221
  var import_jsx_runtime2 = require("react/jsx-runtime");
7195
7222
  var CRITICAL_PROPS = [
@@ -7209,7 +7236,7 @@ var PANEL_BASE_RIGHT_OFFSET = 10;
7209
7236
  var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props) {
7210
7237
  var _ref;
7211
7238
  var _aiLiveContext_context;
7212
- 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, [
7239
+ 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, [
7213
7240
  "src",
7214
7241
  "autoplay",
7215
7242
  "muted",
@@ -7238,12 +7265,14 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7238
7265
  "disableAds",
7239
7266
  "disableFiller",
7240
7267
  "swirlProjectId",
7268
+ "adcisionChannelId",
7241
7269
  "disableOverlays",
7242
7270
  "showAdsControl",
7243
7271
  "showOverlaysControl",
7244
7272
  "showAiContextControl",
7245
7273
  "showDebugControl"
7246
7274
  ]);
7275
+ var _ref1 = _sliced_to_array((0, import_react2.useState)(null), 2), adcisionSrc = _ref1[0], setAdcisionSrc = _ref1[1];
7247
7276
  var videoRef = (0, import_react2.useRef)(null);
7248
7277
  var playerRef = (0, import_react2.useRef)(null);
7249
7278
  var bufferingTimeoutRef = (0, import_react2.useRef)(null);
@@ -7443,21 +7472,43 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7443
7472
  var debugPanelBottomOffset = shouldShowEnhancedControls ? Math.max(74, 92 * responsiveScale) : Math.max(52, 58 * responsiveScale);
7444
7473
  var panelBaseRight = PANEL_BASE_RIGHT_OFFSET * responsiveScale;
7445
7474
  var debugPanelRightOffset = showAiPanel && !shouldStackPanels ? panelBaseRight + analyzerPanelWidth + panelGap : panelBaseRight;
7475
+ (0, import_react2.useEffect)(function() {
7476
+ if (!adcisionChannelId) {
7477
+ setAdcisionSrc(null);
7478
+ return;
7479
+ }
7480
+ var cancelled = false;
7481
+ fetchAdcisionChannel(adcisionChannelId).then(function(ch) {
7482
+ if (!cancelled) setAdcisionSrc(ch.stream_url);
7483
+ }).catch(function(err) {
7484
+ if (!cancelled) {
7485
+ console.warn("[StormcloudVideoPlayer] Failed to fetch adcision channel:", err);
7486
+ }
7487
+ });
7488
+ return function() {
7489
+ cancelled = true;
7490
+ };
7491
+ }, [
7492
+ adcisionChannelId
7493
+ ]);
7494
+ var effectiveSrc = adcisionChannelId ? adcisionSrc : src;
7446
7495
  var criticalPropsKey = (0, import_react2.useMemo)(function() {
7447
- return CRITICAL_PROPS.map(function(prop) {
7448
- return "".concat(prop, ":").concat(props[prop]);
7496
+ var baseParts = CRITICAL_PROPS.map(function(prop) {
7497
+ return prop === "src" ? "src:".concat(effectiveSrc) : "".concat(prop, ":").concat(props[prop]);
7449
7498
  }).join("|");
7499
+ return "".concat(baseParts, "|adcisionChannelId:").concat(adcisionChannelId !== null && adcisionChannelId !== void 0 ? adcisionChannelId : "");
7450
7500
  }, [
7451
- src,
7501
+ effectiveSrc,
7452
7502
  allowNativeHls,
7453
7503
  licenseKey,
7454
7504
  lowLatencyMode,
7455
- driftToleranceMs
7505
+ driftToleranceMs,
7506
+ adcisionChannelId
7456
7507
  ]);
7457
7508
  (0, import_react2.useEffect)(function() {
7458
7509
  if (typeof window === "undefined") return;
7459
7510
  var el = videoRef.current;
7460
- if (!el || !src) return;
7511
+ if (!el || !effectiveSrc) return;
7461
7512
  if (!licenseKey) {
7462
7513
  setShowLicenseWarning(true);
7463
7514
  setIsLoading(false);
@@ -7471,7 +7522,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7471
7522
  playerRef.current = null;
7472
7523
  }
7473
7524
  var cfg = {
7474
- src: src,
7525
+ src: effectiveSrc,
7475
7526
  videoElement: el
7476
7527
  };
7477
7528
  if (autoplay !== void 0) cfg.autoplay = autoplay;
@@ -7489,7 +7540,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7489
7540
  if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
7490
7541
  if (disableAds !== void 0) cfg.disableAds = disableAds;
7491
7542
  cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
7492
- if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7543
+ if (!adcisionChannelId && swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7493
7544
  var player = new StormcloudVideoPlayer(cfg);
7494
7545
  playerRef.current = player;
7495
7546
  player.load().then(function() {
@@ -7511,7 +7562,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7511
7562
  criticalPropsKey
7512
7563
  ]);
7513
7564
  (0, import_react2.useEffect)(function() {
7514
- if (!swirlProjectId) {
7565
+ if (!swirlProjectId || adcisionChannelId) {
7515
7566
  setOverlays([]);
7516
7567
  setOverlayCoordSpace(null);
7517
7568
  return;
@@ -7528,7 +7579,8 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7528
7579
  cancelled = true;
7529
7580
  };
7530
7581
  }, [
7531
- swirlProjectId
7582
+ swirlProjectId,
7583
+ adcisionChannelId
7532
7584
  ]);
7533
7585
  (0, import_react2.useEffect)(function() {
7534
7586
  if (!swirlProjectId) return;
@@ -7770,7 +7822,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7770
7822
  criticalPropsKey
7771
7823
  ]);
7772
7824
  (0, import_react2.useEffect)(function() {
7773
- if (!swirlProjectId) {
7825
+ if (!swirlProjectId || adcisionChannelId) {
7774
7826
  setShowAiPanel(false);
7775
7827
  setAiLiveContext({
7776
7828
  context: null,
@@ -7780,10 +7832,11 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7780
7832
  });
7781
7833
  }
7782
7834
  }, [
7783
- swirlProjectId
7835
+ swirlProjectId,
7836
+ adcisionChannelId
7784
7837
  ]);
7785
7838
  (0, import_react2.useEffect)(function() {
7786
- if (!showAiPanel || !swirlProjectId) return;
7839
+ if (!showAiPanel || !swirlProjectId || adcisionChannelId) return;
7787
7840
  var cancelled = false;
7788
7841
  var pollTimeoutId = null;
7789
7842
  var inFlight = false;
@@ -9283,6 +9336,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
9283
9336
  "poster",
9284
9337
  "children",
9285
9338
  "swirlProjectId",
9339
+ "adcisionChannelId",
9286
9340
  "disableOverlays",
9287
9341
  "showAdsControl",
9288
9342
  "showOverlaysControl",