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.cjs CHANGED
@@ -3208,31 +3208,34 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3208
3208
  this.hls.on(import_hls.default.Events.FRAG_CHANGED, function(_evt, data) {
3209
3209
  var frag = data === null || data === void 0 ? void 0 : data.frag;
3210
3210
  if (!frag) return;
3211
- if (_this.lastAdInsertionPoint && !_this.inAdBreak && !_this.pendingAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
3211
+ if (_this.lastAdInsertionPoint && !_this.inAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
3212
3212
  var segmentName = _this.lastAdInsertionPoint.segment_ts_name;
3213
3213
  if (_this.fragmentMatchesSegment(frag, segmentName)) {
3214
- var _ref;
3214
+ var _ref, _ref1;
3215
+ var _this_pendingAdBreak;
3215
3216
  _this.processedAdInsertionUpdatedAt = _this.lastAdInsertionPoint.updated_at;
3216
3217
  var offsetMs = (_this.lastAdInsertionPoint.offset_seconds || 0) * 1e3;
3218
+ var durationSeconds = (_ref = (_this_pendingAdBreak = _this.pendingAdBreak) === null || _this_pendingAdBreak === void 0 ? void 0 : _this_pendingAdBreak.durationSeconds) !== null && _ref !== void 0 ? _ref : 60;
3219
+ var withPrefetch = _this.pendingAdBreak != null;
3217
3220
  _this.pushAdInsertionDebug("segment_playing", segmentName, {
3218
3221
  offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
3219
- detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
3222
+ detail: "sn=".concat((_ref1 = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref1 !== void 0 ? _ref1 : "?").concat(withPrefetch ? " (prefetch active)" : "")
3220
3223
  });
3221
3224
  if (_this.config.debugAdTiming) {
3222
- console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" now playing — scheduling ad start in ').concat(offsetMs, "ms"));
3225
+ 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)" : ""));
3223
3226
  }
3224
3227
  _this.pushAdInsertionDebug("ad_scheduled", segmentName, {
3225
3228
  offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
3226
- detail: "in ".concat(offsetMs, "ms, dur=60s")
3229
+ detail: "in ".concat(offsetMs, "ms, dur=").concat(durationSeconds, "s").concat(withPrefetch ? " (with prefetch)" : "")
3227
3230
  });
3228
3231
  _this.clearAdInsertionOffsetTimer();
3229
3232
  _this.adInsertionOffsetTimerId = window.setTimeout(function() {
3230
3233
  _this.adInsertionOffsetTimerId = void 0;
3231
3234
  if (_this.inAdBreak) return;
3232
3235
  _this.pushAdInsertionDebug("ad_triggered", segmentName, {
3233
- detail: "ad break started (60s)"
3236
+ detail: "ad break started (".concat(durationSeconds, "s").concat(withPrefetch ? ", with prefetch" : "", ")")
3234
3237
  });
3235
- void _this.handleAdStart(60);
3238
+ void _this.handleAdStart(durationSeconds);
3236
3239
  }, offsetMs);
3237
3240
  }
3238
3241
  }
@@ -4100,7 +4103,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4100
4103
  this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
4101
4104
  offsetSeconds: data.offset_seconds,
4102
4105
  updatedAt: data.updated_at,
4103
- detail: "ch=".concat(data.channel_id, " id=").concat(data.id)
4106
+ detail: "ch=".concat(data.channel_id)
4104
4107
  });
4105
4108
  if (segmentChanged && (this.pendingAdBreak || this.adInsertionOffsetTimerId != null)) {
4106
4109
  this.clearAdInsertionOffsetTimer();
@@ -7744,7 +7747,8 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7744
7747
  if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
7745
7748
  if (disableAds !== void 0) cfg.disableAds = disableAds;
7746
7749
  cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
7747
- if (!adcisionChannelId && swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7750
+ if (adcisionChannelId !== void 0) cfg.projectId = String(adcisionChannelId);
7751
+ else if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7748
7752
  var player = new StormcloudVideoPlayer(cfg);
7749
7753
  playerRef.current = player;
7750
7754
  player.load().then(function() {