stormcloud-video-player 0.7.16 → 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/lib/index.d.cts CHANGED
@@ -270,6 +270,12 @@ type StormcloudVideoPlayerProps = Omit<StormcloudVideoPlayerConfig, "videoElemen
270
270
  wrapperStyle?: React.CSSProperties;
271
271
  licenseKey?: string;
272
272
  swirlProjectId?: number;
273
+ adcisionChannelId?: number;
274
+ disableOverlays?: boolean;
275
+ showAdsControl?: boolean;
276
+ showOverlaysControl?: boolean;
277
+ showAiContextControl?: boolean;
278
+ showDebugControl?: boolean;
273
279
  };
274
280
  declare const StormcloudVideoPlayerComponent: React.FC<StormcloudVideoPlayerProps>;
275
281
 
package/lib/index.d.ts CHANGED
@@ -270,6 +270,12 @@ type StormcloudVideoPlayerProps = Omit<StormcloudVideoPlayerConfig, "videoElemen
270
270
  wrapperStyle?: React.CSSProperties;
271
271
  licenseKey?: string;
272
272
  swirlProjectId?: number;
273
+ adcisionChannelId?: number;
274
+ disableOverlays?: boolean;
275
+ showAdsControl?: boolean;
276
+ showOverlaysControl?: boolean;
277
+ showAiContextControl?: boolean;
278
+ showDebugControl?: boolean;
273
279
  };
274
280
  declare const StormcloudVideoPlayerComponent: React.FC<StormcloudVideoPlayerProps>;
275
281
 
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
@@ -5607,7 +5607,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5607
5607
  return StormcloudVideoPlayer;
5608
5608
  }();
5609
5609
  // src/ui/StormcloudVideoPlayer.tsx
5610
- import { FaPlay, FaPause, FaVolumeUp, FaVolumeMute, FaVolumeDown, FaExpand, FaCompress, FaCog, FaTimes, FaCopy } from "react-icons/fa";
5610
+ import { FaPlay, FaPause, FaVolumeUp, FaVolumeMute, FaVolumeDown, FaExpand, FaCompress, FaCog, FaTimes, FaCopy, FaLayerGroup } from "react-icons/fa";
5611
5611
  // src/ui/OverlayRenderer.tsx
5612
5612
  import React, { useEffect, useRef, useState, useCallback, useMemo, useId } from "react";
5613
5613
  // src/utils/overlays.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, 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",
@@ -7249,8 +7276,15 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7249
7276
  "minSegmentsBeforePlay",
7250
7277
  "disableAds",
7251
7278
  "disableFiller",
7252
- "swirlProjectId"
7279
+ "swirlProjectId",
7280
+ "adcisionChannelId",
7281
+ "disableOverlays",
7282
+ "showAdsControl",
7283
+ "showOverlaysControl",
7284
+ "showAiContextControl",
7285
+ "showDebugControl"
7253
7286
  ]);
7287
+ var _useState2 = _sliced_to_array(useState2(null), 2), adcisionSrc = _useState2[0], setAdcisionSrc = _useState2[1];
7254
7288
  var videoRef = useRef2(null);
7255
7289
  var playerRef = useRef2(null);
7256
7290
  var bufferingTimeoutRef = useRef2(null);
@@ -7286,12 +7320,13 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7286
7320
  var _React2_useState22 = _sliced_to_array(React2.useState([]), 2), debugMarkers = _React2_useState22[0], setDebugMarkers = _React2_useState22[1];
7287
7321
  var _React2_useState23 = _sliced_to_array(React2.useState(false), 2), showAiPanel = _React2_useState23[0], setShowAiPanel = _React2_useState23[1];
7288
7322
  var _React2_useState24 = _sliced_to_array(React2.useState(disableAds !== null && disableAds !== void 0 ? disableAds : false), 2), adsDisabled = _React2_useState24[0], setAdsDisabled = _React2_useState24[1];
7289
- var _React2_useState25 = _sliced_to_array(React2.useState({
7323
+ var _React2_useState25 = _sliced_to_array(React2.useState(disableOverlays !== null && disableOverlays !== void 0 ? disableOverlays : false), 2), overlaysDisabled = _React2_useState25[0], setOverlaysDisabled = _React2_useState25[1];
7324
+ var _React2_useState26 = _sliced_to_array(React2.useState({
7290
7325
  context: null,
7291
7326
  isLoading: false,
7292
7327
  error: null,
7293
7328
  lastPolledAt: null
7294
- }), 2), aiLiveContext = _React2_useState25[0], setAiLiveContext = _React2_useState25[1];
7329
+ }), 2), aiLiveContext = _React2_useState26[0], setAiLiveContext = _React2_useState26[1];
7295
7330
  var getResponsiveScale = function getResponsiveScale() {
7296
7331
  if (viewportWidth < 480) return 0.7;
7297
7332
  if (viewportWidth < 768) return 0.8;
@@ -7449,21 +7484,43 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7449
7484
  var debugPanelBottomOffset = shouldShowEnhancedControls ? Math.max(74, 92 * responsiveScale) : Math.max(52, 58 * responsiveScale);
7450
7485
  var panelBaseRight = PANEL_BASE_RIGHT_OFFSET * responsiveScale;
7451
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;
7452
7507
  var criticalPropsKey = useMemo2(function() {
7453
- return CRITICAL_PROPS.map(function(prop) {
7454
- 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]);
7455
7510
  }).join("|");
7511
+ return "".concat(baseParts, "|adcisionChannelId:").concat(adcisionChannelId !== null && adcisionChannelId !== void 0 ? adcisionChannelId : "");
7456
7512
  }, [
7457
- src,
7513
+ effectiveSrc,
7458
7514
  allowNativeHls,
7459
7515
  licenseKey,
7460
7516
  lowLatencyMode,
7461
- driftToleranceMs
7517
+ driftToleranceMs,
7518
+ adcisionChannelId
7462
7519
  ]);
7463
7520
  useEffect2(function() {
7464
7521
  if (typeof window === "undefined") return;
7465
7522
  var el = videoRef.current;
7466
- if (!el || !src) return;
7523
+ if (!el || !effectiveSrc) return;
7467
7524
  if (!licenseKey) {
7468
7525
  setShowLicenseWarning(true);
7469
7526
  setIsLoading(false);
@@ -7477,7 +7534,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7477
7534
  playerRef.current = null;
7478
7535
  }
7479
7536
  var cfg = {
7480
- src: src,
7537
+ src: effectiveSrc,
7481
7538
  videoElement: el
7482
7539
  };
7483
7540
  if (autoplay !== void 0) cfg.autoplay = autoplay;
@@ -7495,7 +7552,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7495
7552
  if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
7496
7553
  if (disableAds !== void 0) cfg.disableAds = disableAds;
7497
7554
  cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
7498
- if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7555
+ if (!adcisionChannelId && swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7499
7556
  var player = new StormcloudVideoPlayer(cfg);
7500
7557
  playerRef.current = player;
7501
7558
  player.load().then(function() {
@@ -7517,7 +7574,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7517
7574
  criticalPropsKey
7518
7575
  ]);
7519
7576
  useEffect2(function() {
7520
- if (!swirlProjectId) {
7577
+ if (!swirlProjectId || adcisionChannelId) {
7521
7578
  setOverlays([]);
7522
7579
  setOverlayCoordSpace(null);
7523
7580
  return;
@@ -7534,7 +7591,8 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7534
7591
  cancelled = true;
7535
7592
  };
7536
7593
  }, [
7537
- swirlProjectId
7594
+ swirlProjectId,
7595
+ adcisionChannelId
7538
7596
  ]);
7539
7597
  useEffect2(function() {
7540
7598
  if (!swirlProjectId) return;
@@ -7776,7 +7834,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7776
7834
  criticalPropsKey
7777
7835
  ]);
7778
7836
  useEffect2(function() {
7779
- if (!swirlProjectId) {
7837
+ if (!swirlProjectId || adcisionChannelId) {
7780
7838
  setShowAiPanel(false);
7781
7839
  setAiLiveContext({
7782
7840
  context: null,
@@ -7786,10 +7844,11 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7786
7844
  });
7787
7845
  }
7788
7846
  }, [
7789
- swirlProjectId
7847
+ swirlProjectId,
7848
+ adcisionChannelId
7790
7849
  ]);
7791
7850
  useEffect2(function() {
7792
- if (!showAiPanel || !swirlProjectId) return;
7851
+ if (!showAiPanel || !swirlProjectId || adcisionChannelId) return;
7793
7852
  var cancelled = false;
7794
7853
  var pollTimeoutId = null;
7795
7854
  var inFlight = false;
@@ -7966,7 +8025,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7966
8025
  }, restVideoAttrs), {
7967
8026
  children: children
7968
8027
  })),
7969
- overlays.length > 0 && !adStatus.showAds && /* @__PURE__ */ jsx2(OverlayRenderer, {
8028
+ overlays.length > 0 && !adStatus.showAds && !overlaysDisabled && /* @__PURE__ */ jsx2(OverlayRenderer, {
7970
8029
  overlays: overlays,
7971
8030
  currentTime: currentTime,
7972
8031
  videoRef: videoRef,
@@ -8778,7 +8837,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
8778
8837
  gap: "".concat(8 * responsiveScale, "px")
8779
8838
  },
8780
8839
  children: [
8781
- /* @__PURE__ */ jsx2("button", {
8840
+ (showAdsControl !== null && showAdsControl !== void 0 ? showAdsControl : true) && /* @__PURE__ */ jsx2("button", {
8782
8841
  className: "sc-ctrl-btn",
8783
8842
  onClick: function onClick() {
8784
8843
  var _playerRef_current;
@@ -8803,7 +8862,29 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
8803
8862
  title: adsDisabled ? "Enable ads" : "Disable ads",
8804
8863
  children: "AD"
8805
8864
  }),
8806
- swirlProjectId && /* @__PURE__ */ jsx2("button", {
8865
+ swirlProjectId && (showOverlaysControl !== null && showOverlaysControl !== void 0 ? showOverlaysControl : true) && /* @__PURE__ */ jsx2("button", {
8866
+ className: "sc-ctrl-btn",
8867
+ onClick: function onClick() {
8868
+ setOverlaysDisabled(function(prev) {
8869
+ return !prev;
8870
+ });
8871
+ resetControlsTimer();
8872
+ },
8873
+ style: {
8874
+ padding: "".concat(8 * responsiveScale, "px"),
8875
+ borderRadius: "50%",
8876
+ minWidth: "".concat(36 * responsiveScale, "px"),
8877
+ minHeight: "".concat(36 * responsiveScale, "px"),
8878
+ background: overlaysDisabled ? "rgba(239, 68, 68, 0.28)" : "transparent",
8879
+ color: overlaysDisabled ? "rgba(252, 165, 165, 0.9)" : "rgba(255, 255, 255, 0.75)",
8880
+ opacity: overlaysDisabled ? 1 : 0.9
8881
+ },
8882
+ title: overlaysDisabled ? "Enable overlays" : "Disable overlays",
8883
+ children: /* @__PURE__ */ jsx2(FaLayerGroup, {
8884
+ size: Math.max(14, 18 * responsiveScale)
8885
+ })
8886
+ }),
8887
+ swirlProjectId && (showAiContextControl !== null && showAiContextControl !== void 0 ? showAiContextControl : true) && /* @__PURE__ */ jsx2("button", {
8807
8888
  className: "sc-ctrl-btn",
8808
8889
  onClick: function onClick() {
8809
8890
  setShowAiPanel(function(prev) {
@@ -8825,7 +8906,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
8825
8906
  title: showAiPanel ? "Hide AI context" : "Show AI context",
8826
8907
  children: "AI"
8827
8908
  }),
8828
- debugAdTiming && /* @__PURE__ */ jsx2("button", {
8909
+ debugAdTiming && (showDebugControl !== null && showDebugControl !== void 0 ? showDebugControl : true) && /* @__PURE__ */ jsx2("button", {
8829
8910
  className: "sc-ctrl-btn",
8830
8911
  onClick: function onClick() {
8831
8912
  setShowDebugPanel(function(prev) {
@@ -9096,7 +9177,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
9096
9177
  })
9097
9178
  ]
9098
9179
  }),
9099
- /* @__PURE__ */ jsx2("button", {
9180
+ (showAdsControl !== null && showAdsControl !== void 0 ? showAdsControl : true) && /* @__PURE__ */ jsx2("button", {
9100
9181
  className: "sc-ctrl-btn",
9101
9182
  onClick: function onClick() {
9102
9183
  var _playerRef_current;
@@ -9121,7 +9202,28 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
9121
9202
  title: adsDisabled ? "Enable ads" : "Disable ads",
9122
9203
  children: "AD"
9123
9204
  }),
9124
- swirlProjectId && /* @__PURE__ */ jsx2("button", {
9205
+ swirlProjectId && (showOverlaysControl !== null && showOverlaysControl !== void 0 ? showOverlaysControl : true) && /* @__PURE__ */ jsx2("button", {
9206
+ className: "sc-ctrl-btn",
9207
+ onClick: function onClick() {
9208
+ setOverlaysDisabled(function(prev) {
9209
+ return !prev;
9210
+ });
9211
+ resetControlsTimer();
9212
+ },
9213
+ style: {
9214
+ padding: "".concat(8 * responsiveScale, "px"),
9215
+ borderRadius: "50%",
9216
+ minWidth: "".concat(36 * responsiveScale, "px"),
9217
+ minHeight: "".concat(36 * responsiveScale, "px"),
9218
+ background: overlaysDisabled ? "rgba(239, 68, 68, 0.28)" : "rgba(0, 0, 0, 0.6)",
9219
+ color: overlaysDisabled ? "rgba(252, 165, 165, 0.9)" : "rgba(255, 255, 255, 0.75)"
9220
+ },
9221
+ title: overlaysDisabled ? "Enable overlays" : "Disable overlays",
9222
+ children: /* @__PURE__ */ jsx2(FaLayerGroup, {
9223
+ size: Math.max(14, 18 * responsiveScale)
9224
+ })
9225
+ }),
9226
+ swirlProjectId && (showAiContextControl !== null && showAiContextControl !== void 0 ? showAiContextControl : true) && /* @__PURE__ */ jsx2("button", {
9125
9227
  className: "sc-ctrl-btn",
9126
9228
  onClick: function onClick() {
9127
9229
  setShowAiPanel(function(prev) {
@@ -9143,7 +9245,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
9143
9245
  title: showAiPanel ? "Hide AI context" : "Show AI context",
9144
9246
  children: "AI"
9145
9247
  }),
9146
- debugAdTiming && /* @__PURE__ */ jsx2("button", {
9248
+ debugAdTiming && (showDebugControl !== null && showDebugControl !== void 0 ? showDebugControl : true) && /* @__PURE__ */ jsx2("button", {
9147
9249
  className: "sc-ctrl-btn",
9148
9250
  onClick: function onClick() {
9149
9251
  setShowDebugPanel(function(prev) {
@@ -9245,7 +9347,13 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
9245
9347
  "preload",
9246
9348
  "poster",
9247
9349
  "children",
9248
- "swirlProjectId"
9350
+ "swirlProjectId",
9351
+ "adcisionChannelId",
9352
+ "disableOverlays",
9353
+ "showAdsControl",
9354
+ "showOverlaysControl",
9355
+ "showAiContextControl",
9356
+ "showDebugControl"
9249
9357
  ];
9250
9358
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
9251
9359
  try {