stormcloud-video-player 0.3.66 → 0.3.67

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
@@ -232,6 +232,7 @@ declare class StormcloudVideoPlayer {
232
232
  private preloadPoolActive;
233
233
  private preloadPoolLoopRunning;
234
234
  private adDetectSentForCurrentBreak;
235
+ private preAdBreakAudio;
235
236
  constructor(config: StormcloudVideoPlayerConfig);
236
237
  private createAdPlayer;
237
238
  load(): Promise<void>;
@@ -339,6 +340,8 @@ declare class StormcloudVideoPlayer {
339
340
  private resetGamNoFillCounter;
340
341
  private enforceGlobalRateLimit;
341
342
  private playSingleAd;
343
+ private capturePreAdBreakAudio;
344
+ private getPreAdBreakAdVolume;
342
345
  private handleAdPodComplete;
343
346
  private handleAdFailure;
344
347
  private startAdRequestWatchdog;
package/lib/index.d.ts CHANGED
@@ -232,6 +232,7 @@ declare class StormcloudVideoPlayer {
232
232
  private preloadPoolActive;
233
233
  private preloadPoolLoopRunning;
234
234
  private adDetectSentForCurrentBreak;
235
+ private preAdBreakAudio;
235
236
  constructor(config: StormcloudVideoPlayerConfig);
236
237
  private createAdPlayer;
237
238
  load(): Promise<void>;
@@ -339,6 +340,8 @@ declare class StormcloudVideoPlayer {
339
340
  private resetGamNoFillCounter;
340
341
  private enforceGlobalRateLimit;
341
342
  private playSingleAd;
343
+ private capturePreAdBreakAudio;
344
+ private getPreAdBreakAdVolume;
342
345
  private handleAdPodComplete;
343
346
  private handleAdFailure;
344
347
  private startAdRequestWatchdog;
package/lib/index.js CHANGED
@@ -3910,10 +3910,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3910
3910
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3911
3911
  }
3912
3912
  }
3913
- var currentMuted = _this.video.muted;
3914
- var currentVolume = _this.video.volume;
3915
- var adVolume = currentMuted ? 0 : currentVolume;
3916
- _this.ima.setAdVolume(adVolume);
3913
+ _this.ima.setAdVolume(_this.getPreAdBreakAdVolume());
3917
3914
  if (_this.isShowingPlaceholder) {
3918
3915
  if (_this.config.debugAdTiming) {
3919
3916
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -4667,6 +4664,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4667
4664
  {
4668
4665
  key: "startScte35AdBreak",
4669
4666
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
4667
+ this.capturePreAdBreakAudio();
4670
4668
  if (!this.video.muted) {
4671
4669
  this.video.muted = true;
4672
4670
  this.video.volume = 0;
@@ -6348,9 +6346,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6348
6346
  this.continuousFetchingActive = true;
6349
6347
  this.isShowingPlaceholder = false;
6350
6348
  this.totalAdRequestsInBreak = 0;
6351
- currentMuted = this.video.muted;
6352
- currentVolume = this.video.volume;
6353
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
6349
+ this.capturePreAdBreakAudio();
6350
+ currentMuted = this.preAdBreakAudio.muted;
6351
+ currentVolume = this.preAdBreakAudio.volume;
6354
6352
  if (!this.video.muted) {
6355
6353
  this.video.muted = true;
6356
6354
  this.video.volume = 0;
@@ -6825,7 +6823,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6825
6823
  value: function tryNextAvailableAd() {
6826
6824
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6827
6825
  return _async_to_generator(function() {
6828
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6826
+ var remaining, preloaded, error, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error1, errorMessage, maxRetries;
6829
6827
  return _ts_generator(this, function(_state) {
6830
6828
  switch(_state.label){
6831
6829
  case 0:
@@ -6897,10 +6895,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6897
6895
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6898
6896
  this.scheduleAdStopAtBreakBoundary();
6899
6897
  }
6900
- currentMuted = this.video.muted;
6901
- currentVolume = this.video.volume;
6902
- adVolume = currentMuted ? 0 : currentVolume;
6903
- this.ima.setAdVolume(adVolume);
6898
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
6904
6899
  this.consecutiveFailures = 0;
6905
6900
  return [
6906
6901
  2
@@ -6947,9 +6942,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6947
6942
  if (this.config.debugAdTiming) {
6948
6943
  console.log("[CONTINUOUS-FETCH] \uD83C\uDFAC Requesting next ad via IMA SDK (".concat(this.currentAdIndex + 1, "/").concat(this.totalAdsInBreak, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
6949
6944
  }
6950
- currentMuted1 = this.video.muted;
6951
- currentVolume1 = this.video.volume;
6952
- this.ima.updateOriginalMutedState(currentMuted1, currentVolume1);
6945
+ this.ima.updateOriginalMutedState((_ref = (_this_preAdBreakAudio = this.preAdBreakAudio) === null || _this_preAdBreakAudio === void 0 ? void 0 : _this_preAdBreakAudio.muted) !== null && _ref !== void 0 ? _ref : this.video.muted, (_ref1 = (_this_preAdBreakAudio1 = this.preAdBreakAudio) === null || _this_preAdBreakAudio1 === void 0 ? void 0 : _this_preAdBreakAudio1.volume) !== null && _ref1 !== void 0 ? _ref1 : this.video.volume);
6953
6946
  this.currentAdIndex++;
6954
6947
  this.totalAdRequestsInBreak++;
6955
6948
  this.lastAdRequestTime = Date.now();
@@ -7042,7 +7035,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7042
7035
  key: "showPlaceholderAndWaitForAds",
7043
7036
  value: function showPlaceholderAndWaitForAds() {
7044
7037
  return _async_to_generator(function() {
7045
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
7038
+ var remaining, waitTime, checkInterval, maxChecks, i, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error, errorMessage;
7046
7039
  return _ts_generator(this, function(_state) {
7047
7040
  switch(_state.label){
7048
7041
  case 0:
@@ -7138,9 +7131,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7138
7131
  }
7139
7132
  this.isShowingPlaceholder = false;
7140
7133
  this.ima.hidePlaceholder();
7141
- currentMuted = this.video.muted;
7142
- currentVolume = this.video.volume;
7143
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
7134
+ this.ima.updateOriginalMutedState((_ref = (_this_preAdBreakAudio = this.preAdBreakAudio) === null || _this_preAdBreakAudio === void 0 ? void 0 : _this_preAdBreakAudio.muted) !== null && _ref !== void 0 ? _ref : this.video.muted, (_ref1 = (_this_preAdBreakAudio1 = this.preAdBreakAudio) === null || _this_preAdBreakAudio1 === void 0 ? void 0 : _this_preAdBreakAudio1.volume) !== null && _ref1 !== void 0 ? _ref1 : this.video.volume);
7144
7135
  this.currentAdIndex++;
7145
7136
  this.totalAdRequestsInBreak++;
7146
7137
  this.lastAdRequestTime = Date.now();
@@ -7322,7 +7313,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7322
7313
  first = tags[0];
7323
7314
  rest = tags.slice(1);
7324
7315
  this.adPodQueue = rest;
7325
- this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
7316
+ this.capturePreAdBreakAudio();
7326
7317
  this.showAds = true;
7327
7318
  this.inAdBreak = true;
7328
7319
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -7349,12 +7340,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7349
7340
  ];
7350
7341
  case 3:
7351
7342
  error = _state.sent();
7352
- this.adPodQueue = [];
7353
- this.inAdBreak = false;
7354
- this.showAds = false;
7355
7343
  if (this.config.debugAdTiming) {
7356
7344
  console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
7357
7345
  }
7346
+ this.handleAdPodComplete();
7358
7347
  return [
7359
7348
  3,
7360
7349
  4
@@ -7585,7 +7574,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7585
7574
  key: "playSingleAd",
7586
7575
  value: function playSingleAd(vastTagUrl) {
7587
7576
  return _async_to_generator(function() {
7588
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
7577
+ var requestToken, playError, preloadedFallback, fallbackError, error, errorMessage, preloadedFallback1, fallbackError1;
7589
7578
  return _ts_generator(this, function(_state) {
7590
7579
  switch(_state.label){
7591
7580
  case 0:
@@ -7672,10 +7661,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7672
7661
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7673
7662
  this.scheduleAdStopAtBreakBoundary();
7674
7663
  }
7675
- currentMuted = this.video.muted;
7676
- currentVolume = this.video.volume;
7677
- adVolume = currentMuted ? 0 : currentVolume;
7678
- this.ima.setAdVolume(adVolume);
7664
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7679
7665
  this.consecutiveFailures = 0;
7680
7666
  this.temporaryFailureUrls.delete(vastTagUrl);
7681
7667
  return [
@@ -7722,10 +7708,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7722
7708
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7723
7709
  this.scheduleAdStopAtBreakBoundary();
7724
7710
  }
7725
- currentMuted1 = this.video.muted;
7726
- currentVolume1 = this.video.volume;
7727
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7728
- this.ima.setAdVolume(adVolume1);
7711
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7729
7712
  return [
7730
7713
  2
7731
7714
  ];
@@ -7799,10 +7782,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7799
7782
  ];
7800
7783
  case 14:
7801
7784
  _state.sent();
7802
- currentMuted2 = this.video.muted;
7803
- currentVolume2 = this.video.volume;
7804
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7805
- this.ima.setAdVolume(adVolume2);
7785
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7806
7786
  return [
7807
7787
  2
7808
7788
  ];
@@ -7842,6 +7822,33 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7842
7822
  }).call(this);
7843
7823
  }
7844
7824
  },
7825
+ {
7826
+ key: "capturePreAdBreakAudio",
7827
+ value: function capturePreAdBreakAudio() {
7828
+ if (this.preAdBreakAudio) {
7829
+ return;
7830
+ }
7831
+ var captured = {
7832
+ muted: this.video.muted,
7833
+ volume: typeof this.video.volume === "number" && !Number.isNaN(this.video.volume) ? Math.max(0, Math.min(1, this.video.volume)) : 1
7834
+ };
7835
+ this.preAdBreakAudio = captured;
7836
+ this.ima.updateOriginalMutedState(captured.muted, captured.volume);
7837
+ if (this.config.debugAdTiming) {
7838
+ console.log("[StormcloudVideoPlayer] Captured pre-ad-break audio state: muted=".concat(captured.muted, ", volume=").concat(captured.volume));
7839
+ }
7840
+ }
7841
+ },
7842
+ {
7843
+ key: "getPreAdBreakAdVolume",
7844
+ value: function getPreAdBreakAdVolume() {
7845
+ var state = this.preAdBreakAudio;
7846
+ if (state) {
7847
+ return state.muted ? 0 : state.volume;
7848
+ }
7849
+ return this.ima.getOriginalMutedState() ? 0 : this.ima.getOriginalVolume();
7850
+ }
7851
+ },
7845
7852
  {
7846
7853
  key: "handleAdPodComplete",
7847
7854
  value: function handleAdPodComplete() {
@@ -7875,14 +7882,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7875
7882
  this.consecutiveFailures = 0;
7876
7883
  this.globalConsecutiveNoFills = 0;
7877
7884
  this.ima.stop().catch(function() {});
7878
- var restoredMuted = this.ima.getOriginalMutedState();
7879
- var restoredVolume = this.ima.getOriginalVolume();
7885
+ var restoredMuted = this.preAdBreakAudio ? this.preAdBreakAudio.muted : this.ima.getOriginalMutedState();
7886
+ var restoredVolume = this.preAdBreakAudio ? this.preAdBreakAudio.volume : this.ima.getOriginalVolume();
7887
+ this.ima.updateOriginalMutedState(restoredMuted, restoredVolume);
7880
7888
  if (this.video.muted !== restoredMuted) {
7881
7889
  this.video.muted = restoredMuted;
7882
7890
  }
7883
7891
  if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
7884
7892
  this.video.volume = restoredVolume;
7885
7893
  }
7894
+ this.preAdBreakAudio = void 0;
7895
+ if (this.config.debugAdTiming) {
7896
+ console.log("[StormcloudVideoPlayer] Restored post-ad-break audio state: muted=".concat(restoredMuted, ", volume=").concat(restoredVolume));
7897
+ }
7886
7898
  if (this.shouldContinueLiveStreamDuringAds()) {
7887
7899
  if (this.video.paused) {
7888
7900
  var _this_video_play;
@@ -8292,6 +8304,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8292
8304
  this.clearAdFailsafeTimer();
8293
8305
  this.clearAdRequestWatchdog();
8294
8306
  this.clearPendingAdBreak();
8307
+ this.preAdBreakAudio = void 0;
8295
8308
  if (this.placeholderContainer) {
8296
8309
  if (this.placeholderContainer.parentElement) {
8297
8310
  this.placeholderContainer.parentElement.removeChild(this.placeholderContainer);
@@ -8324,8 +8337,66 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8324
8337
  return StormcloudVideoPlayer;
8325
8338
  }();
8326
8339
  // src/ui/StormcloudVideoPlayer.tsx
8327
- import { FaPlay, FaPause, FaVolumeUp, FaVolumeMute, FaVolumeDown, FaExpand, FaCompress } from "react-icons/fa";
8340
+ import { FaPlay, FaPause, FaVolumeUp, FaVolumeMute, FaVolumeDown } from "react-icons/fa";
8328
8341
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8342
+ var ExpandIcon = function ExpandIcon(param) {
8343
+ var _param_size = param.size, size = _param_size === void 0 ? 18 : _param_size;
8344
+ return /* @__PURE__ */ jsxs("svg", {
8345
+ width: size,
8346
+ height: size,
8347
+ viewBox: "0 0 24 24",
8348
+ fill: "none",
8349
+ stroke: "currentColor",
8350
+ strokeWidth: 2,
8351
+ strokeLinecap: "round",
8352
+ strokeLinejoin: "round",
8353
+ "aria-hidden": "true",
8354
+ focusable: "false",
8355
+ children: [
8356
+ /* @__PURE__ */ jsx("path", {
8357
+ d: "M9 4H4v5"
8358
+ }),
8359
+ /* @__PURE__ */ jsx("path", {
8360
+ d: "M20 9V4h-5"
8361
+ }),
8362
+ /* @__PURE__ */ jsx("path", {
8363
+ d: "M15 20h5v-5"
8364
+ }),
8365
+ /* @__PURE__ */ jsx("path", {
8366
+ d: "M4 15v5h5"
8367
+ })
8368
+ ]
8369
+ });
8370
+ };
8371
+ var CompressIcon = function CompressIcon(param) {
8372
+ var _param_size = param.size, size = _param_size === void 0 ? 18 : _param_size;
8373
+ return /* @__PURE__ */ jsxs("svg", {
8374
+ width: size,
8375
+ height: size,
8376
+ viewBox: "0 0 24 24",
8377
+ fill: "none",
8378
+ stroke: "currentColor",
8379
+ strokeWidth: 2,
8380
+ strokeLinecap: "round",
8381
+ strokeLinejoin: "round",
8382
+ "aria-hidden": "true",
8383
+ focusable: "false",
8384
+ children: [
8385
+ /* @__PURE__ */ jsx("path", {
8386
+ d: "M4 9h5V4"
8387
+ }),
8388
+ /* @__PURE__ */ jsx("path", {
8389
+ d: "M15 4v5h5"
8390
+ }),
8391
+ /* @__PURE__ */ jsx("path", {
8392
+ d: "M20 15h-5v5"
8393
+ }),
8394
+ /* @__PURE__ */ jsx("path", {
8395
+ d: "M9 20v-5H4"
8396
+ })
8397
+ ]
8398
+ });
8399
+ };
8329
8400
  var CRITICAL_PROPS = [
8330
8401
  "src",
8331
8402
  "allowNativeHls",
@@ -9376,9 +9447,9 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
9376
9447
  minHeight: "".concat(36 * responsiveScale, "px")
9377
9448
  },
9378
9449
  title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
9379
- children: isFullscreen ? /* @__PURE__ */ jsx(FaCompress, {
9450
+ children: isFullscreen ? /* @__PURE__ */ jsx(CompressIcon, {
9380
9451
  size: Math.max(14, 18 * responsiveScale)
9381
- }) : /* @__PURE__ */ jsx(FaExpand, {
9452
+ }) : /* @__PURE__ */ jsx(ExpandIcon, {
9382
9453
  size: Math.max(14, 18 * responsiveScale)
9383
9454
  })
9384
9455
  })
@@ -9576,9 +9647,9 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
9576
9647
  background: "rgba(0, 0, 0, 0.6)"
9577
9648
  },
9578
9649
  title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
9579
- children: isFullscreen ? /* @__PURE__ */ jsx(FaCompress, {
9650
+ children: isFullscreen ? /* @__PURE__ */ jsx(CompressIcon, {
9580
9651
  size: Math.max(14, 18 * responsiveScale)
9581
- }) : /* @__PURE__ */ jsx(FaExpand, {
9652
+ }) : /* @__PURE__ */ jsx(ExpandIcon, {
9582
9653
  size: Math.max(14, 18 * responsiveScale)
9583
9654
  })
9584
9655
  })