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.cjs CHANGED
@@ -4127,10 +4127,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4127
4127
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
4128
4128
  }
4129
4129
  }
4130
- var currentMuted = _this.video.muted;
4131
- var currentVolume = _this.video.volume;
4132
- var adVolume = currentMuted ? 0 : currentVolume;
4133
- _this.ima.setAdVolume(adVolume);
4130
+ _this.ima.setAdVolume(_this.getPreAdBreakAdVolume());
4134
4131
  if (_this.isShowingPlaceholder) {
4135
4132
  if (_this.config.debugAdTiming) {
4136
4133
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -4884,6 +4881,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4884
4881
  {
4885
4882
  key: "startScte35AdBreak",
4886
4883
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
4884
+ this.capturePreAdBreakAudio();
4887
4885
  if (!this.video.muted) {
4888
4886
  this.video.muted = true;
4889
4887
  this.video.volume = 0;
@@ -6565,9 +6563,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6565
6563
  this.continuousFetchingActive = true;
6566
6564
  this.isShowingPlaceholder = false;
6567
6565
  this.totalAdRequestsInBreak = 0;
6568
- currentMuted = this.video.muted;
6569
- currentVolume = this.video.volume;
6570
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
6566
+ this.capturePreAdBreakAudio();
6567
+ currentMuted = this.preAdBreakAudio.muted;
6568
+ currentVolume = this.preAdBreakAudio.volume;
6571
6569
  if (!this.video.muted) {
6572
6570
  this.video.muted = true;
6573
6571
  this.video.volume = 0;
@@ -7042,7 +7040,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7042
7040
  value: function tryNextAvailableAd() {
7043
7041
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
7044
7042
  return _async_to_generator(function() {
7045
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
7043
+ var remaining, preloaded, error, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error1, errorMessage, maxRetries;
7046
7044
  return _ts_generator(this, function(_state) {
7047
7045
  switch(_state.label){
7048
7046
  case 0:
@@ -7114,10 +7112,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7114
7112
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7115
7113
  this.scheduleAdStopAtBreakBoundary();
7116
7114
  }
7117
- currentMuted = this.video.muted;
7118
- currentVolume = this.video.volume;
7119
- adVolume = currentMuted ? 0 : currentVolume;
7120
- this.ima.setAdVolume(adVolume);
7115
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7121
7116
  this.consecutiveFailures = 0;
7122
7117
  return [
7123
7118
  2
@@ -7164,9 +7159,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7164
7159
  if (this.config.debugAdTiming) {
7165
7160
  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)"));
7166
7161
  }
7167
- currentMuted1 = this.video.muted;
7168
- currentVolume1 = this.video.volume;
7169
- this.ima.updateOriginalMutedState(currentMuted1, currentVolume1);
7162
+ 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);
7170
7163
  this.currentAdIndex++;
7171
7164
  this.totalAdRequestsInBreak++;
7172
7165
  this.lastAdRequestTime = Date.now();
@@ -7259,7 +7252,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7259
7252
  key: "showPlaceholderAndWaitForAds",
7260
7253
  value: function showPlaceholderAndWaitForAds() {
7261
7254
  return _async_to_generator(function() {
7262
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
7255
+ var remaining, waitTime, checkInterval, maxChecks, i, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error, errorMessage;
7263
7256
  return _ts_generator(this, function(_state) {
7264
7257
  switch(_state.label){
7265
7258
  case 0:
@@ -7355,9 +7348,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7355
7348
  }
7356
7349
  this.isShowingPlaceholder = false;
7357
7350
  this.ima.hidePlaceholder();
7358
- currentMuted = this.video.muted;
7359
- currentVolume = this.video.volume;
7360
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
7351
+ 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);
7361
7352
  this.currentAdIndex++;
7362
7353
  this.totalAdRequestsInBreak++;
7363
7354
  this.lastAdRequestTime = Date.now();
@@ -7539,7 +7530,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7539
7530
  first = tags[0];
7540
7531
  rest = tags.slice(1);
7541
7532
  this.adPodQueue = rest;
7542
- this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
7533
+ this.capturePreAdBreakAudio();
7543
7534
  this.showAds = true;
7544
7535
  this.inAdBreak = true;
7545
7536
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -7566,12 +7557,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7566
7557
  ];
7567
7558
  case 3:
7568
7559
  error = _state.sent();
7569
- this.adPodQueue = [];
7570
- this.inAdBreak = false;
7571
- this.showAds = false;
7572
7560
  if (this.config.debugAdTiming) {
7573
7561
  console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
7574
7562
  }
7563
+ this.handleAdPodComplete();
7575
7564
  return [
7576
7565
  3,
7577
7566
  4
@@ -7802,7 +7791,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7802
7791
  key: "playSingleAd",
7803
7792
  value: function playSingleAd(vastTagUrl) {
7804
7793
  return _async_to_generator(function() {
7805
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
7794
+ var requestToken, playError, preloadedFallback, fallbackError, error, errorMessage, preloadedFallback1, fallbackError1;
7806
7795
  return _ts_generator(this, function(_state) {
7807
7796
  switch(_state.label){
7808
7797
  case 0:
@@ -7889,10 +7878,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7889
7878
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7890
7879
  this.scheduleAdStopAtBreakBoundary();
7891
7880
  }
7892
- currentMuted = this.video.muted;
7893
- currentVolume = this.video.volume;
7894
- adVolume = currentMuted ? 0 : currentVolume;
7895
- this.ima.setAdVolume(adVolume);
7881
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7896
7882
  this.consecutiveFailures = 0;
7897
7883
  this.temporaryFailureUrls.delete(vastTagUrl);
7898
7884
  return [
@@ -7939,10 +7925,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7939
7925
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7940
7926
  this.scheduleAdStopAtBreakBoundary();
7941
7927
  }
7942
- currentMuted1 = this.video.muted;
7943
- currentVolume1 = this.video.volume;
7944
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7945
- this.ima.setAdVolume(adVolume1);
7928
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7946
7929
  return [
7947
7930
  2
7948
7931
  ];
@@ -8016,10 +7999,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8016
7999
  ];
8017
8000
  case 14:
8018
8001
  _state.sent();
8019
- currentMuted2 = this.video.muted;
8020
- currentVolume2 = this.video.volume;
8021
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
8022
- this.ima.setAdVolume(adVolume2);
8002
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
8023
8003
  return [
8024
8004
  2
8025
8005
  ];
@@ -8059,6 +8039,33 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8059
8039
  }).call(this);
8060
8040
  }
8061
8041
  },
8042
+ {
8043
+ key: "capturePreAdBreakAudio",
8044
+ value: function capturePreAdBreakAudio() {
8045
+ if (this.preAdBreakAudio) {
8046
+ return;
8047
+ }
8048
+ var captured = {
8049
+ muted: this.video.muted,
8050
+ volume: typeof this.video.volume === "number" && !Number.isNaN(this.video.volume) ? Math.max(0, Math.min(1, this.video.volume)) : 1
8051
+ };
8052
+ this.preAdBreakAudio = captured;
8053
+ this.ima.updateOriginalMutedState(captured.muted, captured.volume);
8054
+ if (this.config.debugAdTiming) {
8055
+ console.log("[StormcloudVideoPlayer] Captured pre-ad-break audio state: muted=".concat(captured.muted, ", volume=").concat(captured.volume));
8056
+ }
8057
+ }
8058
+ },
8059
+ {
8060
+ key: "getPreAdBreakAdVolume",
8061
+ value: function getPreAdBreakAdVolume() {
8062
+ var state = this.preAdBreakAudio;
8063
+ if (state) {
8064
+ return state.muted ? 0 : state.volume;
8065
+ }
8066
+ return this.ima.getOriginalMutedState() ? 0 : this.ima.getOriginalVolume();
8067
+ }
8068
+ },
8062
8069
  {
8063
8070
  key: "handleAdPodComplete",
8064
8071
  value: function handleAdPodComplete() {
@@ -8092,14 +8099,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8092
8099
  this.consecutiveFailures = 0;
8093
8100
  this.globalConsecutiveNoFills = 0;
8094
8101
  this.ima.stop().catch(function() {});
8095
- var restoredMuted = this.ima.getOriginalMutedState();
8096
- var restoredVolume = this.ima.getOriginalVolume();
8102
+ var restoredMuted = this.preAdBreakAudio ? this.preAdBreakAudio.muted : this.ima.getOriginalMutedState();
8103
+ var restoredVolume = this.preAdBreakAudio ? this.preAdBreakAudio.volume : this.ima.getOriginalVolume();
8104
+ this.ima.updateOriginalMutedState(restoredMuted, restoredVolume);
8097
8105
  if (this.video.muted !== restoredMuted) {
8098
8106
  this.video.muted = restoredMuted;
8099
8107
  }
8100
8108
  if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
8101
8109
  this.video.volume = restoredVolume;
8102
8110
  }
8111
+ this.preAdBreakAudio = void 0;
8112
+ if (this.config.debugAdTiming) {
8113
+ console.log("[StormcloudVideoPlayer] Restored post-ad-break audio state: muted=".concat(restoredMuted, ", volume=").concat(restoredVolume));
8114
+ }
8103
8115
  if (this.shouldContinueLiveStreamDuringAds()) {
8104
8116
  if (this.video.paused) {
8105
8117
  var _this_video_play;
@@ -8509,6 +8521,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8509
8521
  this.clearAdFailsafeTimer();
8510
8522
  this.clearAdRequestWatchdog();
8511
8523
  this.clearPendingAdBreak();
8524
+ this.preAdBreakAudio = void 0;
8512
8525
  if (this.placeholderContainer) {
8513
8526
  if (this.placeholderContainer.parentElement) {
8514
8527
  this.placeholderContainer.parentElement.removeChild(this.placeholderContainer);
@@ -8543,6 +8556,64 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8543
8556
  // src/ui/StormcloudVideoPlayer.tsx
8544
8557
  var import_fa = require("react-icons/fa");
8545
8558
  var import_jsx_runtime = require("react/jsx-runtime");
8559
+ var ExpandIcon = function ExpandIcon(param) {
8560
+ var _param_size = param.size, size = _param_size === void 0 ? 18 : _param_size;
8561
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
8562
+ width: size,
8563
+ height: size,
8564
+ viewBox: "0 0 24 24",
8565
+ fill: "none",
8566
+ stroke: "currentColor",
8567
+ strokeWidth: 2,
8568
+ strokeLinecap: "round",
8569
+ strokeLinejoin: "round",
8570
+ "aria-hidden": "true",
8571
+ focusable: "false",
8572
+ children: [
8573
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8574
+ d: "M9 4H4v5"
8575
+ }),
8576
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8577
+ d: "M20 9V4h-5"
8578
+ }),
8579
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8580
+ d: "M15 20h5v-5"
8581
+ }),
8582
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8583
+ d: "M4 15v5h5"
8584
+ })
8585
+ ]
8586
+ });
8587
+ };
8588
+ var CompressIcon = function CompressIcon(param) {
8589
+ var _param_size = param.size, size = _param_size === void 0 ? 18 : _param_size;
8590
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
8591
+ width: size,
8592
+ height: size,
8593
+ viewBox: "0 0 24 24",
8594
+ fill: "none",
8595
+ stroke: "currentColor",
8596
+ strokeWidth: 2,
8597
+ strokeLinecap: "round",
8598
+ strokeLinejoin: "round",
8599
+ "aria-hidden": "true",
8600
+ focusable: "false",
8601
+ children: [
8602
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8603
+ d: "M4 9h5V4"
8604
+ }),
8605
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8606
+ d: "M15 4v5h5"
8607
+ }),
8608
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8609
+ d: "M20 15h-5v5"
8610
+ }),
8611
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8612
+ d: "M9 20v-5H4"
8613
+ })
8614
+ ]
8615
+ });
8616
+ };
8546
8617
  var CRITICAL_PROPS = [
8547
8618
  "src",
8548
8619
  "allowNativeHls",
@@ -9593,9 +9664,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
9593
9664
  minHeight: "".concat(36 * responsiveScale, "px")
9594
9665
  },
9595
9666
  title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
9596
- children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaCompress, {
9667
+ children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompressIcon, {
9597
9668
  size: Math.max(14, 18 * responsiveScale)
9598
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaExpand, {
9669
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExpandIcon, {
9599
9670
  size: Math.max(14, 18 * responsiveScale)
9600
9671
  })
9601
9672
  })
@@ -9793,9 +9864,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
9793
9864
  background: "rgba(0, 0, 0, 0.6)"
9794
9865
  },
9795
9866
  title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
9796
- children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaCompress, {
9867
+ children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompressIcon, {
9797
9868
  size: Math.max(14, 18 * responsiveScale)
9798
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaExpand, {
9869
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExpandIcon, {
9799
9870
  size: Math.max(14, 18 * responsiveScale)
9800
9871
  })
9801
9872
  })