stormcloud-video-player 0.8.42 → 0.8.43

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.
@@ -6201,6 +6201,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6201
6201
  this.isLiveStream = false;
6202
6202
  this.nativeHlsMode = false;
6203
6203
  this.videoSrcProtection = null;
6204
+ this.reloadingLiveStream = false;
6204
6205
  this.bufferedSegmentsCount = 0;
6205
6206
  this.shouldAutoplayAfterBuffering = false;
6206
6207
  this.hasInitialBufferCompleted = false;
@@ -6334,6 +6335,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6334
6335
  _state.sent();
6335
6336
  _state.label = 3;
6336
6337
  case 3:
6338
+ this.reloadingLiveStream = false;
6337
6339
  return [
6338
6340
  2
6339
6341
  ];
@@ -6678,6 +6680,33 @@ var HlsEngine = /*#__PURE__*/ function() {
6678
6680
  }
6679
6681
  }
6680
6682
  },
6683
+ {
6684
+ key: "reloadLiveStream",
6685
+ value: function reloadLiveStream() {
6686
+ var hls = this.hls;
6687
+ if (!hls) {
6688
+ return;
6689
+ }
6690
+ if (this.debug) {
6691
+ console.log("[StormcloudVideoPlayer] Hard-reloading live stream (detach \u2192 reset video \u2192 re-attach)");
6692
+ }
6693
+ try {
6694
+ this.reloadingLiveStream = true;
6695
+ hls.stopLoad();
6696
+ hls.detachMedia();
6697
+ try {
6698
+ this.video.removeAttribute("src");
6699
+ this.video.load();
6700
+ } catch (unused) {}
6701
+ hls.attachMedia(this.video);
6702
+ } catch (error) {
6703
+ this.reloadingLiveStream = false;
6704
+ if (this.debug) {
6705
+ console.warn("[StormcloudVideoPlayer] Failed to hard-reload live stream:", error);
6706
+ }
6707
+ }
6708
+ }
6709
+ },
6681
6710
  {
6682
6711
  key: "destroy",
6683
6712
  value: function destroy() {
@@ -8023,13 +8052,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8023
8052
  var _this = this;
8024
8053
  var pollIntervalMs = 1e3;
8025
8054
  var graceMs = 5e3;
8026
- var reloadCooldownMs = 5e3;
8027
- var maxHardReloads = 2;
8028
- var maxMonitorMs = 25e3;
8055
+ var recoveryCooldownMs = 5e3;
8056
+ var maxRecoveries = 2;
8057
+ var maxMonitorMs = 3e4;
8029
8058
  var startTime = Date.now();
8030
8059
  var baseline = resumeBaseline;
8031
- var hardReloads = 0;
8032
- var lastReloadAt = 0;
8060
+ var recoveries = 0;
8061
+ var lastRecoveryAt = 0;
8033
8062
  var poll = function poll1() {
8034
8063
  if (_this.inAdBreak) {
8035
8064
  return;
@@ -8057,19 +8086,27 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8057
8086
  }
8058
8087
  return;
8059
8088
  }
8060
- var canHardReload = wedged && elapsed >= graceMs && Date.now() - lastReloadAt >= reloadCooldownMs && hardReloads < maxHardReloads;
8061
- if (canHardReload) {
8062
- hardReloads++;
8063
- lastReloadAt = Date.now();
8064
- var liveSyncPos = _this.host.getLiveSyncPosition();
8065
- var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
8066
- if (_this.debug) {
8067
- console.warn("[StormcloudVideoPlayer] Content wedged after ad break (t=".concat(currentTime.toFixed(2), "s, buffered=").concat(bufferedAhead.toFixed(2), "s) forcing HLS reload at ").concat(reloadPos.toFixed(2), "s (hard reload ").concat(hardReloads, "/").concat(maxHardReloads, ")"));
8068
- }
8069
- if (liveSyncPos != null && liveSyncPos > currentTime) {
8070
- video.currentTime = liveSyncPos;
8089
+ var canRecover = wedged && elapsed >= graceMs && Date.now() - lastRecoveryAt >= recoveryCooldownMs && recoveries < maxRecoveries;
8090
+ if (canRecover) {
8091
+ recoveries++;
8092
+ lastRecoveryAt = Date.now();
8093
+ var isFinalAttempt = recoveries >= maxRecoveries;
8094
+ if (!isFinalAttempt) {
8095
+ var liveSyncPos = _this.host.getLiveSyncPosition();
8096
+ var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
8097
+ if (_this.debug) {
8098
+ console.warn("[StormcloudVideoPlayer] Content wedged after ad break (t=".concat(currentTime.toFixed(2), "s, buffered=").concat(bufferedAhead.toFixed(2), "s) — restarting HLS load at ").concat(reloadPos.toFixed(2), "s (recovery ").concat(recoveries, "/").concat(maxRecoveries, ")"));
8099
+ }
8100
+ if (liveSyncPos != null && liveSyncPos > currentTime) {
8101
+ video.currentTime = liveSyncPos;
8102
+ }
8103
+ _this.host.restartHlsLoad(reloadPos);
8104
+ } else {
8105
+ if (_this.debug) {
8106
+ console.warn("[StormcloudVideoPlayer] Content still wedged after ad break (t=".concat(currentTime.toFixed(2), "s, buffered=").concat(bufferedAhead.toFixed(2), "s) — hard-reloading live stream (recovery ").concat(recoveries, "/").concat(maxRecoveries, ")"));
8107
+ }
8108
+ _this.host.reloadLiveStream();
8071
8109
  }
8072
- _this.host.restartHlsLoad(reloadPos);
8073
8110
  baseline = video.currentTime;
8074
8111
  if (video.paused) {
8075
8112
  var _video_play1;
@@ -8232,6 +8269,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8232
8269
  restartHlsLoad: function restartHlsLoad(position) {
8233
8270
  return _this.hlsEngine.restartLoadAt(position);
8234
8271
  },
8272
+ reloadLiveStream: function reloadLiveStream() {
8273
+ return _this.hlsEngine.reloadLiveStream();
8274
+ },
8235
8275
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8236
8276
  return _this.generatePodVastUrl(base, breakDurationMs);
8237
8277
  }
@@ -8363,6 +8403,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8363
8403
  return _async_to_generator(function() {
8364
8404
  var prerollKey, adBehavior;
8365
8405
  return _ts_generator(this, function(_state) {
8406
+ if (this.hlsEngine.reloadingLiveStream) {
8407
+ if (this.debug) {
8408
+ console.log("[StormcloudVideoPlayer] Manifest re-parsed after hard reload \u2014 skipping ad-player setup");
8409
+ }
8410
+ return [
8411
+ 2
8412
+ ];
8413
+ }
8366
8414
  if (!this.adConfig.isVmapEnabled() && !isLive && this.adConfig.vmapBreaks.length === 0 && this.adConfig.apiVastTagUrl) {
8367
8415
  prerollKey = "synthetic-vod-preroll";
8368
8416
  if (!this.adConfig.consumedVmapBreakIds.has(prerollKey)) {