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.
@@ -77,6 +77,7 @@ declare class StormcloudVideoPlayer {
77
77
  private preloadPoolActive;
78
78
  private preloadPoolLoopRunning;
79
79
  private adDetectSentForCurrentBreak;
80
+ private preAdBreakAudio;
80
81
  constructor(config: StormcloudVideoPlayerConfig);
81
82
  private createAdPlayer;
82
83
  load(): Promise<void>;
@@ -134,6 +135,7 @@ declare class StormcloudVideoPlayer {
134
135
  private initializeTracking;
135
136
  private sendHeartbeatIfNeeded;
136
137
  private isVmapEnabled;
138
+ private applyMqttConfigFromResponse;
137
139
  private fetchAdConfiguration;
138
140
  private fetchAndParseVmap;
139
141
  private parseVmapToBreaks;
@@ -183,6 +185,8 @@ declare class StormcloudVideoPlayer {
183
185
  private resetGamNoFillCounter;
184
186
  private enforceGlobalRateLimit;
185
187
  private playSingleAd;
188
+ private capturePreAdBreakAudio;
189
+ private getPreAdBreakAdVolume;
186
190
  private handleAdPodComplete;
187
191
  private handleAdFailure;
188
192
  private startAdRequestWatchdog;
@@ -2442,6 +2442,9 @@ var DEFAULT_MQTT_CONFIG = {
2442
2442
  qos: 1
2443
2443
  };
2444
2444
  var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
2445
+ function applyMQTTConfig(overrides) {
2446
+ Object.assign(mqttConfig, overrides);
2447
+ }
2445
2448
  function isMQTTEnabled() {
2446
2449
  return mqttConfig.enabled;
2447
2450
  }
@@ -3884,10 +3887,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3884
3887
  console.log("[StormcloudVideoPlayer] Starting ad break timer on content_pause (first ad starting)");
3885
3888
  }
3886
3889
  }
3887
- var currentMuted = _this.video.muted;
3888
- var currentVolume = _this.video.volume;
3889
- var adVolume = currentMuted ? 0 : currentVolume;
3890
- _this.ima.setAdVolume(adVolume);
3890
+ _this.ima.setAdVolume(_this.getPreAdBreakAdVolume());
3891
3891
  if (_this.isShowingPlaceholder) {
3892
3892
  if (_this.config.debugAdTiming) {
3893
3893
  console.log("[StormcloudVideoPlayer] Hiding placeholder - new ads starting");
@@ -4641,6 +4641,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4641
4641
  {
4642
4642
  key: "startScte35AdBreak",
4643
4643
  value: function startScte35AdBreak(marker, cueKey, durationMs) {
4644
+ this.capturePreAdBreakAudio();
4644
4645
  if (!this.video.muted) {
4645
4646
  this.video.muted = true;
4646
4647
  this.video.volume = 0;
@@ -5416,6 +5417,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5416
5417
  return !!(this.config.isVmap && ((_this_config_vmapUrl = this.config.vmapUrl) === null || _this_config_vmapUrl === void 0 ? void 0 : _this_config_vmapUrl.trim()));
5417
5418
  }
5418
5419
  },
5420
+ {
5421
+ key: "applyMqttConfigFromResponse",
5422
+ value: function applyMqttConfigFromResponse(data) {
5423
+ var _data_response;
5424
+ var mqttConfig2 = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.mqtt_config;
5425
+ if (!mqttConfig2 || (typeof mqttConfig2 === "undefined" ? "undefined" : _type_of(mqttConfig2)) !== "object") {
5426
+ return;
5427
+ }
5428
+ applyMQTTConfig(mqttConfig2);
5429
+ if (this.config.debugAdTiming) {
5430
+ console.log("[StormcloudVideoPlayer] Applied MQTT config from /ads/web:", mqttConfig2);
5431
+ }
5432
+ }
5433
+ },
5419
5434
  {
5420
5435
  key: "fetchAdConfiguration",
5421
5436
  value: function fetchAdConfiguration() {
@@ -5502,6 +5517,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5502
5517
  ];
5503
5518
  case 4:
5504
5519
  data = _state.sent();
5520
+ this.applyMqttConfigFromResponse(data);
5505
5521
  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;
5506
5522
  if (imaPayload) {
5507
5523
  this.apiVastTagUrl = decodeURIComponent(imaPayload);
@@ -6307,9 +6323,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6307
6323
  this.continuousFetchingActive = true;
6308
6324
  this.isShowingPlaceholder = false;
6309
6325
  this.totalAdRequestsInBreak = 0;
6310
- currentMuted = this.video.muted;
6311
- currentVolume = this.video.volume;
6312
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
6326
+ this.capturePreAdBreakAudio();
6327
+ currentMuted = this.preAdBreakAudio.muted;
6328
+ currentVolume = this.preAdBreakAudio.volume;
6313
6329
  if (!this.video.muted) {
6314
6330
  this.video.muted = true;
6315
6331
  this.video.volume = 0;
@@ -6784,7 +6800,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6784
6800
  value: function tryNextAvailableAd() {
6785
6801
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
6786
6802
  return _async_to_generator(function() {
6787
- var remaining, preloaded, currentMuted, currentVolume, adVolume, error, nextAdUrl, currentMuted1, currentVolume1, error1, errorMessage, maxRetries;
6803
+ var remaining, preloaded, error, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error1, errorMessage, maxRetries;
6788
6804
  return _ts_generator(this, function(_state) {
6789
6805
  switch(_state.label){
6790
6806
  case 0:
@@ -6856,10 +6872,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6856
6872
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6857
6873
  this.scheduleAdStopAtBreakBoundary();
6858
6874
  }
6859
- currentMuted = this.video.muted;
6860
- currentVolume = this.video.volume;
6861
- adVolume = currentMuted ? 0 : currentVolume;
6862
- this.ima.setAdVolume(adVolume);
6875
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
6863
6876
  this.consecutiveFailures = 0;
6864
6877
  return [
6865
6878
  2
@@ -6906,9 +6919,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6906
6919
  if (this.config.debugAdTiming) {
6907
6920
  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)"));
6908
6921
  }
6909
- currentMuted1 = this.video.muted;
6910
- currentVolume1 = this.video.volume;
6911
- this.ima.updateOriginalMutedState(currentMuted1, currentVolume1);
6922
+ 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);
6912
6923
  this.currentAdIndex++;
6913
6924
  this.totalAdRequestsInBreak++;
6914
6925
  this.lastAdRequestTime = Date.now();
@@ -7001,7 +7012,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7001
7012
  key: "showPlaceholderAndWaitForAds",
7002
7013
  value: function showPlaceholderAndWaitForAds() {
7003
7014
  return _async_to_generator(function() {
7004
- var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, currentMuted, currentVolume, error, errorMessage;
7015
+ var remaining, waitTime, checkInterval, maxChecks, i, _ref, _ref1, _this_preAdBreakAudio, _this_preAdBreakAudio1, nextAdUrl, error, errorMessage;
7005
7016
  return _ts_generator(this, function(_state) {
7006
7017
  switch(_state.label){
7007
7018
  case 0:
@@ -7097,9 +7108,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7097
7108
  }
7098
7109
  this.isShowingPlaceholder = false;
7099
7110
  this.ima.hidePlaceholder();
7100
- currentMuted = this.video.muted;
7101
- currentVolume = this.video.volume;
7102
- this.ima.updateOriginalMutedState(currentMuted, currentVolume);
7111
+ 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);
7103
7112
  this.currentAdIndex++;
7104
7113
  this.totalAdRequestsInBreak++;
7105
7114
  this.lastAdRequestTime = Date.now();
@@ -7281,7 +7290,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7281
7290
  first = tags[0];
7282
7291
  rest = tags.slice(1);
7283
7292
  this.adPodQueue = rest;
7284
- this.ima.updateOriginalMutedState(this.video.muted, this.video.volume);
7293
+ this.capturePreAdBreakAudio();
7285
7294
  this.showAds = true;
7286
7295
  this.inAdBreak = true;
7287
7296
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -7308,12 +7317,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7308
7317
  ];
7309
7318
  case 3:
7310
7319
  error = _state.sent();
7311
- this.adPodQueue = [];
7312
- this.inAdBreak = false;
7313
- this.showAds = false;
7314
7320
  if (this.config.debugAdTiming) {
7315
7321
  console.warn("[StormcloudVideoPlayer] VMAP ad request failed:", error);
7316
7322
  }
7323
+ this.handleAdPodComplete();
7317
7324
  return [
7318
7325
  3,
7319
7326
  4
@@ -7544,7 +7551,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7544
7551
  key: "playSingleAd",
7545
7552
  value: function playSingleAd(vastTagUrl) {
7546
7553
  return _async_to_generator(function() {
7547
- var requestToken, currentMuted, currentVolume, adVolume, playError, preloadedFallback, currentMuted1, currentVolume1, adVolume1, fallbackError, error, errorMessage, preloadedFallback1, currentMuted2, currentVolume2, adVolume2, fallbackError1;
7554
+ var requestToken, playError, preloadedFallback, fallbackError, error, errorMessage, preloadedFallback1, fallbackError1;
7548
7555
  return _ts_generator(this, function(_state) {
7549
7556
  switch(_state.label){
7550
7557
  case 0:
@@ -7631,10 +7638,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7631
7638
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7632
7639
  this.scheduleAdStopAtBreakBoundary();
7633
7640
  }
7634
- currentMuted = this.video.muted;
7635
- currentVolume = this.video.volume;
7636
- adVolume = currentMuted ? 0 : currentVolume;
7637
- this.ima.setAdVolume(adVolume);
7641
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7638
7642
  this.consecutiveFailures = 0;
7639
7643
  this.temporaryFailureUrls.delete(vastTagUrl);
7640
7644
  return [
@@ -7681,10 +7685,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7681
7685
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
7682
7686
  this.scheduleAdStopAtBreakBoundary();
7683
7687
  }
7684
- currentMuted1 = this.video.muted;
7685
- currentVolume1 = this.video.volume;
7686
- adVolume1 = currentMuted1 ? 0 : currentVolume1;
7687
- this.ima.setAdVolume(adVolume1);
7688
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7688
7689
  return [
7689
7690
  2
7690
7691
  ];
@@ -7758,10 +7759,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7758
7759
  ];
7759
7760
  case 14:
7760
7761
  _state.sent();
7761
- currentMuted2 = this.video.muted;
7762
- currentVolume2 = this.video.volume;
7763
- adVolume2 = currentMuted2 ? 0 : currentVolume2;
7764
- this.ima.setAdVolume(adVolume2);
7762
+ this.ima.setAdVolume(this.getPreAdBreakAdVolume());
7765
7763
  return [
7766
7764
  2
7767
7765
  ];
@@ -7801,6 +7799,33 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7801
7799
  }).call(this);
7802
7800
  }
7803
7801
  },
7802
+ {
7803
+ key: "capturePreAdBreakAudio",
7804
+ value: function capturePreAdBreakAudio() {
7805
+ if (this.preAdBreakAudio) {
7806
+ return;
7807
+ }
7808
+ var captured = {
7809
+ muted: this.video.muted,
7810
+ volume: typeof this.video.volume === "number" && !Number.isNaN(this.video.volume) ? Math.max(0, Math.min(1, this.video.volume)) : 1
7811
+ };
7812
+ this.preAdBreakAudio = captured;
7813
+ this.ima.updateOriginalMutedState(captured.muted, captured.volume);
7814
+ if (this.config.debugAdTiming) {
7815
+ console.log("[StormcloudVideoPlayer] Captured pre-ad-break audio state: muted=".concat(captured.muted, ", volume=").concat(captured.volume));
7816
+ }
7817
+ }
7818
+ },
7819
+ {
7820
+ key: "getPreAdBreakAdVolume",
7821
+ value: function getPreAdBreakAdVolume() {
7822
+ var state = this.preAdBreakAudio;
7823
+ if (state) {
7824
+ return state.muted ? 0 : state.volume;
7825
+ }
7826
+ return this.ima.getOriginalMutedState() ? 0 : this.ima.getOriginalVolume();
7827
+ }
7828
+ },
7804
7829
  {
7805
7830
  key: "handleAdPodComplete",
7806
7831
  value: function handleAdPodComplete() {
@@ -7834,14 +7859,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7834
7859
  this.consecutiveFailures = 0;
7835
7860
  this.globalConsecutiveNoFills = 0;
7836
7861
  this.ima.stop().catch(function() {});
7837
- var restoredMuted = this.ima.getOriginalMutedState();
7838
- var restoredVolume = this.ima.getOriginalVolume();
7862
+ var restoredMuted = this.preAdBreakAudio ? this.preAdBreakAudio.muted : this.ima.getOriginalMutedState();
7863
+ var restoredVolume = this.preAdBreakAudio ? this.preAdBreakAudio.volume : this.ima.getOriginalVolume();
7864
+ this.ima.updateOriginalMutedState(restoredMuted, restoredVolume);
7839
7865
  if (this.video.muted !== restoredMuted) {
7840
7866
  this.video.muted = restoredMuted;
7841
7867
  }
7842
7868
  if (Math.abs(this.video.volume - restoredVolume) > 0.01) {
7843
7869
  this.video.volume = restoredVolume;
7844
7870
  }
7871
+ this.preAdBreakAudio = void 0;
7872
+ if (this.config.debugAdTiming) {
7873
+ console.log("[StormcloudVideoPlayer] Restored post-ad-break audio state: muted=".concat(restoredMuted, ", volume=").concat(restoredVolume));
7874
+ }
7845
7875
  if (this.shouldContinueLiveStreamDuringAds()) {
7846
7876
  if (this.video.paused) {
7847
7877
  var _this_video_play;
@@ -8251,6 +8281,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8251
8281
  this.clearAdFailsafeTimer();
8252
8282
  this.clearAdRequestWatchdog();
8253
8283
  this.clearPendingAdBreak();
8284
+ this.preAdBreakAudio = void 0;
8254
8285
  if (this.placeholderContainer) {
8255
8286
  if (this.placeholderContainer.parentElement) {
8256
8287
  this.placeholderContainer.parentElement.removeChild(this.placeholderContainer);