stormcloud-video-player 0.8.36 → 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.
@@ -1136,7 +1136,7 @@ function createHlsAdPlayer(contentVideo, options) {
1136
1136
  adHls.destroy();
1137
1137
  }
1138
1138
  adHls = new import_hls.default({
1139
- enableWorker: true,
1139
+ enableWorker: typeof globalThis !== "undefined",
1140
1140
  lowLatencyMode: false
1141
1141
  });
1142
1142
  adHls.loadSource(mediaFile.url);
@@ -3500,7 +3500,7 @@ function removeBrokenAppNameOrphans(params, appName) {
3500
3500
  try {
3501
3501
  for(var _iterator = appName.split("&").slice(1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3502
3502
  var suffix = _step.value;
3503
- var trimmed = suffix.trimStart();
3503
+ var trimmed = suffix.replace(/^\s+/, "");
3504
3504
  if (!trimmed) continue;
3505
3505
  toDelete.push(suffix, " ".concat(trimmed), trimmed);
3506
3506
  }
@@ -3554,7 +3554,7 @@ function normalizeVastTagUrl(raw) {
3554
3554
  });
3555
3555
  if (orphanFragments.length > 0) {
3556
3556
  var reconstructed = [
3557
- anValue.trimEnd()
3557
+ anValue.replace(/\s+$/, "")
3558
3558
  ].concat(_to_consumable_array(orphanFragments)).filter(Boolean).join(" & ");
3559
3559
  url.searchParams.forEach(function(_value, key) {
3560
3560
  if (key && INVALID_VAST_PARAM_KEY.test(key)) {
@@ -6242,7 +6242,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6242
6242
  value: function setupHls() {
6243
6243
  var _this = this;
6244
6244
  this.hls = new import_hls2.default(_object_spread_props(_object_spread({
6245
- enableWorker: true,
6245
+ enableWorker: typeof globalThis !== "undefined",
6246
6246
  backBufferLength: 30,
6247
6247
  liveDurationInfinity: true,
6248
6248
  lowLatencyMode: !!this.config.lowLatencyMode,
@@ -6631,6 +6631,22 @@ var HlsEngine = /*#__PURE__*/ function() {
6631
6631
  return typeof pos === "number" && Number.isFinite(pos) ? pos : void 0;
6632
6632
  }
6633
6633
  },
6634
+ {
6635
+ key: "restartLoadAt",
6636
+ value: function restartLoadAt(position) {
6637
+ if (!this.hls) {
6638
+ return;
6639
+ }
6640
+ try {
6641
+ this.hls.stopLoad();
6642
+ this.hls.startLoad(position);
6643
+ } catch (error) {
6644
+ if (this.debug) {
6645
+ console.warn("[StormcloudVideoPlayer] Failed to restart HLS load at live edge:", error);
6646
+ }
6647
+ }
6648
+ }
6649
+ },
6634
6650
  {
6635
6651
  key: "destroy",
6636
6652
  value: function destroy() {
@@ -7947,11 +7963,56 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7947
7963
  console.log("[StormcloudVideoPlayer] Live break end — snapping to live edge: ".concat(this.host.video.currentTime.toFixed(2), "s → ").concat(liveSyncPos.toFixed(2), "s"));
7948
7964
  }
7949
7965
  this.host.video.currentTime = liveSyncPos;
7966
+ this.host.restartHlsLoad(liveSyncPos);
7950
7967
  }
7968
+ this.resumeContentPlayback();
7969
+ this.monitorLiveResumeStall(0, this.host.video.currentTime);
7970
+ return;
7951
7971
  }
7952
7972
  this.resumeContentPlayback();
7953
7973
  }
7954
7974
  },
7975
+ {
7976
+ key: "monitorLiveResumeStall",
7977
+ value: function monitorLiveResumeStall(attempt, lastTime) {
7978
+ var _this = this;
7979
+ var maxAttempts = 3;
7980
+ var checkDelayMs = 2500;
7981
+ window.setTimeout(function() {
7982
+ if (_this.inAdBreak) {
7983
+ return;
7984
+ }
7985
+ var currentTime = _this.host.video.currentTime;
7986
+ var advanced = currentTime > lastTime + 0.25;
7987
+ if (advanced && !_this.host.video.paused) {
7988
+ if (_this.debug) {
7989
+ console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break");
7990
+ }
7991
+ return;
7992
+ }
7993
+ if (attempt >= maxAttempts) {
7994
+ if (_this.debug) {
7995
+ console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat(maxAttempts, " recovery attempts (t=").concat(currentTime.toFixed(2), "s)"));
7996
+ }
7997
+ return;
7998
+ }
7999
+ if (_this.debug) {
8000
+ 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, ")"));
8001
+ }
8002
+ var liveSyncPos = _this.host.getLiveSyncPosition();
8003
+ var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
8004
+ if (liveSyncPos != null && liveSyncPos > currentTime) {
8005
+ _this.host.video.currentTime = liveSyncPos;
8006
+ }
8007
+ _this.host.restartHlsLoad(reloadPos);
8008
+ if (_this.host.video.paused) {
8009
+ var _this_host_video_play;
8010
+ (_this_host_video_play = _this.host.video.play()) === null || _this_host_video_play === void 0 ? void 0 : _this_host_video_play.catch(function() {});
8011
+ }
8012
+ _this.monitorLiveResumeStall(attempt + 1, _this.host.video.currentTime);
8013
+ }, checkDelayMs);
8014
+ }
8015
+ },
7955
8016
  {
7956
8017
  key: "resumeContentPlayback",
7957
8018
  value: function resumeContentPlayback() {
@@ -8100,6 +8161,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8100
8161
  getLiveSyncPosition: function getLiveSyncPosition() {
8101
8162
  return _this.hlsEngine.getLiveSyncPosition();
8102
8163
  },
8164
+ restartHlsLoad: function restartHlsLoad(position) {
8165
+ return _this.hlsEngine.restartLoadAt(position);
8166
+ },
8103
8167
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8104
8168
  return _this.generatePodVastUrl(base, breakDurationMs);
8105
8169
  }