stormcloud-video-player 0.8.45 → 0.8.46

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.
@@ -2549,8 +2549,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2549
2549
  var pollIntervalMs = 1e3;
2550
2550
  var graceMs = 5e3;
2551
2551
  var recoveryCooldownMs = 5e3;
2552
- var maxRecoveries = 2;
2553
- var maxMonitorMs = 3e4;
2552
+ var maxRecoveries = 3;
2553
+ var maxMonitorMs = 45e3;
2554
2554
  var startTime = Date.now();
2555
2555
  var baseline = resumeBaseline;
2556
2556
  var recoveries = 0;
@@ -2662,8 +2662,12 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2662
2662
  if (canRecover) {
2663
2663
  recoveries++;
2664
2664
  lastRecoveryAt = Date.now();
2665
- var isFinalAttempt = recoveries >= maxRecoveries;
2666
- if (!isFinalAttempt) {
2665
+ if (recoveries === 1) {
2666
+ if (_this.debug) {
2667
+ console.warn("[StormcloudVideoPlayer] Content wedged after ad break — calling recoverMediaError() (recovery ".concat(recoveries, "/").concat(maxRecoveries, ") — ").concat(_this.describeVideoState()));
2668
+ }
2669
+ _this.host.recoverMediaError();
2670
+ } else if (recoveries === 2) {
2667
2671
  var liveSyncPos = _this.host.getLiveSyncPosition();
2668
2672
  var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
2669
2673
  if (_this.debug) {
@@ -2695,17 +2699,41 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2695
2699
  value: function resumeContentPlayback() {
2696
2700
  var _this = this;
2697
2701
  var attempt = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
2698
- var maxAttempts = 3;
2699
- if (!this.host.video.paused) {
2702
+ var maxAttempts = 5;
2703
+ var video = this.host.video;
2704
+ if (!video.paused) {
2700
2705
  if (this.debug && attempt === 0) {
2701
2706
  console.log("[StormcloudVideoPlayer] Content video already playing after ads");
2702
2707
  }
2703
2708
  return;
2704
2709
  }
2705
2710
  if (this.debug) {
2706
- console.log("[StormcloudVideoPlayer] Resuming content playback after ads (attempt ".concat(attempt + 1, "/").concat(maxAttempts, ")"));
2711
+ console.log("[StormcloudVideoPlayer] Resuming content playback after ads (attempt ".concat(attempt + 1, "/").concat(maxAttempts, ", readyState=").concat(video.readyState, ")"));
2712
+ }
2713
+ if (video.readyState < 3) {
2714
+ if (attempt + 1 >= maxAttempts) {
2715
+ var _video_play;
2716
+ if (this.debug) {
2717
+ console.warn("[StormcloudVideoPlayer] readyState never reached HAVE_FUTURE_DATA, forcing play()");
2718
+ }
2719
+ (_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function() {});
2720
+ return;
2721
+ }
2722
+ var onReady = function onReady1() {
2723
+ video.removeEventListener("canplay", onReady);
2724
+ _this.resumeContentPlayback(attempt + 1);
2725
+ };
2726
+ video.addEventListener("canplay", onReady);
2727
+ var backoffMs = 500 * (attempt + 1);
2728
+ window.setTimeout(function() {
2729
+ video.removeEventListener("canplay", onReady);
2730
+ if (video.paused) {
2731
+ _this.resumeContentPlayback(attempt + 1);
2732
+ }
2733
+ }, backoffMs);
2734
+ return;
2707
2735
  }
2708
- var playResult = this.host.video.play();
2736
+ var playResult = video.play();
2709
2737
  if (playResult && typeof playResult.catch === "function") {
2710
2738
  playResult.catch(function(error) {
2711
2739
  if (attempt + 1 >= maxAttempts) {