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.
@@ -3873,10 +3873,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3873
3873
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3874
3874
  }
3875
3875
  }
3876
- var currentMuted = _this.video.muted;
3877
- var currentVolume = _this.video.volume;
3878
- var adVolume = currentMuted ? 0 : currentVolume;
3879
- _this.ima.setAdVolume(adVolume);
3876
+ _this.ima.setAdVolume(_this.getPreAdBreakAdVolume());
3880
3877
  if (_this.isShowingPlaceholder) {
3881
3878
  if (_this.config.debugAdTiming) {
3882
3879
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -4630,6 +4627,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4630
4627
  {
4631
4628
  key: "startScte35AdBreak",
4632
4629
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
4630
+ this.capturePreAdBreakAudio();
4633
4631
  if (!this.video.muted) {
4634
4632
  this.video.muted = true;
4635
4633
  this.video.volume = 0;
@@ -6311,9 +6309,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6311
6309
  this.continuousFetchingActive = true;
6312
6310
  this.isShowingPlaceholder = false;
6313
6311
  this.totalAdRequestsInBreak = 0;
6314
- currentMuted = this.video.muted;
6315
- currentVolume = this.video.volume;
6316
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
6312
+ this.capturePreAdBreakAudio();
6313
+ currentMuted = this.preAdBreakAudio.muted;
6314
+ currentVolume = this.preAdBreakAudio.volume;
6317
6315
  if (!this.video.muted) {
6318
6316
  this.video.muted = true;
6319
6317
  this.video.volume = 0;
@@ -6788,7 +6786,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6788
6786
  value: function tryNextAvailableAd() {
6789
6787
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6790
6788
  return _async_to_generator(function() {
6791
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6789
+ var remaining, preloaded, error, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error1, errorMessage, maxRetries;
6792
6790
  return _ts_generator(this, function(_state) {
6793
6791
  switch(_state.label){
6794
6792
  case 0:
@@ -6860,10 +6858,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6860
6858
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6861
6859
  this.scheduleAdStopAtBreakBoundary();
6862
6860
  }
6863
- currentMuted = this.video.muted;
6864
- currentVolume = this.video.volume;
6865
- adVolume = currentMuted ? 0 : currentVolume;
6866
- this.ima.setAdVolume(adVolume);
6861
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
6867
6862
  this.consecutiveFailures = 0;
6868
6863
  return [
6869
6864
  2
@@ -6910,9 +6905,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6910
6905
  if (this.config.debugAdTiming) {
6911
6906
  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)"));
6912
6907
  }
6913
- currentMuted1 = this.video.muted;
6914
- currentVolume1 = this.video.volume;
6915
- this.ima.updateOriginalMutedState(currentMuted1, currentVolume1);
6908
+ 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);
6916
6909
  this.currentAdIndex++;
6917
6910
  this.totalAdRequestsInBreak++;
6918
6911
  this.lastAdRequestTime = Date.now();
@@ -7005,7 +6998,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7005
6998
  key: "showPlaceholderAndWaitForAds",
7006
6999
  value: function showPlaceholderAndWaitForAds() {
7007
7000
  return _async_to_generator(function() {
7008
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
7001
+ var remaining, waitTime, checkInterval, maxChecks, i, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error, errorMessage;
7009
7002
  return _ts_generator(this, function(_state) {
7010
7003
  switch(_state.label){
7011
7004
  case 0:
@@ -7101,9 +7094,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7101
7094
  }
7102
7095
  this.isShowingPlaceholder = false;
7103
7096
  this.ima.hidePlaceholder();
7104
- currentMuted = this.video.muted;
7105
- currentVolume = this.video.volume;
7106
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
7097
+ 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);
7107
7098
  this.currentAdIndex++;
7108
7099
  this.totalAdRequestsInBreak++;
7109
7100
  this.lastAdRequestTime = Date.now();
@@ -7285,7 +7276,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7285
7276
  first = tags[0];
7286
7277
  rest = tags.slice(1);
7287
7278
  this.adPodQueue = rest;
7288
- this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
7279
+ this.capturePreAdBreakAudio();
7289
7280
  this.showAds = true;
7290
7281
  this.inAdBreak = true;
7291
7282
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -7312,12 +7303,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7312
7303
  ];
7313
7304
  case 3:
7314
7305
  error = _state.sent();
7315
- this.adPodQueue = [];
7316
- this.inAdBreak = false;
7317
- this.showAds = false;
7318
7306
  if (this.config.debugAdTiming) {
7319
7307
  console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
7320
7308
  }
7309
+ this.handleAdPodComplete();
7321
7310
  return [
7322
7311
  3,
7323
7312
  4
@@ -7548,7 +7537,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7548
7537
  key: "playSingleAd",
7549
7538
  value: function playSingleAd(vastTagUrl) {
7550
7539
  return _async_to_generator(function() {
7551
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
7540
+ var requestToken, playError, preloadedFallback, fallbackError, error, errorMessage, preloadedFallback1, fallbackError1;
7552
7541
  return _ts_generator(this, function(_state) {
7553
7542
  switch(_state.label){
7554
7543
  case 0:
@@ -7635,10 +7624,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7635
7624
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7636
7625
  this.scheduleAdStopAtBreakBoundary();
7637
7626
  }
7638
- currentMuted = this.video.muted;
7639
- currentVolume = this.video.volume;
7640
- adVolume = currentMuted ? 0 : currentVolume;
7641
- this.ima.setAdVolume(adVolume);
7627
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7642
7628
  this.consecutiveFailures = 0;
7643
7629
  this.temporaryFailureUrls.delete(vastTagUrl);
7644
7630
  return [
@@ -7685,10 +7671,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7685
7671
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7686
7672
  this.scheduleAdStopAtBreakBoundary();
7687
7673
  }
7688
- currentMuted1 = this.video.muted;
7689
- currentVolume1 = this.video.volume;
7690
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7691
- this.ima.setAdVolume(adVolume1);
7674
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7692
7675
  return [
7693
7676
  2
7694
7677
  ];
@@ -7762,10 +7745,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7762
7745
  ];
7763
7746
  case 14:
7764
7747
  _state.sent();
7765
- currentMuted2 = this.video.muted;
7766
- currentVolume2 = this.video.volume;
7767
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7768
- this.ima.setAdVolume(adVolume2);
7748
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7769
7749
  return [
7770
7750
  2
7771
7751
  ];
@@ -7805,6 +7785,33 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7805
7785
  }).call(this);
7806
7786
  }
7807
7787
  },
7788
+ {
7789
+ key: "capturePreAdBreakAudio",
7790
+ value: function capturePreAdBreakAudio() {
7791
+ if (this.preAdBreakAudio) {
7792
+ return;
7793
+ }
7794
+ var captured = {
7795
+ muted: this.video.muted,
7796
+ volume: typeof this.video.volume === "number" && !Number.isNaN(this.video.volume) ? Math.max(0, Math.min(1, this.video.volume)) : 1
7797
+ };
7798
+ this.preAdBreakAudio = captured;
7799
+ this.ima.updateOriginalMutedState(captured.muted, captured.volume);
7800
+ if (this.config.debugAdTiming) {
7801
+ console.log("[StormcloudVideoPlayer] Captured pre-ad-break audio state: muted=".concat(captured.muted, ", volume=").concat(captured.volume));
7802
+ }
7803
+ }
7804
+ },
7805
+ {
7806
+ key: "getPreAdBreakAdVolume",
7807
+ value: function getPreAdBreakAdVolume() {
7808
+ var state = this.preAdBreakAudio;
7809
+ if (state) {
7810
+ return state.muted ? 0 : state.volume;
7811
+ }
7812
+ return this.ima.getOriginalMutedState() ? 0 : this.ima.getOriginalVolume();
7813
+ }
7814
+ },
7808
7815
  {
7809
7816
  key: "handleAdPodComplete",
7810
7817
  value: function handleAdPodComplete() {
@@ -7838,14 +7845,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7838
7845
  this.consecutiveFailures = 0;
7839
7846
  this.globalConsecutiveNoFills = 0;
7840
7847
  this.ima.stop().catch(function() {});
7841
- var restoredMuted = this.ima.getOriginalMutedState();
7842
- var restoredVolume = this.ima.getOriginalVolume();
7848
+ var restoredMuted = this.preAdBreakAudio ? this.preAdBreakAudio.muted : this.ima.getOriginalMutedState();
7849
+ var restoredVolume = this.preAdBreakAudio ? this.preAdBreakAudio.volume : this.ima.getOriginalVolume();
7850
+ this.ima.updateOriginalMutedState(restoredMuted, restoredVolume);
7843
7851
  if (this.video.muted !== restoredMuted) {
7844
7852
  this.video.muted = restoredMuted;
7845
7853
  }
7846
7854
  if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
7847
7855
  this.video.volume = restoredVolume;
7848
7856
  }
7857
+ this.preAdBreakAudio = void 0;
7858
+ if (this.config.debugAdTiming) {
7859
+ console.log("[StormcloudVideoPlayer] Restored post-ad-break audio state: muted=".concat(restoredMuted, ", volume=").concat(restoredVolume));
7860
+ }
7849
7861
  if (this.shouldContinueLiveStreamDuringAds()) {
7850
7862
  if (this.video.paused) {
7851
7863
  var _this_video_play;
@@ -8255,6 +8267,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8255
8267
  this.clearAdFailsafeTimer();
8256
8268
  this.clearAdRequestWatchdog();
8257
8269
  this.clearPendingAdBreak();
8270
+ this.preAdBreakAudio = void 0;
8258
8271
  if (this.placeholderContainer) {
8259
8272
  if (this.placeholderContainer.parentElement) {
8260
8273
  this.placeholderContainer.parentElement.removeChild(this.placeholderContainer);
@@ -8289,6 +8302,64 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8289
8302
  // src/ui/StormcloudVideoPlayer.tsx
8290
8303
  var import_fa = require("react-icons/fa");
8291
8304
  var import_jsx_runtime = require("react/jsx-runtime");
8305
+ var ExpandIcon = function ExpandIcon(param) {
8306
+ var _param_size = param.size, size = _param_size === void 0 ? 18 : _param_size;
8307
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
8308
+ width: size,
8309
+ height: size,
8310
+ viewBox: "0 0 24 24",
8311
+ fill: "none",
8312
+ stroke: "currentColor",
8313
+ strokeWidth: 2,
8314
+ strokeLinecap: "round",
8315
+ strokeLinejoin: "round",
8316
+ "aria-hidden": "true",
8317
+ focusable: "false",
8318
+ children: [
8319
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8320
+ d: "M9 4H4v5"
8321
+ }),
8322
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8323
+ d: "M20 9V4h-5"
8324
+ }),
8325
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8326
+ d: "M15 20h5v-5"
8327
+ }),
8328
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8329
+ d: "M4 15v5h5"
8330
+ })
8331
+ ]
8332
+ });
8333
+ };
8334
+ var CompressIcon = function CompressIcon(param) {
8335
+ var _param_size = param.size, size = _param_size === void 0 ? 18 : _param_size;
8336
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
8337
+ width: size,
8338
+ height: size,
8339
+ viewBox: "0 0 24 24",
8340
+ fill: "none",
8341
+ stroke: "currentColor",
8342
+ strokeWidth: 2,
8343
+ strokeLinecap: "round",
8344
+ strokeLinejoin: "round",
8345
+ "aria-hidden": "true",
8346
+ focusable: "false",
8347
+ children: [
8348
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8349
+ d: "M4 9h5V4"
8350
+ }),
8351
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8352
+ d: "M15 4v5h5"
8353
+ }),
8354
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8355
+ d: "M20 15h-5v5"
8356
+ }),
8357
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
8358
+ d: "M9 20v-5H4"
8359
+ })
8360
+ ]
8361
+ });
8362
+ };
8292
8363
  var CRITICAL_PROPS = [
8293
8364
  "src",
8294
8365
  "allowNativeHls",
@@ -9339,9 +9410,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
9339
9410
  minHeight: "".concat(36 * responsiveScale, "px")
9340
9411
  },
9341
9412
  title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
9342
- children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaCompress, {
9413
+ children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompressIcon, {
9343
9414
  size: Math.max(14, 18 * responsiveScale)
9344
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaExpand, {
9415
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExpandIcon, {
9345
9416
  size: Math.max(14, 18 * responsiveScale)
9346
9417
  })
9347
9418
  })
@@ -9539,9 +9610,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
9539
9610
  background: "rgba(0, 0, 0, 0.6)"
9540
9611
  },
9541
9612
  title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
9542
- children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaCompress, {
9613
+ children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompressIcon, {
9543
9614
  size: Math.max(14, 18 * responsiveScale)
9544
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaExpand, {
9615
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExpandIcon, {
9545
9616
  size: Math.max(14, 18 * responsiveScale)
9546
9617
  })
9547
9618
  })