stormcloud-video-player 0.8.67 → 0.8.68

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.
@@ -8935,6 +8935,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8935
8935
  this.adPodQueue = [];
8936
8936
  this.defaultMinRemainingMsToRequestAd = 1e4;
8937
8937
  this.defaultMaxNoFillsPerBreak = 2;
8938
+ this.defaultLiveMaxNoFillsPerBreak = 1;
8939
+ this.breakDurationWaitMs = 300;
8938
8940
  this.pendingAdBreak = null;
8939
8941
  this.host = host;
8940
8942
  this.timing = timing;
@@ -9051,7 +9053,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9051
9053
  }
9052
9054
  });
9053
9055
  adPlayer.on("ad_error", function(errorPayload) {
9054
- var errorMessage = "Ad playback failed";
9056
+ if (_this.controllerCallInFlight) {
9057
+ if (_this.debug) {
9058
+ console.log("[AdBreak] ad_error during request/play; outcome reported by the caller", errorPayload || "");
9059
+ }
9060
+ return;
9061
+ }
9062
+ var errorMessage = "Ad error (no details)";
9055
9063
  if (errorPayload) {
9056
9064
  var errorCode = errorPayload.code || errorPayload.errorCode || "unknown";
9057
9065
  var vastErrorCode = errorPayload.vastErrorCode;
@@ -9067,9 +9075,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9067
9075
  }
9068
9076
  }
9069
9077
  console.error("[AD-ERROR]", errorMessage, errorPayload || "");
9070
- if (_this.controllerCallInFlight) {
9071
- return;
9072
- }
9073
9078
  _this.handleAdFailure("ad_error");
9074
9079
  });
9075
9080
  adPlayer.on("content_pause", function() {
@@ -9220,7 +9225,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9220
9225
  key: "handleAdStart",
9221
9226
  value: function handleAdStart(marker) {
9222
9227
  return _async_to_generator(function() {
9223
- var baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, epoch, podPlayed;
9228
+ var baseVastUrl, adBreakDurationMs, currentMuted, currentVolume, epoch, hasPrefetchedUrl, mode, podPlayed;
9224
9229
  return _ts_generator(this, function(_state) {
9225
9230
  switch(_state.label){
9226
9231
  case 0:
@@ -9242,10 +9247,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9242
9247
  ];
9243
9248
  }
9244
9249
  adBreakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : this.timing.expectedAdBreakDurationMs;
9245
- if (this.debug) {
9246
- mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
9247
- console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
9248
- }
9249
9250
  this.timing.failedVastUrls.clear();
9250
9251
  this.timing.temporaryFailureUrls.clear();
9251
9252
  this.timing.consecutiveFailures = 0;
@@ -9274,11 +9275,31 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9274
9275
  }
9275
9276
  this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
9276
9277
  epoch = this.timing.adBreakEpoch;
9278
+ hasPrefetchedUrl = !!(this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0);
9279
+ if (!(adBreakDurationMs == null && !hasPrefetchedUrl)) return [
9280
+ 3,
9281
+ 2
9282
+ ];
9277
9283
  return [
9278
9284
  4,
9279
- this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
9285
+ this.waitForBreakDuration(this.breakDurationWaitMs)
9280
9286
  ];
9281
9287
  case 1:
9288
+ adBreakDurationMs = _state.sent();
9289
+ if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) return [
9290
+ 2
9291
+ ];
9292
+ _state.label = 2;
9293
+ case 2:
9294
+ if (this.debug) {
9295
+ mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
9296
+ console.log("[AdBreak] ".concat(mode, " break start: target duration=").concat(adBreakDurationMs != null ? "".concat(adBreakDurationMs, "ms") : "unknown"));
9297
+ }
9298
+ return [
9299
+ 4,
9300
+ this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
9301
+ ];
9302
+ case 3:
9282
9303
  podPlayed = _state.sent();
9283
9304
  if (!podPlayed && this.inAdBreak && epoch === this.timing.adBreakEpoch) {
9284
9305
  this.setSlotState("NEEDS_NEXT_AD", "initial_request_failed");
@@ -9292,6 +9313,53 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9292
9313
  }).call(this);
9293
9314
  }
9294
9315
  },
9316
+ {
9317
+ key: "waitForBreakDuration",
9318
+ value: function waitForBreakDuration(maxWaitMs) {
9319
+ return _async_to_generator(function() {
9320
+ var deadline, durationMs;
9321
+ return _ts_generator(this, function(_state) {
9322
+ switch(_state.label){
9323
+ case 0:
9324
+ deadline = Date.now() + maxWaitMs;
9325
+ _state.label = 1;
9326
+ case 1:
9327
+ if (!(this.timing.expectedAdBreakDurationMs == null && Date.now() < deadline)) return [
9328
+ 3,
9329
+ 3
9330
+ ];
9331
+ return [
9332
+ 4,
9333
+ new Promise(function(resolve) {
9334
+ return setTimeout(resolve, 50);
9335
+ })
9336
+ ];
9337
+ case 2:
9338
+ _state.sent();
9339
+ if (!this.inAdBreak) return [
9340
+ 3,
9341
+ 3
9342
+ ];
9343
+ return [
9344
+ 3,
9345
+ 1
9346
+ ];
9347
+ case 3:
9348
+ durationMs = this.timing.expectedAdBreakDurationMs;
9349
+ this.logOrchestratorFunnel("break_duration_wait", {
9350
+ waitedForMs: maxWaitMs - Math.max(0, deadline - Date.now()),
9351
+ durationMs: durationMs,
9352
+ resolved: durationMs != null
9353
+ });
9354
+ return [
9355
+ 2,
9356
+ durationMs
9357
+ ];
9358
+ }
9359
+ });
9360
+ }).call(this);
9361
+ }
9362
+ },
9295
9363
  {
9296
9364
  key: "startOptimizedPod",
9297
9365
  value: // ───────────────────────────────────────────────────────────────
@@ -9478,7 +9546,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9478
9546
  key: "getMaxNoFillsPerBreak",
9479
9547
  value: function getMaxNoFillsPerBreak() {
9480
9548
  var configured = this.host.config.maxNoFillsPerBreak;
9481
- return typeof configured === "number" && configured > 0 ? configured : this.defaultMaxNoFillsPerBreak;
9549
+ if (typeof configured === "number" && configured > 0) return configured;
9550
+ return this.breakSource === "scte35" ? this.defaultLiveMaxNoFillsPerBreak : this.defaultMaxNoFillsPerBreak;
9482
9551
  }
9483
9552
  },
9484
9553
  {
@@ -9674,6 +9743,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9674
9743
  } catch (unused) {}
9675
9744
  var adType = (_ref = params === null || params === void 0 ? void 0 : params.get("ad_type")) !== null && _ref !== void 0 ? _ref : void 0;
9676
9745
  this.logOrchestratorFunnel("vast_url_generated", {
9746
+ requestId: void 0,
9677
9747
  source: source,
9678
9748
  pod: (_ref1 = params === null || params === void 0 ? void 0 : params.get("pod")) !== null && _ref1 !== void 0 ? _ref1 : void 0,
9679
9749
  pmad: (_ref2 = params === null || params === void 0 ? void 0 : params.get("pmad")) !== null && _ref2 !== void 0 ? _ref2 : void 0,
@@ -10208,6 +10278,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10208
10278
  key: "handleAdPodComplete",
10209
10279
  value: function handleAdPodComplete() {
10210
10280
  var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "unspecified";
10281
+ var _this_breakFunnel_play_called, _this_breakFunnel_impression_fired;
10211
10282
  if (this.debug) {
10212
10283
  console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up", {
10213
10284
  reason: reason
@@ -10232,6 +10303,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10232
10303
  }
10233
10304
  this.finalizeRequestDiagnostics(this.currentRequestId, "break_ended:".concat(reason));
10234
10305
  this.currentRequestId = void 0;
10306
+ var contentWasInterrupted = this.showAds || this.isShowingPlaceholder || ((_this_breakFunnel_play_called = this.breakFunnel["play_called"]) !== null && _this_breakFunnel_play_called !== void 0 ? _this_breakFunnel_play_called : 0) > 0 || ((_this_breakFunnel_impression_fired = this.breakFunnel["impression_fired"]) !== null && _this_breakFunnel_impression_fired !== void 0 ? _this_breakFunnel_impression_fired : 0) > 0;
10235
10307
  this.timing.resetForBreakEnd();
10236
10308
  this.placeholder.hide();
10237
10309
  this.clearPendingAdBreak();
@@ -10270,6 +10342,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10270
10342
  this.monitorLiveResumeStall(this.host.video.currentTime);
10271
10343
  return;
10272
10344
  }
10345
+ if (!contentWasInterrupted) {
10346
+ if (this.debug) {
10347
+ console.log("[StormcloudVideoPlayer] Live break end \u2014 no ad was shown, leaving playback position unchanged");
10348
+ }
10349
+ this.resumeContentPlayback();
10350
+ return;
10351
+ }
10273
10352
  var liveSyncPos = this.host.getLiveSyncPosition();
10274
10353
  if (liveSyncPos != null && liveSyncPos > this.host.video.currentTime) {
10275
10354
  if (this.debug) {