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.
@@ -2428,6 +2428,9 @@ var DEFAULT_MQTT_CONFIG = {
2428
2428
  qos: 1
2429
2429
  };
2430
2430
  var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
2431
+ function applyMQTTConfig(overrides) {
2432
+ Object.assign(mqttConfig, overrides);
2433
+ }
2431
2434
  function isMQTTEnabled() {
2432
2435
  return mqttConfig.enabled;
2433
2436
  }
@@ -3870,10 +3873,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3870
3873
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3871
3874
  }
3872
3875
  }
3873
- var currentMuted = _this.video.muted;
3874
- var currentVolume = _this.video.volume;
3875
- var adVolume = currentMuted ? 0 : currentVolume;
3876
- _this.ima.setAdVolume(adVolume);
3876
+ _this.ima.setAdVolume(_this.getPreAdBreakAdVolume());
3877
3877
  if (_this.isShowingPlaceholder) {
3878
3878
  if (_this.config.debugAdTiming) {
3879
3879
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -4627,6 +4627,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4627
4627
  {
4628
4628
  key: "startScte35AdBreak",
4629
4629
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
4630
+ this.capturePreAdBreakAudio();
4630
4631
  if (!this.video.muted) {
4631
4632
  this.video.muted = true;
4632
4633
  this.video.volume = 0;
@@ -5402,6 +5403,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5402
5403
  return !!(this.config.isVmap && ((_this_config_vmapUrl = this.config.vmapUrl) === null || _this_config_vmapUrl === void 0 ? void 0 : _this_config_vmapUrl.trim()));
5403
5404
  }
5404
5405
  },
5406
+ {
5407
+ key: "applyMqttConfigFromResponse",
5408
+ value: function applyMqttConfigFromResponse(data) {
5409
+ var _data_response;
5410
+ var mqttConfig2 = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.mqtt_config;
5411
+ if (!mqttConfig2 || (typeof mqttConfig2 === "undefined" ? "undefined" : _type_of(mqttConfig2)) !== "object") {
5412
+ return;
5413
+ }
5414
+ applyMQTTConfig(mqttConfig2);
5415
+ if (this.config.debugAdTiming) {
5416
+ console.log("[StormcloudVideoPlayer] Applied MQTT config from /ads/web:", mqttConfig2);
5417
+ }
5418
+ }
5419
+ },
5405
5420
  {
5406
5421
  key: "fetchAdConfiguration",
5407
5422
  value: function fetchAdConfiguration() {
@@ -5488,6 +5503,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5488
5503
  ];
5489
5504
  case 4:
5490
5505
  data = _state.sent();
5506
+ this.applyMqttConfigFromResponse(data);
5491
5507
  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;
5492
5508
  if (imaPayload) {
5493
5509
  this.apiVastTagUrl = decodeURIComponent(imaPayload);
@@ -6293,9 +6309,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6293
6309
  this.continuousFetchingActive = true;
6294
6310
  this.isShowingPlaceholder = false;
6295
6311
  this.totalAdRequestsInBreak = 0;
6296
- currentMuted = this.video.muted;
6297
- currentVolume = this.video.volume;
6298
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
6312
+ this.capturePreAdBreakAudio();
6313
+ currentMuted = this.preAdBreakAudio.muted;
6314
+ currentVolume = this.preAdBreakAudio.volume;
6299
6315
  if (!this.video.muted) {
6300
6316
  this.video.muted = true;
6301
6317
  this.video.volume = 0;
@@ -6770,7 +6786,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6770
6786
  value: function tryNextAvailableAd() {
6771
6787
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6772
6788
  return _async_to_generator(function() {
6773
- 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;
6774
6790
  return _ts_generator(this, function(_state) {
6775
6791
  switch(_state.label){
6776
6792
  case 0:
@@ -6842,10 +6858,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6842
6858
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6843
6859
  this.scheduleAdStopAtBreakBoundary();
6844
6860
  }
6845
- currentMuted = this.video.muted;
6846
- currentVolume = this.video.volume;
6847
- adVolume = currentMuted ? 0 : currentVolume;
6848
- this.ima.setAdVolume(adVolume);
6861
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
6849
6862
  this.consecutiveFailures = 0;
6850
6863
  return [
6851
6864
  2
@@ -6892,9 +6905,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6892
6905
  if (this.config.debugAdTiming) {
6893
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)"));
6894
6907
  }
6895
- currentMuted1 = this.video.muted;
6896
- currentVolume1 = this.video.volume;
6897
- 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);
6898
6909
  this.currentAdIndex++;
6899
6910
  this.totalAdRequestsInBreak++;
6900
6911
  this.lastAdRequestTime = Date.now();
@@ -6987,7 +6998,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6987
6998
  key: "showPlaceholderAndWaitForAds",
6988
6999
  value: function showPlaceholderAndWaitForAds() {
6989
7000
  return _async_to_generator(function() {
6990
- 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;
6991
7002
  return _ts_generator(this, function(_state) {
6992
7003
  switch(_state.label){
6993
7004
  case 0:
@@ -7083,9 +7094,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7083
7094
  }
7084
7095
  this.isShowingPlaceholder = false;
7085
7096
  this.ima.hidePlaceholder();
7086
- currentMuted = this.video.muted;
7087
- currentVolume = this.video.volume;
7088
- 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);
7089
7098
  this.currentAdIndex++;
7090
7099
  this.totalAdRequestsInBreak++;
7091
7100
  this.lastAdRequestTime = Date.now();
@@ -7267,7 +7276,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7267
7276
  first = tags[0];
7268
7277
  rest = tags.slice(1);
7269
7278
  this.adPodQueue = rest;
7270
- this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
7279
+ this.capturePreAdBreakAudio();
7271
7280
  this.showAds = true;
7272
7281
  this.inAdBreak = true;
7273
7282
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -7294,12 +7303,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7294
7303
  ];
7295
7304
  case 3:
7296
7305
  error = _state.sent();
7297
- this.adPodQueue = [];
7298
- this.inAdBreak = false;
7299
- this.showAds = false;
7300
7306
  if (this.config.debugAdTiming) {
7301
7307
  console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
7302
7308
  }
7309
+ this.handleAdPodComplete();
7303
7310
  return [
7304
7311
  3,
7305
7312
  4
@@ -7530,7 +7537,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7530
7537
  key: "playSingleAd",
7531
7538
  value: function playSingleAd(vastTagUrl) {
7532
7539
  return _async_to_generator(function() {
7533
- 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;
7534
7541
  return _ts_generator(this, function(_state) {
7535
7542
  switch(_state.label){
7536
7543
  case 0:
@@ -7617,10 +7624,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7617
7624
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7618
7625
  this.scheduleAdStopAtBreakBoundary();
7619
7626
  }
7620
- currentMuted = this.video.muted;
7621
- currentVolume = this.video.volume;
7622
- adVolume = currentMuted ? 0 : currentVolume;
7623
- this.ima.setAdVolume(adVolume);
7627
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7624
7628
  this.consecutiveFailures = 0;
7625
7629
  this.temporaryFailureUrls.delete(vastTagUrl);
7626
7630
  return [
@@ -7667,10 +7671,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7667
7671
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7668
7672
  this.scheduleAdStopAtBreakBoundary();
7669
7673
  }
7670
- currentMuted1 = this.video.muted;
7671
- currentVolume1 = this.video.volume;
7672
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7673
- this.ima.setAdVolume(adVolume1);
7674
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7674
7675
  return [
7675
7676
  2
7676
7677
  ];
@@ -7744,10 +7745,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7744
7745
  ];
7745
7746
  case 14:
7746
7747
  _state.sent();
7747
- currentMuted2 = this.video.muted;
7748
- currentVolume2 = this.video.volume;
7749
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7750
- this.ima.setAdVolume(adVolume2);
7748
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7751
7749
  return [
7752
7750
  2
7753
7751
  ];
@@ -7787,6 +7785,33 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7787
7785
  }).call(this);
7788
7786
  }
7789
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
+ },
7790
7815
  {
7791
7816
  key: "handleAdPodComplete",
7792
7817
  value: function handleAdPodComplete() {
@@ -7820,14 +7845,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7820
7845
  this.consecutiveFailures = 0;
7821
7846
  this.globalConsecutiveNoFills = 0;
7822
7847
  this.ima.stop().catch(function() {});
7823
- var restoredMuted = this.ima.getOriginalMutedState();
7824
- 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);
7825
7851
  if (this.video.muted !== restoredMuted) {
7826
7852
  this.video.muted = restoredMuted;
7827
7853
  }
7828
7854
  if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
7829
7855
  this.video.volume = restoredVolume;
7830
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
+ }
7831
7861
  if (this.shouldContinueLiveStreamDuringAds()) {
7832
7862
  if (this.video.paused) {
7833
7863
  var _this_video_play;
@@ -8237,6 +8267,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8237
8267
  this.clearAdFailsafeTimer();
8238
8268
  this.clearAdRequestWatchdog();
8239
8269
  this.clearPendingAdBreak();
8270
+ this.preAdBreakAudio = void 0;
8240
8271
  if (this.placeholderContainer) {
8241
8272
  if (this.placeholderContainer.parentElement) {
8242
8273
  this.placeholderContainer.parentElement.removeChild(this.placeholderContainer);
@@ -8271,6 +8302,64 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8271
8302
  // src/ui/StormcloudVideoPlayer.tsx
8272
8303
  var import_fa = require("react-icons/fa");
8273
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
+ };
8274
8363
  var CRITICAL_PROPS = [
8275
8364
  "src",
8276
8365
  "allowNativeHls",
@@ -9321,9 +9410,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
9321
9410
  minHeight: "".concat(36 * responsiveScale, "px")
9322
9411
  },
9323
9412
  title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
9324
- children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaCompress, {
9413
+ children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompressIcon, {
9325
9414
  size: Math.max(14, 18 * responsiveScale)
9326
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaExpand, {
9415
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExpandIcon, {
9327
9416
  size: Math.max(14, 18 * responsiveScale)
9328
9417
  })
9329
9418
  })
@@ -9521,9 +9610,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
9521
9610
  background: "rgba(0, 0, 0, 0.6)"
9522
9611
  },
9523
9612
  title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
9524
- children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaCompress, {
9613
+ children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompressIcon, {
9525
9614
  size: Math.max(14, 18 * responsiveScale)
9526
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_fa.FaExpand, {
9615
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExpandIcon, {
9527
9616
  size: Math.max(14, 18 * responsiveScale)
9528
9617
  })
9529
9618
  })