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.
package/lib/index.js CHANGED
@@ -1120,7 +1120,7 @@ function createHlsAdPlayer(contentVideo, options) {
1120
1120
  adHls.destroy();
1121
1121
  }
1122
1122
  adHls = new Hls({
1123
- enableWorker: true,
1123
+ enableWorker: typeof globalThis !== "undefined",
1124
1124
  lowLatencyMode: false
1125
1125
  });
1126
1126
  adHls.loadSource(mediaFile.url);
@@ -3507,7 +3507,7 @@ function removeBrokenAppNameOrphans(params, appName) {
3507
3507
  try {
3508
3508
  for(var _iterator = appName.split("&").slice(1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3509
3509
  var suffix = _step.value;
3510
- var trimmed = suffix.trimStart();
3510
+ var trimmed = suffix.replace(/^\s+/, "");
3511
3511
  if (!trimmed) continue;
3512
3512
  toDelete.push(suffix, " ".concat(trimmed), trimmed);
3513
3513
  }
@@ -3561,7 +3561,7 @@ function normalizeVastTagUrl(raw) {
3561
3561
  });
3562
3562
  if (orphanFragments.length > 0) {
3563
3563
  var reconstructed = [
3564
- anValue.trimEnd()
3564
+ anValue.replace(/\s+$/, "")
3565
3565
  ].concat(_to_consumable_array(orphanFragments)).filter(Boolean).join(" & ");
3566
3566
  url.searchParams.forEach(function(_value, key) {
3567
3567
  if (key && INVALID_VAST_PARAM_KEY.test(key)) {
@@ -6278,7 +6278,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6278
6278
  value: function setupHls() {
6279
6279
  var _this = this;
6280
6280
  this.hls = new Hls2(_object_spread_props(_object_spread({
6281
- enableWorker: true,
6281
+ enableWorker: typeof globalThis !== "undefined",
6282
6282
  backBufferLength: 30,
6283
6283
  liveDurationInfinity: true,
6284
6284
  lowLatencyMode: !!this.config.lowLatencyMode,
@@ -6667,6 +6667,22 @@ var HlsEngine = /*#__PURE__*/ function() {
6667
6667
  return typeof pos === "number" && Number.isFinite(pos) ? pos : void 0;
6668
6668
  }
6669
6669
  },
6670
+ {
6671
+ key: "restartLoadAt",
6672
+ value: function restartLoadAt(position) {
6673
+ if (!this.hls) {
6674
+ return;
6675
+ }
6676
+ try {
6677
+ this.hls.stopLoad();
6678
+ this.hls.startLoad(position);
6679
+ } catch (error) {
6680
+ if (this.debug) {
6681
+ console.warn("[StormcloudVideoPlayer] Failed to restart HLS load at live edge:", error);
6682
+ }
6683
+ }
6684
+ }
6685
+ },
6670
6686
  {
6671
6687
  key: "destroy",
6672
6688
  value: function destroy() {
@@ -7984,11 +8000,56 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7984
8000
  console.log("[StormcloudVideoPlayer] Live break end — snapping to live edge: ".concat(this.host.video.currentTime.toFixed(2), "s → ").concat(liveSyncPos.toFixed(2), "s"));
7985
8001
  }
7986
8002
  this.host.video.currentTime = liveSyncPos;
8003
+ this.host.restartHlsLoad(liveSyncPos);
7987
8004
  }
8005
+ this.resumeContentPlayback();
8006
+ this.monitorLiveResumeStall(0, this.host.video.currentTime);
8007
+ return;
7988
8008
  }
7989
8009
  this.resumeContentPlayback();
7990
8010
  }
7991
8011
  },
8012
+ {
8013
+ key: "monitorLiveResumeStall",
8014
+ value: function monitorLiveResumeStall(attempt, lastTime) {
8015
+ var _this = this;
8016
+ var maxAttempts = 3;
8017
+ var checkDelayMs = 2500;
8018
+ window.setTimeout(function() {
8019
+ if (_this.inAdBreak) {
8020
+ return;
8021
+ }
8022
+ var currentTime = _this.host.video.currentTime;
8023
+ var advanced = currentTime > lastTime + 0.25;
8024
+ if (advanced && !_this.host.video.paused) {
8025
+ if (_this.debug) {
8026
+ console.log("[StormcloudVideoPlayer] Live stream resumed successfully after ad break");
8027
+ }
8028
+ return;
8029
+ }
8030
+ if (attempt >= maxAttempts) {
8031
+ if (_this.debug) {
8032
+ console.warn("[StormcloudVideoPlayer] Live stream failed to resume after ".concat(maxAttempts, " recovery attempts (t=").concat(currentTime.toFixed(2), "s)"));
8033
+ }
8034
+ return;
8035
+ }
8036
+ if (_this.debug) {
8037
+ 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, ")"));
8038
+ }
8039
+ var liveSyncPos = _this.host.getLiveSyncPosition();
8040
+ var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
8041
+ if (liveSyncPos != null && liveSyncPos > currentTime) {
8042
+ _this.host.video.currentTime = liveSyncPos;
8043
+ }
8044
+ _this.host.restartHlsLoad(reloadPos);
8045
+ if (_this.host.video.paused) {
8046
+ var _this_host_video_play;
8047
+ (_this_host_video_play = _this.host.video.play()) === null || _this_host_video_play === void 0 ? void 0 : _this_host_video_play.catch(function() {});
8048
+ }
8049
+ _this.monitorLiveResumeStall(attempt + 1, _this.host.video.currentTime);
8050
+ }, checkDelayMs);
8051
+ }
8052
+ },
7992
8053
  {
7993
8054
  key: "resumeContentPlayback",
7994
8055
  value: function resumeContentPlayback() {
@@ -8138,6 +8199,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8138
8199
  getLiveSyncPosition: function getLiveSyncPosition() {
8139
8200
  return _this.hlsEngine.getLiveSyncPosition();
8140
8201
  },
8202
+ restartHlsLoad: function restartHlsLoad(position) {
8203
+ return _this.hlsEngine.restartLoadAt(position);
8204
+ },
8141
8205
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8142
8206
  return _this.generatePodVastUrl(base, breakDurationMs);
8143
8207
  }