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.
@@ -6238,6 +6238,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6238
6238
  this.isLiveStream = false;
6239
6239
  this.nativeHlsMode = false;
6240
6240
  this.videoSrcProtection = null;
6241
+ this.reloadingLiveStream = false;
6241
6242
  this.bufferedSegmentsCount = 0;
6242
6243
  this.shouldAutoplayAfterBuffering = false;
6243
6244
  this.hasInitialBufferCompleted = false;
@@ -6371,6 +6372,7 @@ var HlsEngine = /*#__PURE__*/ function() {
6371
6372
  _state.sent();
6372
6373
  _state.label = 3;
6373
6374
  case 3:
6375
+ this.reloadingLiveStream = false;
6374
6376
  return [
6375
6377
  2
6376
6378
  ];
@@ -6715,6 +6717,33 @@ var HlsEngine = /*#__PURE__*/ function() {
6715
6717
  }
6716
6718
  }
6717
6719
  },
6720
+ {
6721
+ key: "reloadLiveStream",
6722
+ value: function reloadLiveStream() {
6723
+ var hls = this.hls;
6724
+ if (!hls) {
6725
+ return;
6726
+ }
6727
+ if (this.debug) {
6728
+ console.log("[StormcloudVideoPlayer] Hard-reloading live stream (detach \u2192 reset video \u2192 re-attach)");
6729
+ }
6730
+ try {
6731
+ this.reloadingLiveStream = true;
6732
+ hls.stopLoad();
6733
+ hls.detachMedia();
6734
+ try {
6735
+ this.video.removeAttribute("src");
6736
+ this.video.load();
6737
+ } catch (unused) {}
6738
+ hls.attachMedia(this.video);
6739
+ } catch (error) {
6740
+ this.reloadingLiveStream = false;
6741
+ if (this.debug) {
6742
+ console.warn("[StormcloudVideoPlayer] Failed to hard-reload live stream:", error);
6743
+ }
6744
+ }
6745
+ }
6746
+ },
6718
6747
  {
6719
6748
  key: "destroy",
6720
6749
  value: function destroy() {
@@ -8060,13 +8089,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8060
8089
  var _this = this;
8061
8090
  var pollIntervalMs = 1e3;
8062
8091
  var graceMs = 5e3;
8063
- var reloadCooldownMs = 5e3;
8064
- var maxHardReloads = 2;
8065
- var maxMonitorMs = 25e3;
8092
+ var recoveryCooldownMs = 5e3;
8093
+ var maxRecoveries = 2;
8094
+ var maxMonitorMs = 3e4;
8066
8095
  var startTime = Date.now();
8067
8096
  var baseline = resumeBaseline;
8068
- var hardReloads = 0;
8069
- var lastReloadAt = 0;
8097
+ var recoveries = 0;
8098
+ var lastRecoveryAt = 0;
8070
8099
  var poll = function poll1() {
8071
8100
  if (_this.inAdBreak) {
8072
8101
  return;
@@ -8094,19 +8123,27 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8094
8123
  }
8095
8124
  return;
8096
8125
  }
8097
- var canHardReload = wedged && elapsed >= graceMs && Date.now() - lastReloadAt >= reloadCooldownMs && hardReloads < maxHardReloads;
8098
- if (canHardReload) {
8099
- hardReloads++;
8100
- lastReloadAt = Date.now();
8101
- var liveSyncPos = _this.host.getLiveSyncPosition();
8102
- var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
8103
- if (_this.debug) {
8104
- 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, ")"));
8105
- }
8106
- if (liveSyncPos != null && liveSyncPos > currentTime) {
8107
- video.currentTime = liveSyncPos;
8126
+ var canRecover = wedged && elapsed >= graceMs && Date.now() - lastRecoveryAt >= recoveryCooldownMs && recoveries < maxRecoveries;
8127
+ if (canRecover) {
8128
+ recoveries++;
8129
+ lastRecoveryAt = Date.now();
8130
+ var isFinalAttempt = recoveries >= maxRecoveries;
8131
+ if (!isFinalAttempt) {
8132
+ var liveSyncPos = _this.host.getLiveSyncPosition();
8133
+ var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
8134
+ if (_this.debug) {
8135
+ 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, ")"));
8136
+ }
8137
+ if (liveSyncPos != null && liveSyncPos > currentTime) {
8138
+ video.currentTime = liveSyncPos;
8139
+ }
8140
+ _this.host.restartHlsLoad(reloadPos);
8141
+ } else {
8142
+ if (_this.debug) {
8143
+ 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, ")"));
8144
+ }
8145
+ _this.host.reloadLiveStream();
8108
8146
  }
8109
- _this.host.restartHlsLoad(reloadPos);
8110
8147
  baseline = video.currentTime;
8111
8148
  if (video.paused) {
8112
8149
  var _video_play1;
@@ -8269,6 +8306,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8269
8306
  restartHlsLoad: function restartHlsLoad(position) {
8270
8307
  return _this.hlsEngine.restartLoadAt(position);
8271
8308
  },
8309
+ reloadLiveStream: function reloadLiveStream() {
8310
+ return _this.hlsEngine.reloadLiveStream();
8311
+ },
8272
8312
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8273
8313
  return _this.generatePodVastUrl(base, breakDurationMs);
8274
8314
  }
@@ -8400,6 +8440,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8400
8440
  return _async_to_generator(function() {
8401
8441
  var prerollKey, adBehavior;
8402
8442
  return _ts_generator(this, function(_state) {
8443
+ if (this.hlsEngine.reloadingLiveStream) {
8444
+ if (this.debug) {
8445
+ console.log("[StormcloudVideoPlayer] Manifest re-parsed after hard reload \u2014 skipping ad-player setup");
8446
+ }
8447
+ return [
8448
+ 2
8449
+ ];
8450
+ }
8403
8451
  if (!this.adConfig.isVmapEnabled() && !isLive && this.adConfig.vmapBreaks.length === 0 && this.adConfig.apiVastTagUrl) {
8404
8452
  prerollKey = "synthetic-vod-preroll";
8405
8453
  if (!this.adConfig.consumedVmapBreakIds.has(prerollKey)) {