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.
@@ -1186,7 +1186,7 @@ function createHlsAdPlayer(contentVideo, options) {
1186
1186
  adHls.destroy();
1187
1187
  }
1188
1188
  adHls = new import_hls.default({
1189
- enableWorker: true,
1189
+ enableWorker: typeof globalThis !== "undefined",
1190
1190
  lowLatencyMode: false
1191
1191
  });
1192
1192
  adHls.loadSource(mediaFile.url);
@@ -1942,6 +1942,9 @@ var DEFAULT_MQTT_CONFIG = {
1942
1942
  qos: 1
1943
1943
  };
1944
1944
  var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
1945
+ function applyMQTTConfig(overrides) {
1946
+ Object.assign(mqttConfig, overrides);
1947
+ }
1945
1948
  function isMQTTEnabled() {
1946
1949
  return mqttConfig.enabled;
1947
1950
  }
@@ -3547,7 +3550,7 @@ function removeBrokenAppNameOrphans(params, appName) {
3547
3550
  try {
3548
3551
  for(var _iterator = appName.split("&").slice(1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3549
3552
  var suffix = _step.value;
3550
- var trimmed = suffix.trimStart();
3553
+ var trimmed = suffix.replace(/^\s+/, "");
3551
3554
  if (!trimmed) continue;
3552
3555
  toDelete.push(suffix, " ".concat(trimmed), trimmed);
3553
3556
  }
@@ -3601,7 +3604,7 @@ function normalizeVastTagUrl(raw) {
3601
3604
  });
3602
3605
  if (orphanFragments.length > 0) {
3603
3606
  var reconstructed = [
3604
- anValue.trimEnd()
3607
+ anValue.replace(/\s+$/, "")
3605
3608
  ].concat(_to_consumable_array(orphanFragments)).filter(Boolean).join(" & ");
3606
3609
  url.searchParams.forEach(function(_value, key) {
3607
3610
  if (key && INVALID_VAST_PARAM_KEY.test(key)) {
@@ -5113,6 +5116,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
5113
5116
  ];
5114
5117
  case 4:
5115
5118
  data = _state.sent();
5119
+ this.applyMqttConfigFromResponse(data);
5116
5120
  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;
5117
5121
  if (imaPayload) {
5118
5122
  decodedPayload = imaPayload;
@@ -5146,6 +5150,20 @@ var AdConfigManager = /*#__PURE__*/ function() {
5146
5150
  }).call(this);
5147
5151
  }
5148
5152
  },
5153
+ {
5154
+ key: "applyMqttConfigFromResponse",
5155
+ value: function applyMqttConfigFromResponse(data) {
5156
+ var _data_response;
5157
+ var mqttConfig2 = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : _data_response.mqtt_config;
5158
+ if (!mqttConfig2 || (typeof mqttConfig2 === "undefined" ? "undefined" : _type_of(mqttConfig2)) !== "object") {
5159
+ return;
5160
+ }
5161
+ applyMQTTConfig(mqttConfig2);
5162
+ if (this.debug) {
5163
+ console.log("[StormcloudVideoPlayer] Applied MQTT config from /ads/web:", mqttConfig2);
5164
+ }
5165
+ }
5166
+ },
5149
5167
  {
5150
5168
  key: "fetchAndParseVmap",
5151
5169
  value: function fetchAndParseVmap(vmapUrl) {
@@ -6274,7 +6292,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6274
6292
  value: function setupHls() {
6275
6293
  var _this = this;
6276
6294
  this.hls = new import_hls2.default(_object_spread_props(_object_spread({
6277
- enableWorker: true,
6295
+ enableWorker: typeof globalThis !== "undefined",
6278
6296
  backBufferLength: 30,
6279
6297
  liveDurationInfinity: true,
6280
6298
  lowLatencyMode: !!this.config.lowLatencyMode,
@@ -6663,6 +6681,22 @@ var HlsEngine = /*#__PURE__*/ function() {
6663
6681
  return typeof pos === "number" && Number.isFinite(pos) ? pos : void 0;
6664
6682
  }
6665
6683
  },
6684
+ {
6685
+ key: "restartLoadAt",
6686
+ value: function restartLoadAt(position) {
6687
+ if (!this.hls) {
6688
+ return;
6689
+ }
6690
+ try {
6691
+ this.hls.stopLoad();
6692
+ this.hls.startLoad(position);
6693
+ } catch (error) {
6694
+ if (this.debug) {
6695
+ console.warn("[StormcloudVideoPlayer] Failed to restart HLS load at live edge:", error);
6696
+ }
6697
+ }
6698
+ }
6699
+ },
6666
6700
  {
6667
6701
  key: "destroy",
6668
6702
  value: function destroy() {
@@ -7979,11 +8013,56 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7979
8013
  console.log("[StormcloudVideoPlayer] Live break end — snapping to live edge: ".concat(this.host.video.currentTime.toFixed(2), "s → ").concat(liveSyncPos.toFixed(2), "s"));
7980
8014
  }
7981
8015
  this.host.video.currentTime = liveSyncPos;
8016
+ this.host.restartHlsLoad(liveSyncPos);
7982
8017
  }
8018
+ this.resumeContentPlayback();
8019
+ this.monitorLiveResumeStall(0, this.host.video.currentTime);
8020
+ return;
7983
8021
  }
7984
8022
  this.resumeContentPlayback();
7985
8023
  }
7986
8024
  },
8025
+ {
8026
+ key: "monitorLiveResumeStall",
8027
+ value: function monitorLiveResumeStall(attempt, lastTime) {
8028
+ var _this = this;
8029
+ var maxAttempts = 3;
8030
+ var checkDelayMs = 2500;
8031
+ window.setTimeout(function() {
8032
+ if (_this.inAdBreak) {
8033
+ return;
8034
+ }
8035
+ var currentTime = _this.host.video.currentTime;
8036
+ var advanced = currentTime > lastTime + 0.25;
8037
+ if (advanced && !_this.host.video.paused) {
8038
+ if (_this.debug) {
8039
+ console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break");
8040
+ }
8041
+ return;
8042
+ }
8043
+ if (attempt >= maxAttempts) {
8044
+ if (_this.debug) {
8045
+ console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat(maxAttempts, " recovery attempts (t=").concat(currentTime.toFixed(2), "s)"));
8046
+ }
8047
+ return;
8048
+ }
8049
+ if (_this.debug) {
8050
+ 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, ")"));
8051
+ }
8052
+ var liveSyncPos = _this.host.getLiveSyncPosition();
8053
+ var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
8054
+ if (liveSyncPos != null && liveSyncPos > currentTime) {
8055
+ _this.host.video.currentTime = liveSyncPos;
8056
+ }
8057
+ _this.host.restartHlsLoad(reloadPos);
8058
+ if (_this.host.video.paused) {
8059
+ var _this_host_video_play;
8060
+ (_this_host_video_play = _this.host.video.play()) === null || _this_host_video_play === void 0 ? void 0 : _this_host_video_play.catch(function() {});
8061
+ }
8062
+ _this.monitorLiveResumeStall(attempt + 1, _this.host.video.currentTime);
8063
+ }, checkDelayMs);
8064
+ }
8065
+ },
7987
8066
  {
7988
8067
  key: "resumeContentPlayback",
7989
8068
  value: function resumeContentPlayback() {
@@ -8132,6 +8211,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8132
8211
  getLiveSyncPosition: function getLiveSyncPosition() {
8133
8212
  return _this.hlsEngine.getLiveSyncPosition();
8134
8213
  },
8214
+ restartHlsLoad: function restartHlsLoad(position) {
8215
+ return _this.hlsEngine.restartLoadAt(position);
8216
+ },
8135
8217
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8136
8218
  return _this.generatePodVastUrl(base, breakDurationMs);
8137
8219
  }