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.
package/lib/Player.d.cts CHANGED
@@ -9,7 +9,7 @@ interface PlayerProps extends BaseStormcloudPlayerProps {
9
9
  }
10
10
  declare class Player extends Component<PlayerProps> {
11
11
  static displayName: string;
12
- static defaultProps: Required<Omit<BaseStormcloudPlayerProps, "ctvAdRequest" | keyof React.VideoHTMLAttributes<HTMLVideoElement> | "onReady">>;
12
+ static defaultProps: Required<Omit<BaseStormcloudPlayerProps, "ctvAdRequest" | "onReady" | keyof React.VideoHTMLAttributes<HTMLVideoElement>>>;
13
13
  private mounted;
14
14
  private isReady;
15
15
  private isPlaying;
@@ -8938,6 +8938,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8938
8938
  this.adPodQueue = [];
8939
8939
  this.defaultMinRemainingMsToRequestAd = 1e4;
8940
8940
  this.defaultMaxNoFillsPerBreak = 2;
8941
+ this.defaultLiveMaxNoFillsPerBreak = 1;
8942
+ this.breakDurationWaitMs = 300;
8941
8943
  this.pendingAdBreak = null;
8942
8944
  this.host = host;
8943
8945
  this.timing = timing;
@@ -9054,7 +9056,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9054
9056
  }
9055
9057
  });
9056
9058
  adPlayer.on("ad_error", function(errorPayload) {
9057
- var errorMessage = "Ad playback failed";
9059
+ if (_this.controllerCallInFlight) {
9060
+ if (_this.debug) {
9061
+ console.log("[AdBreak] ad_error during request/play; outcome reported by the caller", errorPayload || "");
9062
+ }
9063
+ return;
9064
+ }
9065
+ var errorMessage = "Ad error (no details)";
9058
9066
  if (errorPayload) {
9059
9067
  var errorCode = errorPayload.code || errorPayload.errorCode || "unknown";
9060
9068
  var vastErrorCode = errorPayload.vastErrorCode;
@@ -9070,9 +9078,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9070
9078
  }
9071
9079
  }
9072
9080
  console.error("[AD-ERROR]", errorMessage, errorPayload || "");
9073
- if (_this.controllerCallInFlight) {
9074
- return;
9075
- }
9076
9081
  _this.handleAdFailure("ad_error");
9077
9082
  });
9078
9083
  adPlayer.on("content_pause", function() {
@@ -9223,7 +9228,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9223
9228
  key: "handleAdStart",
9224
9229
  value: function handleAdStart(marker) {
9225
9230
  return _async_to_generator(function() {
9226
- var baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, epoch, podPlayed;
9231
+ var baseVastUrl, adBreakDurationMs, currentMuted, currentVolume, epoch, hasPrefetchedUrl, mode, podPlayed;
9227
9232
  return _ts_generator(this, function(_state) {
9228
9233
  switch(_state.label){
9229
9234
  case 0:
@@ -9245,10 +9250,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9245
9250
  ];
9246
9251
  }
9247
9252
  adBreakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : this.timing.expectedAdBreakDurationMs;
9248
- if (this.debug) {
9249
- mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
9250
- console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
9251
- }
9252
9253
  this.timing.failedVastUrls.clear();
9253
9254
  this.timing.temporaryFailureUrls.clear();
9254
9255
  this.timing.consecutiveFailures = 0;
@@ -9277,11 +9278,31 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9277
9278
  }
9278
9279
  this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
9279
9280
  epoch = this.timing.adBreakEpoch;
9281
+ hasPrefetchedUrl = !!(this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0);
9282
+ if (!(adBreakDurationMs == null && !hasPrefetchedUrl)) return [
9283
+ 3,
9284
+ 2
9285
+ ];
9280
9286
  return [
9281
9287
  4,
9282
- this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
9288
+ this.waitForBreakDuration(this.breakDurationWaitMs)
9283
9289
  ];
9284
9290
  case 1:
9291
+ adBreakDurationMs = _state.sent();
9292
+ if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) return [
9293
+ 2
9294
+ ];
9295
+ _state.label = 2;
9296
+ case 2:
9297
+ if (this.debug) {
9298
+ mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
9299
+ console.log("[AdBreak] ".concat(mode, " break start: target duration=").concat(adBreakDurationMs != null ? "".concat(adBreakDurationMs, "ms") : "unknown"));
9300
+ }
9301
+ return [
9302
+ 4,
9303
+ this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
9304
+ ];
9305
+ case 3:
9285
9306
  podPlayed = _state.sent();
9286
9307
  if (!podPlayed && this.inAdBreak && epoch === this.timing.adBreakEpoch) {
9287
9308
  this.setSlotState("NEEDS_NEXT_AD", "initial_request_failed");
@@ -9295,6 +9316,53 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9295
9316
  }).call(this);
9296
9317
  }
9297
9318
  },
9319
+ {
9320
+ key: "waitForBreakDuration",
9321
+ value: function waitForBreakDuration(maxWaitMs) {
9322
+ return _async_to_generator(function() {
9323
+ var deadline, durationMs;
9324
+ return _ts_generator(this, function(_state) {
9325
+ switch(_state.label){
9326
+ case 0:
9327
+ deadline = Date.now() + maxWaitMs;
9328
+ _state.label = 1;
9329
+ case 1:
9330
+ if (!(this.timing.expectedAdBreakDurationMs == null && Date.now() < deadline)) return [
9331
+ 3,
9332
+ 3
9333
+ ];
9334
+ return [
9335
+ 4,
9336
+ new Promise(function(resolve) {
9337
+ return setTimeout(resolve, 50);
9338
+ })
9339
+ ];
9340
+ case 2:
9341
+ _state.sent();
9342
+ if (!this.inAdBreak) return [
9343
+ 3,
9344
+ 3
9345
+ ];
9346
+ return [
9347
+ 3,
9348
+ 1
9349
+ ];
9350
+ case 3:
9351
+ durationMs = this.timing.expectedAdBreakDurationMs;
9352
+ this.logOrchestratorFunnel("break_duration_wait", {
9353
+ waitedForMs: maxWaitMs - Math.max(0, deadline - Date.now()),
9354
+ durationMs: durationMs,
9355
+ resolved: durationMs != null
9356
+ });
9357
+ return [
9358
+ 2,
9359
+ durationMs
9360
+ ];
9361
+ }
9362
+ });
9363
+ }).call(this);
9364
+ }
9365
+ },
9298
9366
  {
9299
9367
  key: "startOptimizedPod",
9300
9368
  value: // ───────────────────────────────────────────────────────────────
@@ -9481,7 +9549,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9481
9549
  key: "getMaxNoFillsPerBreak",
9482
9550
  value: function getMaxNoFillsPerBreak() {
9483
9551
  var configured = this.host.config.maxNoFillsPerBreak;
9484
- return typeof configured === "number" && configured > 0 ? configured : this.defaultMaxNoFillsPerBreak;
9552
+ if (typeof configured === "number" && configured > 0) return configured;
9553
+ return this.breakSource === "scte35" ? this.defaultLiveMaxNoFillsPerBreak : this.defaultMaxNoFillsPerBreak;
9485
9554
  }
9486
9555
  },
9487
9556
  {
@@ -9677,6 +9746,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9677
9746
  } catch (unused) {}
9678
9747
  var adType = (_ref = params === null || params === void 0 ? void 0 : params.get("ad_type")) !== null && _ref !== void 0 ? _ref : void 0;
9679
9748
  this.logOrchestratorFunnel("vast_url_generated", {
9749
+ requestId: void 0,
9680
9750
  source: source,
9681
9751
  pod: (_ref1 = params === null || params === void 0 ? void 0 : params.get("pod")) !== null && _ref1 !== void 0 ? _ref1 : void 0,
9682
9752
  pmad: (_ref2 = params === null || params === void 0 ? void 0 : params.get("pmad")) !== null && _ref2 !== void 0 ? _ref2 : void 0,
@@ -10211,6 +10281,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10211
10281
  key: "handleAdPodComplete",
10212
10282
  value: function handleAdPodComplete() {
10213
10283
  var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "unspecified";
10284
+ var _this_breakFunnel_play_called, _this_breakFunnel_impression_fired;
10214
10285
  if (this.debug) {
10215
10286
  console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up", {
10216
10287
  reason: reason
@@ -10235,6 +10306,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10235
10306
  }
10236
10307
  this.finalizeRequestDiagnostics(this.currentRequestId, "break_ended:".concat(reason));
10237
10308
  this.currentRequestId = void 0;
10309
+ 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;
10238
10310
  this.timing.resetForBreakEnd();
10239
10311
  this.placeholder.hide();
10240
10312
  this.clearPendingAdBreak();
@@ -10273,6 +10345,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10273
10345
  this.monitorLiveResumeStall(this.host.video.currentTime);
10274
10346
  return;
10275
10347
  }
10348
+ if (!contentWasInterrupted) {
10349
+ if (this.debug) {
10350
+ console.log("[StormcloudVideoPlayer] Live break end \u2014 no ad was shown, leaving playback position unchanged");
10351
+ }
10352
+ this.resumeContentPlayback();
10353
+ return;
10354
+ }
10276
10355
  var liveSyncPos = this.host.getLiveSyncPosition();
10277
10356
  if (liveSyncPos != null && liveSyncPos > this.host.video.currentTime) {
10278
10357
  if (this.debug) {