stormcloud-video-player 0.3.65 → 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;
@@ -5659,6 +5657,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5659
5657
  return !!(this.config.isVmap && ((_this_config_vmapUrl = this.config.vmapUrl) === null || _this_config_vmapUrl === void 0 ? void 0 : _this_config_vmapUrl.trim()));
5660
5658
  }
5661
5659
  },
5660
+ {
5661
+ key: "applyMqttConfigFromResponse",
5662
+ value: function applyMqttConfigFromResponse(data) {
5663
+ var _data_response;
5664
+ var mqttConfig2 = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.mqtt_config;
5665
+ if (!mqttConfig2 || (typeof mqttConfig2 === "undefined" ? "undefined" : _type_of(mqttConfig2)) !== "object") {
5666
+ return;
5667
+ }
5668
+ applyMQTTConfig(mqttConfig2);
5669
+ if (this.config.debugAdTiming) {
5670
+ console.log("[StormcloudVideoPlayer] Applied MQTT config from /ads/web:", mqttConfig2);
5671
+ }
5672
+ }
5673
+ },
5662
5674
  {
5663
5675
  key: "fetchAdConfiguration",
5664
5676
  value: function fetchAdConfiguration() {
@@ -5745,6 +5757,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5745
5757
  ];
5746
5758
  case 4:
5747
5759
  data = _state.sent();
5760
+ this.applyMqttConfigFromResponse(data);
5748
5761
  imaPayload = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : (_data_response_ima = _data_response.ima) === null || _data_response_ima === void 0 ? void 0 : (_data_response_ima_publisherdeskima = _data_response_ima["publisherdesk.ima"]) === null || _data_response_ima_publisherdeskima === void 0 ? void 0 : _data_response_ima_publisherdeskima.payload;
5749
5762
  if (imaPayload) {
5750
5763
  this.apiVastTagUrl = decodeURIComponent(imaPayload);
@@ -6550,9 +6563,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6550
6563
  this.continuousFetchingActive = true;
6551
6564
  this.isShowingPlaceholder = false;
6552
6565
  this.totalAdRequestsInBreak = 0;
6553
- currentMuted = this.video.muted;
6554
- currentVolume = this.video.volume;
6555
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
6566
+ this.capturePreAdBreakAudio();
6567
+ currentMuted = this.preAdBreakAudio.muted;
6568
+ currentVolume = this.preAdBreakAudio.volume;
6556
6569
  if (!this.video.muted) {
6557
6570
  this.video.muted = true;
6558
6571
  this.video.volume = 0;
@@ -7027,7 +7040,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7027
7040
  value: function tryNextAvailableAd() {
7028
7041
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
7029
7042
  return _async_to_generator(function() {
7030
- 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;
7031
7044
  return _ts_generator(this, function(_state) {
7032
7045
  switch(_state.label){
7033
7046
  case 0:
@@ -7099,10 +7112,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7099
7112
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7100
7113
  this.scheduleAdStopAtBreakBoundary();
7101
7114
  }
7102
- currentMuted = this.video.muted;
7103
- currentVolume = this.video.volume;
7104
- adVolume = currentMuted ? 0 : currentVolume;
7105
- this.ima.setAdVolume(adVolume);
7115
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7106
7116
  this.consecutiveFailures = 0;
7107
7117
  return [
7108
7118
  2
@@ -7149,9 +7159,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7149
7159
  if (this.config.debugAdTiming) {
7150
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)"));
7151
7161
  }
7152
- currentMuted1 = this.video.muted;
7153
- currentVolume1 = this.video.volume;
7154
- 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);
7155
7163
  this.currentAdIndex++;
7156
7164
  this.totalAdRequestsInBreak++;
7157
7165
  this.lastAdRequestTime = Date.now();
@@ -7244,7 +7252,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7244
7252
  key: "showPlaceholderAndWaitForAds",
7245
7253
  value: function showPlaceholderAndWaitForAds() {
7246
7254
  return _async_to_generator(function() {
7247
- 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;
7248
7256
  return _ts_generator(this, function(_state) {
7249
7257
  switch(_state.label){
7250
7258
  case 0:
@@ -7340,9 +7348,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7340
7348
  }
7341
7349
  this.isShowingPlaceholder = false;
7342
7350
  this.ima.hidePlaceholder();
7343
- currentMuted = this.video.muted;
7344
- currentVolume = this.video.volume;
7345
- 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);
7346
7352
  this.currentAdIndex++;
7347
7353
  this.totalAdRequestsInBreak++;
7348
7354
  this.lastAdRequestTime = Date.now();
@@ -7524,7 +7530,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7524
7530
  first = tags[0];
7525
7531
  rest = tags.slice(1);
7526
7532
  this.adPodQueue = rest;
7527
- this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
7533
+ this.capturePreAdBreakAudio();
7528
7534
  this.showAds = true;
7529
7535
  this.inAdBreak = true;
7530
7536
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -7551,12 +7557,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7551
7557
  ];
7552
7558
  case 3:
7553
7559
  error = _state.sent();
7554
- this.adPodQueue = [];
7555
- this.inAdBreak = false;
7556
- this.showAds = false;
7557
7560
  if (this.config.debugAdTiming) {
7558
7561
  console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
7559
7562
  }
7563
+ this.handleAdPodComplete();
7560
7564
  return [
7561
7565
  3,
7562
7566
  4
@@ -7787,7 +7791,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7787
7791
  key: "playSingleAd",
7788
7792
  value: function playSingleAd(vastTagUrl) {
7789
7793
  return _async_to_generator(function() {
7790
- 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;
7791
7795
  return _ts_generator(this, function(_state) {
7792
7796
  switch(_state.label){
7793
7797
  case 0:
@@ -7874,10 +7878,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7874
7878
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7875
7879
  this.scheduleAdStopAtBreakBoundary();
7876
7880
  }
7877
- currentMuted = this.video.muted;
7878
- currentVolume = this.video.volume;
7879
- adVolume = currentMuted ? 0 : currentVolume;
7880
- this.ima.setAdVolume(adVolume);
7881
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7881
7882
  this.consecutiveFailures = 0;
7882
7883
  this.temporaryFailureUrls.delete(vastTagUrl);
7883
7884
  return [
@@ -7924,10 +7925,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7924
7925
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7925
7926
  this.scheduleAdStopAtBreakBoundary();
7926
7927
  }
7927
- currentMuted1 = this.video.muted;
7928
- currentVolume1 = this.video.volume;
7929
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7930
- this.ima.setAdVolume(adVolume1);
7928
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7931
7929
  return [
7932
7930
  2
7933
7931
  ];
@@ -8001,10 +7999,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8001
7999
  ];
8002
8000
  case 14:
8003
8001
  _state.sent();
8004
- currentMuted2 = this.video.muted;
8005
- currentVolume2 = this.video.volume;
8006
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
8007
- this.ima.setAdVolume(adVolume2);
8002
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
8008
8003
  return [
8009
8004
  2
8010
8005
  ];
@@ -8044,6 +8039,33 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8044
8039
  }).call(this);
8045
8040
  }
8046
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
+ },
8047
8069
  {
8048
8070
  key: "handleAdPodComplete",
8049
8071
  value: function handleAdPodComplete() {
@@ -8077,14 +8099,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8077
8099
  this.consecutiveFailures = 0;
8078
8100
  this.globalConsecutiveNoFills = 0;
8079
8101
  this.ima.stop().catch(function() {});
8080
- var restoredMuted = this.ima.getOriginalMutedState();
8081
- 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);
8082
8105
  if (this.video.muted !== restoredMuted) {
8083
8106
  this.video.muted = restoredMuted;
8084
8107
  }
8085
8108
  if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
8086
8109
  this.video.volume = restoredVolume;
8087
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
+ }
8088
8115
  if (this.shouldContinueLiveStreamDuringAds()) {
8089
8116
  if (this.video.paused) {
8090
8117
  var _this_video_play;
@@ -8494,6 +8521,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8494
8521
  this.clearAdFailsafeTimer();
8495
8522
  this.clearAdRequestWatchdog();
8496
8523
  this.clearPendingAdBreak();
8524
+ this.preAdBreakAudio = void 0;
8497
8525
  if (this.placeholderContainer) {
8498
8526
  if (this.placeholderContainer.parentElement) {
8499
8527
  this.placeholderContainer.parentElement.removeChild(this.placeholderContainer);
@@ -8528,6 +8556,64 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8528
8556
  // src/ui/StormcloudVideoPlayer.tsx
8529
8557
  var import_fa = require("react-icons/fa");
8530
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
+ };
8531
8617
  var CRITICAL_PROPS = [
8532
8618
  "src",
8533
8619
  "allowNativeHls",
@@ -9578,9 +9664,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
9578
9664
  minHeight: "".concat(36 * responsiveScale, "px")
9579
9665
  },
9580
9666
  title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
9581
- children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaCompress, {
9667
+ children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompressIcon, {
9582
9668
  size: Math.max(14, 18 * responsiveScale)
9583
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaExpand, {
9669
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExpandIcon, {
9584
9670
  size: Math.max(14, 18 * responsiveScale)
9585
9671
  })
9586
9672
  })
@@ -9778,9 +9864,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
9778
9864
  background: "rgba(0, 0, 0, 0.6)"
9779
9865
  },
9780
9866
  title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
9781
- children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaCompress, {
9867
+ children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompressIcon, {
9782
9868
  size: Math.max(14, 18 * responsiveScale)
9783
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaExpand, {
9869
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExpandIcon, {
9784
9870
  size: Math.max(14, 18 * responsiveScale)
9785
9871
  })
9786
9872
  })