stormcloud-video-player 0.8.45 → 0.8.47

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.
@@ -2485,6 +2485,14 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2485
2485
  this.host.video.style.visibility = "visible";
2486
2486
  this.host.video.style.opacity = "1";
2487
2487
  if (this.host.isLiveStream()) {
2488
+ if (this.host.requiresMediaPipelineResetAfterAds()) {
2489
+ if (this.debug) {
2490
+ console.log("[StormcloudVideoPlayer] Live break end \u2014 hard-reloading stream to reacquire decoder (single-decoder platform)");
2491
+ }
2492
+ this.host.reloadLiveStream();
2493
+ this.monitorLiveResumeStall(this.host.video.currentTime);
2494
+ return;
2495
+ }
2488
2496
  var liveSyncPos = this.host.getLiveSyncPosition();
2489
2497
  if (liveSyncPos != null && liveSyncPos > this.host.video.currentTime) {
2490
2498
  if (this.debug) {
@@ -2546,11 +2554,12 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2546
2554
  key: "monitorLiveResumeStall",
2547
2555
  value: function monitorLiveResumeStall(resumeBaseline) {
2548
2556
  var _this = this;
2557
+ var needsReset = this.host.requiresMediaPipelineResetAfterAds();
2549
2558
  var pollIntervalMs = 1e3;
2550
- var graceMs = 5e3;
2551
- var recoveryCooldownMs = 5e3;
2552
- var maxRecoveries = 2;
2553
- var maxMonitorMs = 3e4;
2559
+ var graceMs = needsReset ? 8e3 : 5e3;
2560
+ var recoveryCooldownMs = needsReset ? 7e3 : 5e3;
2561
+ var maxRecoveries = 3;
2562
+ var maxMonitorMs = 45e3;
2554
2563
  var startTime = Date.now();
2555
2564
  var baseline = resumeBaseline;
2556
2565
  var recoveries = 0;
@@ -2662,8 +2671,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2662
2671
  if (canRecover) {
2663
2672
  recoveries++;
2664
2673
  lastRecoveryAt = Date.now();
2665
- var isFinalAttempt = recoveries >= maxRecoveries;
2666
- if (!isFinalAttempt) {
2674
+ if (needsReset) {
2675
+ if (_this.debug) {
2676
+ console.warn("[StormcloudVideoPlayer] Content still wedged after ad break — hard-reloading live stream (recovery ".concat(recoveries, "/").concat(maxRecoveries, ") — ").concat(_this.describeVideoState()));
2677
+ }
2678
+ _this.host.reloadLiveStream();
2679
+ } else if (recoveries === 1) {
2680
+ if (_this.debug) {
2681
+ console.warn("[StormcloudVideoPlayer] Content wedged after ad break — calling recoverMediaError() (recovery ".concat(recoveries, "/").concat(maxRecoveries, ") — ").concat(_this.describeVideoState()));
2682
+ }
2683
+ _this.host.recoverMediaError();
2684
+ } else if (recoveries === 2) {
2667
2685
  var liveSyncPos = _this.host.getLiveSyncPosition();
2668
2686
  var reloadPos = liveSyncPos != null && liveSyncPos > currentTime ? liveSyncPos : currentTime;
2669
2687
  if (_this.debug) {
@@ -2695,17 +2713,41 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2695
2713
  value: function resumeContentPlayback() {
2696
2714
  var _this = this;
2697
2715
  var attempt = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
2698
- var maxAttempts = 3;
2699
- if (!this.host.video.paused) {
2716
+ var maxAttempts = 5;
2717
+ var video = this.host.video;
2718
+ if (!video.paused) {
2700
2719
  if (this.debug && attempt === 0) {
2701
2720
  console.log("[StormcloudVideoPlayer] Content video already playing after ads");
2702
2721
  }
2703
2722
  return;
2704
2723
  }
2705
2724
  if (this.debug) {
2706
- console.log("[StormcloudVideoPlayer] Resuming content playback after ads (attempt ".concat(attempt + 1, "/").concat(maxAttempts, ")"));
2725
+ console.log("[StormcloudVideoPlayer] Resuming content playback after ads (attempt ".concat(attempt + 1, "/").concat(maxAttempts, ", readyState=").concat(video.readyState, ")"));
2726
+ }
2727
+ if (video.readyState < 3) {
2728
+ if (attempt + 1 >= maxAttempts) {
2729
+ var _video_play;
2730
+ if (this.debug) {
2731
+ console.warn("[StormcloudVideoPlayer] readyState never reached HAVE_FUTURE_DATA, forcing play()");
2732
+ }
2733
+ (_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function() {});
2734
+ return;
2735
+ }
2736
+ var onReady = function onReady1() {
2737
+ video.removeEventListener("canplay", onReady);
2738
+ _this.resumeContentPlayback(attempt + 1);
2739
+ };
2740
+ video.addEventListener("canplay", onReady);
2741
+ var backoffMs = 500 * (attempt + 1);
2742
+ window.setTimeout(function() {
2743
+ video.removeEventListener("canplay", onReady);
2744
+ if (video.paused) {
2745
+ _this.resumeContentPlayback(attempt + 1);
2746
+ }
2747
+ }, backoffMs);
2748
+ return;
2707
2749
  }
2708
- var playResult = this.host.video.play();
2750
+ var playResult = video.play();
2709
2751
  if (playResult && typeof playResult.catch === "function") {
2710
2752
  playResult.catch(function(error) {
2711
2753
  if (attempt + 1 >= maxAttempts) {