stormcloud-video-player 0.7.22 → 0.7.24

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/index.js CHANGED
@@ -3042,31 +3042,34 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3042
3042
  this.hls.on(Hls.Events.FRAG_CHANGED, function(_evt, data) {
3043
3043
  var frag = data === null || data === void 0 ? void 0 : data.frag;
3044
3044
  if (!frag) return;
3045
- if (_this.lastAdInsertionPoint && !_this.inAdBreak && !_this.pendingAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
3045
+ if (_this.lastAdInsertionPoint && !_this.inAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
3046
3046
  var segmentName = _this.lastAdInsertionPoint.segment_ts_name;
3047
3047
  if (_this.fragmentMatchesSegment(frag, segmentName)) {
3048
- var _ref;
3048
+ var _ref, _ref1;
3049
+ var _this_pendingAdBreak;
3049
3050
  _this.processedAdInsertionUpdatedAt = _this.lastAdInsertionPoint.updated_at;
3050
3051
  var offsetMs = (_this.lastAdInsertionPoint.offset_seconds || 0) * 1e3;
3052
+ var durationSeconds = (_ref = (_this_pendingAdBreak = _this.pendingAdBreak) === null || _this_pendingAdBreak === void 0 ? void 0 : _this_pendingAdBreak.durationSeconds) !== null && _ref !== void 0 ? _ref : 60;
3053
+ var withPrefetch = _this.pendingAdBreak != null;
3051
3054
  _this.pushAdInsertionDebug("segment_playing", segmentName, {
3052
3055
  offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
3053
- detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
3056
+ detail: "sn=".concat((_ref1 = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref1 !== void 0 ? _ref1 : "?").concat(withPrefetch ? " (prefetch active)" : "")
3054
3057
  });
3055
3058
  if (_this.config.debugAdTiming) {
3056
- console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" now playing — scheduling ad start in ').concat(offsetMs, "ms"));
3059
+ console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" now playing — scheduling ad start in ').concat(offsetMs, "ms") + (withPrefetch ? " (prefetch was active, preloaded tokens will be used)" : ""));
3057
3060
  }
3058
3061
  _this.pushAdInsertionDebug("ad_scheduled", segmentName, {
3059
3062
  offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
3060
- detail: "in ".concat(offsetMs, "ms, dur=60s")
3063
+ detail: "in ".concat(offsetMs, "ms, dur=").concat(durationSeconds, "s").concat(withPrefetch ? " (with prefetch)" : "")
3061
3064
  });
3062
3065
  _this.clearAdInsertionOffsetTimer();
3063
3066
  _this.adInsertionOffsetTimerId = window.setTimeout(function() {
3064
3067
  _this.adInsertionOffsetTimerId = void 0;
3065
3068
  if (_this.inAdBreak) return;
3066
3069
  _this.pushAdInsertionDebug("ad_triggered", segmentName, {
3067
- detail: "ad break started (60s)"
3070
+ detail: "ad break started (".concat(durationSeconds, "s").concat(withPrefetch ? ", with prefetch" : "", ")")
3068
3071
  });
3069
- void _this.handleAdStart(60);
3072
+ void _this.handleAdStart(durationSeconds);
3070
3073
  }, offsetMs);
3071
3074
  }
3072
3075
  }
@@ -3934,7 +3937,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3934
3937
  this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
3935
3938
  offsetSeconds: data.offset_seconds,
3936
3939
  updatedAt: data.updated_at,
3937
- detail: "ch=".concat(data.channel_id, " id=").concat(data.id)
3940
+ detail: "ch=".concat(data.channel_id)
3938
3941
  });
3939
3942
  if (segmentChanged && (this.pendingAdBreak || this.adInsertionOffsetTimerId != null)) {
3940
3943
  this.clearAdInsertionOffsetTimer();
@@ -7578,7 +7581,8 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7578
7581
  if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
7579
7582
  if (disableAds !== void 0) cfg.disableAds = disableAds;
7580
7583
  cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
7581
- if (!adcisionChannelId && swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7584
+ if (adcisionChannelId !== void 0) cfg.projectId = String(adcisionChannelId);
7585
+ else if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7582
7586
  var player = new StormcloudVideoPlayer(cfg);
7583
7587
  playerRef.current = player;
7584
7588
  player.load().then(function() {