stormcloud-video-player 0.8.66 → 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.
@@ -8889,6 +8889,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8889
8889
  this.adPodQueue = [];
8890
8890
  this.defaultMinRemainingMsToRequestAd = 1e4;
8891
8891
  this.defaultMaxNoFillsPerBreak = 2;
8892
+ this.defaultLiveMaxNoFillsPerBreak = 1;
8893
+ this.breakDurationWaitMs = 300;
8892
8894
  this.pendingAdBreak = null;
8893
8895
  this.host = host;
8894
8896
  this.timing = timing;
@@ -9005,7 +9007,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9005
9007
  }
9006
9008
  });
9007
9009
  adPlayer.on("ad_error", function(errorPayload) {
9008
- var errorMessage = "Ad playback failed";
9010
+ if (_this.controllerCallInFlight) {
9011
+ if (_this.debug) {
9012
+ console.log("[AdBreak] ad_error during request/play; outcome reported by the caller", errorPayload || "");
9013
+ }
9014
+ return;
9015
+ }
9016
+ var errorMessage = "Ad error (no details)";
9009
9017
  if (errorPayload) {
9010
9018
  var errorCode = errorPayload.code || errorPayload.errorCode || "unknown";
9011
9019
  var vastErrorCode = errorPayload.vastErrorCode;
@@ -9021,9 +9029,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9021
9029
  }
9022
9030
  }
9023
9031
  console.error("[AD-ERROR]", errorMessage, errorPayload || "");
9024
- if (_this.controllerCallInFlight) {
9025
- return;
9026
- }
9027
9032
  _this.handleAdFailure("ad_error");
9028
9033
  });
9029
9034
  adPlayer.on("content_pause", function() {
@@ -9174,7 +9179,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9174
9179
  key: "handleAdStart",
9175
9180
  value: function handleAdStart(marker) {
9176
9181
  return _async_to_generator(function() {
9177
- var baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, epoch, podPlayed;
9182
+ var baseVastUrl, adBreakDurationMs, currentMuted, currentVolume, epoch, hasPrefetchedUrl, mode, podPlayed;
9178
9183
  return _ts_generator(this, function(_state) {
9179
9184
  switch(_state.label){
9180
9185
  case 0:
@@ -9196,10 +9201,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9196
9201
  ];
9197
9202
  }
9198
9203
  adBreakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : this.timing.expectedAdBreakDurationMs;
9199
- if (this.debug) {
9200
- mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
9201
- console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
9202
- }
9203
9204
  this.timing.failedVastUrls.clear();
9204
9205
  this.timing.temporaryFailureUrls.clear();
9205
9206
  this.timing.consecutiveFailures = 0;
@@ -9228,11 +9229,31 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9228
9229
  }
9229
9230
  this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
9230
9231
  epoch = this.timing.adBreakEpoch;
9232
+ hasPrefetchedUrl = !!(this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0);
9233
+ if (!(adBreakDurationMs == null && !hasPrefetchedUrl)) return [
9234
+ 3,
9235
+ 2
9236
+ ];
9231
9237
  return [
9232
9238
  4,
9233
- this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
9239
+ this.waitForBreakDuration(this.breakDurationWaitMs)
9234
9240
  ];
9235
9241
  case 1:
9242
+ adBreakDurationMs = _state.sent();
9243
+ if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) return [
9244
+ 2
9245
+ ];
9246
+ _state.label = 2;
9247
+ case 2:
9248
+ if (this.debug) {
9249
+ mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
9250
+ console.log("[AdBreak] ".concat(mode, " break start: target duration=").concat(adBreakDurationMs != null ? "".concat(adBreakDurationMs, "ms") : "unknown"));
9251
+ }
9252
+ return [
9253
+ 4,
9254
+ this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
9255
+ ];
9256
+ case 3:
9236
9257
  podPlayed = _state.sent();
9237
9258
  if (!podPlayed && this.inAdBreak && epoch === this.timing.adBreakEpoch) {
9238
9259
  this.setSlotState("NEEDS_NEXT_AD", "initial_request_failed");
@@ -9246,6 +9267,53 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9246
9267
  }).call(this);
9247
9268
  }
9248
9269
  },
9270
+ {
9271
+ key: "waitForBreakDuration",
9272
+ value: function waitForBreakDuration(maxWaitMs) {
9273
+ return _async_to_generator(function() {
9274
+ var deadline, durationMs;
9275
+ return _ts_generator(this, function(_state) {
9276
+ switch(_state.label){
9277
+ case 0:
9278
+ deadline = Date.now() + maxWaitMs;
9279
+ _state.label = 1;
9280
+ case 1:
9281
+ if (!(this.timing.expectedAdBreakDurationMs == null && Date.now() < deadline)) return [
9282
+ 3,
9283
+ 3
9284
+ ];
9285
+ return [
9286
+ 4,
9287
+ new Promise(function(resolve) {
9288
+ return setTimeout(resolve, 50);
9289
+ })
9290
+ ];
9291
+ case 2:
9292
+ _state.sent();
9293
+ if (!this.inAdBreak) return [
9294
+ 3,
9295
+ 3
9296
+ ];
9297
+ return [
9298
+ 3,
9299
+ 1
9300
+ ];
9301
+ case 3:
9302
+ durationMs = this.timing.expectedAdBreakDurationMs;
9303
+ this.logOrchestratorFunnel("break_duration_wait", {
9304
+ waitedForMs: maxWaitMs - Math.max(0, deadline - Date.now()),
9305
+ durationMs: durationMs,
9306
+ resolved: durationMs != null
9307
+ });
9308
+ return [
9309
+ 2,
9310
+ durationMs
9311
+ ];
9312
+ }
9313
+ });
9314
+ }).call(this);
9315
+ }
9316
+ },
9249
9317
  {
9250
9318
  key: "startOptimizedPod",
9251
9319
  value: // ───────────────────────────────────────────────────────────────
@@ -9432,7 +9500,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9432
9500
  key: "getMaxNoFillsPerBreak",
9433
9501
  value: function getMaxNoFillsPerBreak() {
9434
9502
  var configured = this.host.config.maxNoFillsPerBreak;
9435
- return typeof configured === "number" && configured > 0 ? configured : this.defaultMaxNoFillsPerBreak;
9503
+ if (typeof configured === "number" && configured > 0) return configured;
9504
+ return this.breakSource === "scte35" ? this.defaultLiveMaxNoFillsPerBreak : this.defaultMaxNoFillsPerBreak;
9436
9505
  }
9437
9506
  },
9438
9507
  {
@@ -9628,6 +9697,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9628
9697
  } catch (unused) {}
9629
9698
  var adType = (_ref = params === null || params === void 0 ? void 0 : params.get("ad_type")) !== null && _ref !== void 0 ? _ref : void 0;
9630
9699
  this.logOrchestratorFunnel("vast_url_generated", {
9700
+ requestId: void 0,
9631
9701
  source: source,
9632
9702
  pod: (_ref1 = params === null || params === void 0 ? void 0 : params.get("pod")) !== null && _ref1 !== void 0 ? _ref1 : void 0,
9633
9703
  pmad: (_ref2 = params === null || params === void 0 ? void 0 : params.get("pmad")) !== null && _ref2 !== void 0 ? _ref2 : void 0,
@@ -10162,6 +10232,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10162
10232
  key: "handleAdPodComplete",
10163
10233
  value: function handleAdPodComplete() {
10164
10234
  var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "unspecified";
10235
+ var _this_breakFunnel_play_called, _this_breakFunnel_impression_fired;
10165
10236
  if (this.debug) {
10166
10237
  console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up", {
10167
10238
  reason: reason
@@ -10186,6 +10257,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10186
10257
  }
10187
10258
  this.finalizeRequestDiagnostics(this.currentRequestId, "break_ended:".concat(reason));
10188
10259
  this.currentRequestId = void 0;
10260
+ 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;
10189
10261
  this.timing.resetForBreakEnd();
10190
10262
  this.placeholder.hide();
10191
10263
  this.clearPendingAdBreak();
@@ -10224,6 +10296,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10224
10296
  this.monitorLiveResumeStall(this.host.video.currentTime);
10225
10297
  return;
10226
10298
  }
10299
+ if (!contentWasInterrupted) {
10300
+ if (this.debug) {
10301
+ console.log("[StormcloudVideoPlayer] Live break end \u2014 no ad was shown, leaving playback position unchanged");
10302
+ }
10303
+ this.resumeContentPlayback();
10304
+ return;
10305
+ }
10227
10306
  var liveSyncPos = this.host.getLiveSyncPosition();
10228
10307
  if (liveSyncPos != null && liveSyncPos > this.host.video.currentTime) {
10229
10308
  if (this.debug) {
@@ -11472,7 +11551,7 @@ var CRITICAL_PROPS = [
11472
11551
  var CONTROLS_HIDE_DELAY = 3e3;
11473
11552
  var DEFAULT_PLAYER_ASPECT_RATIO = 16 / 9;
11474
11553
  var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
11475
- var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, isLiveStream = props.isLiveStream, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, vastMode = props.vastMode, vastTagUrl = props.vastTagUrl, isVmap = props.isVmap, vmapUrl = props.vmapUrl, minSegmentsBeforePlay = props.minSegmentsBeforePlay, ctvAdRequest = props.ctvAdRequest, programTitle = props.programTitle, channelName = props.channelName, restVideoAttrs = _object_without_properties(props, [
11554
+ var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, isLiveStream = props.isLiveStream, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, vastMode = props.vastMode, vastTagUrl = props.vastTagUrl, isVmap = props.isVmap, vmapUrl = props.vmapUrl, minSegmentsBeforePlay = props.minSegmentsBeforePlay, ctvAdRequest = props.ctvAdRequest, programTitle = props.programTitle, channelName = props.channelName, minRemainingMsToStartAd = props.minRemainingMsToStartAd, minRemainingMsToRequestAd = props.minRemainingMsToRequestAd, maxNoFillsPerBreak = props.maxNoFillsPerBreak, restVideoAttrs = _object_without_properties(props, [
11476
11555
  "src",
11477
11556
  "autoplay",
11478
11557
  "muted",
@@ -11505,7 +11584,10 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
11505
11584
  "minSegmentsBeforePlay",
11506
11585
  "ctvAdRequest",
11507
11586
  "programTitle",
11508
- "channelName"
11587
+ "channelName",
11588
+ "minRemainingMsToStartAd",
11589
+ "minRemainingMsToRequestAd",
11590
+ "maxNoFillsPerBreak"
11509
11591
  ]);
11510
11592
  var videoRef = (0, import_react.useRef)(null);
11511
11593
  var playerRef = (0, import_react.useRef)(null);
@@ -11698,6 +11780,9 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
11698
11780
  if (ctvAdRequest !== void 0) cfg.ctvAdRequest = ctvAdRequest;
11699
11781
  if (programTitle !== void 0) cfg.programTitle = programTitle;
11700
11782
  if (channelName !== void 0) cfg.channelName = channelName;
11783
+ if (minRemainingMsToStartAd !== void 0) cfg.minRemainingMsToStartAd = minRemainingMsToStartAd;
11784
+ if (minRemainingMsToRequestAd !== void 0) cfg.minRemainingMsToRequestAd = minRemainingMsToRequestAd;
11785
+ if (maxNoFillsPerBreak !== void 0) cfg.maxNoFillsPerBreak = maxNoFillsPerBreak;
11701
11786
  var player = new StormcloudVideoPlayer(cfg);
11702
11787
  playerRef.current = player;
11703
11788
  player.load().then(function() {