stormcloud-video-player 0.8.35 → 0.8.37

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.
@@ -1150,7 +1150,7 @@ function createHlsAdPlayer(contentVideo, options) {
1150
1150
  adHls.destroy();
1151
1151
  }
1152
1152
  adHls = new import_hls.default({
1153
- enableWorker: true,
1153
+ enableWorker: typeof globalThis !== "undefined",
1154
1154
  lowLatencyMode: false
1155
1155
  });
1156
1156
  adHls.loadSource(mediaFile.url);
@@ -1906,6 +1906,9 @@ var DEFAULT_MQTT_CONFIG = {
1906
1906
  qos: 1
1907
1907
  };
1908
1908
  var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
1909
+ function applyMQTTConfig(overrides) {
1910
+ Object.assign(mqttConfig, overrides);
1911
+ }
1909
1912
  function isMQTTEnabled() {
1910
1913
  return mqttConfig.enabled;
1911
1914
  }
@@ -3511,7 +3514,7 @@ function removeBrokenAppNameOrphans(params, appName) {
3511
3514
  try {
3512
3515
  for(var _iterator = appName.split("&").slice(1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3513
3516
  var suffix = _step.value;
3514
- var trimmed = suffix.trimStart();
3517
+ var trimmed = suffix.replace(/^\s+/, "");
3515
3518
  if (!trimmed) continue;
3516
3519
  toDelete.push(suffix, " ".concat(trimmed), trimmed);
3517
3520
  }
@@ -3565,7 +3568,7 @@ function normalizeVastTagUrl(raw) {
3565
3568
  });
3566
3569
  if (orphanFragments.length > 0) {
3567
3570
  var reconstructed = [
3568
- anValue.trimEnd()
3571
+ anValue.replace(/\s+$/, "")
3569
3572
  ].concat(_to_consumable_array(orphanFragments)).filter(Boolean).join(" & ");
3570
3573
  url.searchParams.forEach(function(_value, key) {
3571
3574
  if (key && INVALID_VAST_PARAM_KEY.test(key)) {
@@ -5077,6 +5080,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
5077
5080
  ];
5078
5081
  case 4:
5079
5082
  data = _state.sent();
5083
+ this.applyMqttConfigFromResponse(data);
5080
5084
  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;
5081
5085
  if (imaPayload) {
5082
5086
  decodedPayload = imaPayload;
@@ -5110,6 +5114,20 @@ var AdConfigManager = /*#__PURE__*/ function() {
5110
5114
  }).call(this);
5111
5115
  }
5112
5116
  },
5117
+ {
5118
+ key: "applyMqttConfigFromResponse",
5119
+ value: function applyMqttConfigFromResponse(data) {
5120
+ var _data_response;
5121
+ var mqttConfig2 = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.mqtt_config;
5122
+ if (!mqttConfig2 || (typeof mqttConfig2 === "undefined" ? "undefined" : _type_of(mqttConfig2)) !== "object") {
5123
+ return;
5124
+ }
5125
+ applyMQTTConfig(mqttConfig2);
5126
+ if (this.debug) {
5127
+ console.log("[StormcloudVideoPlayer] Applied MQTT config from /ads/web:", mqttConfig2);
5128
+ }
5129
+ }
5130
+ },
5113
5131
  {
5114
5132
  key: "fetchAndParseVmap",
5115
5133
  value: function fetchAndParseVmap(vmapUrl) {
@@ -6238,7 +6256,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6238
6256
  value: function setupHls() {
6239
6257
  var _this = this;
6240
6258
  this.hls = new import_hls2.default(_object_spread_props(_object_spread({
6241
- enableWorker: true,
6259
+ enableWorker: typeof globalThis !== "undefined",
6242
6260
  backBufferLength: 30,
6243
6261
  liveDurationInfinity: true,
6244
6262
  lowLatencyMode: !!this.config.lowLatencyMode,
@@ -6627,6 +6645,22 @@ var HlsEngine = /*#__PURE__*/ function() {
6627
6645
  return typeof pos === "number" && Number.isFinite(pos) ? pos : void 0;
6628
6646
  }
6629
6647
  },
6648
+ {
6649
+ key: "restartLoadAt",
6650
+ value: function restartLoadAt(position) {
6651
+ if (!this.hls) {
6652
+ return;
6653
+ }
6654
+ try {
6655
+ this.hls.stopLoad();
6656
+ this.hls.startLoad(position);
6657
+ } catch (error) {
6658
+ if (this.debug) {
6659
+ console.warn("[StormcloudVideoPlayer] Failed to restart HLS load at live edge:", error);
6660
+ }
6661
+ }
6662
+ }
6663
+ },
6630
6664
  {
6631
6665
  key: "destroy",
6632
6666
  value: function destroy() {
@@ -7943,11 +7977,56 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7943
7977
  console.log("[StormcloudVideoPlayer] Live break end — snapping to live edge: ".concat(this.host.video.currentTime.toFixed(2), "s → ").concat(liveSyncPos.toFixed(2), "s"));
7944
7978
  }
7945
7979
  this.host.video.currentTime = liveSyncPos;
7980
+ this.host.restartHlsLoad(liveSyncPos);
7946
7981
  }
7982
+ this.resumeContentPlayback();
7983
+ this.monitorLiveResumeStall(0, this.host.video.currentTime);
7984
+ return;
7947
7985
  }
7948
7986
  this.resumeContentPlayback();
7949
7987
  }
7950
7988
  },
7989
+ {
7990
+ key: "monitorLiveResumeStall",
7991
+ value: function monitorLiveResumeStall(attempt, lastTime) {
7992
+ var _this = this;
7993
+ var maxAttempts = 3;
7994
+ var checkDelayMs = 2500;
7995
+ window.setTimeout(function() {
7996
+ if (_this.inAdBreak) {
7997
+ return;
7998
+ }
7999
+ var currentTime = _this.host.video.currentTime;
8000
+ var advanced = currentTime > lastTime + 0.25;
8001
+ if (advanced && !_this.host.video.paused) {
8002
+ if (_this.debug) {
8003
+ console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break");
8004
+ }
8005
+ return;
8006
+ }
8007
+ if (attempt >= maxAttempts) {
8008
+ if (_this.debug) {
8009
+ console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat(maxAttempts, " recovery attempts (t=").concat(currentTime.toFixed(2), "s)"));
8010
+ }
8011
+ return;
8012
+ }
8013
+ if (_this.debug) {
8014
+ console.warn("[StormcloudVideoPlayer] Content stalled after ad break (t=".concat(currentTime.toFixed(2), "s) — forcing HLS reload at live edge (attempt ").concat(attempt + 1, "/").concat(maxAttempts, ")"));
8015
+ }
8016
+ var liveSyncPos = _this.host.getLiveSyncPosition();
8017
+ var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
8018
+ if (liveSyncPos != null && liveSyncPos > currentTime) {
8019
+ _this.host.video.currentTime = liveSyncPos;
8020
+ }
8021
+ _this.host.restartHlsLoad(reloadPos);
8022
+ if (_this.host.video.paused) {
8023
+ var _this_host_video_play;
8024
+ (_this_host_video_play = _this.host.video.play()) === null || _this_host_video_play === void 0 ? void 0 : _this_host_video_play.catch(function() {});
8025
+ }
8026
+ _this.monitorLiveResumeStall(attempt + 1, _this.host.video.currentTime);
8027
+ }, checkDelayMs);
8028
+ }
8029
+ },
7951
8030
  {
7952
8031
  key: "resumeContentPlayback",
7953
8032
  value: function resumeContentPlayback() {
@@ -8096,6 +8175,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8096
8175
  getLiveSyncPosition: function getLiveSyncPosition() {
8097
8176
  return _this.hlsEngine.getLiveSyncPosition();
8098
8177
  },
8178
+ restartHlsLoad: function restartHlsLoad(position) {
8179
+ return _this.hlsEngine.restartLoadAt(position);
8180
+ },
8099
8181
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8100
8182
  return _this.generatePodVastUrl(base, breakDurationMs);
8101
8183
  }