stormcloud-video-player 0.7.23 → 0.7.25

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
@@ -723,7 +723,7 @@ function isSupportedFormat(url, mimeType) {
723
723
  return false;
724
724
  }
725
725
  function createAdStormPlayer(contentVideo, options) {
726
- var licenseKey = options.licenseKey, _options_debug = options.debug, debug = _options_debug === void 0 ? false : _options_debug;
726
+ var licenseKey = options.licenseKey, _options_debug = options.debug, debug = _options_debug === void 0 ? false : _options_debug, channelId = options.channelId;
727
727
  var adPlaying = false;
728
728
  var originalMutedState = false;
729
729
  var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
@@ -929,8 +929,13 @@ function createAdStormPlayer(contentVideo, options) {
929
929
  adVideoElement.load();
930
930
  }
931
931
  function buildVastUrl(durationSeconds) {
932
- var baseUrl = "https://adstorm.co/api-adstorm-dev/adstorm/nab/vast/pod";
933
- return "".concat(baseUrl, "?duration=").concat(Math.ceil(durationSeconds));
932
+ var baseUrl = "https://adstorm.co/api/adstorm/nab/vast/pod";
933
+ var params = new URLSearchParams();
934
+ if (channelId != null) {
935
+ params.set("channel_id", String(channelId));
936
+ }
937
+ params.set("duration", String(Math.ceil(durationSeconds)));
938
+ return "".concat(baseUrl, "?").concat(params.toString());
934
939
  }
935
940
  function parseVastXml(xmlString) {
936
941
  var ads = [];
@@ -2953,10 +2958,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2953
2958
  logBrowserInfo(config.debugAdTiming);
2954
2959
  var browserForAdLayer = detectBrowser();
2955
2960
  var isSinglePipeline = browserForAdLayer.isSmartTV || !!this.config.singlePipelineMode;
2956
- this.adLayer = createAdStormPlayer(this.video, {
2961
+ this.adLayer = createAdStormPlayer(this.video, _object_spread({
2957
2962
  licenseKey: this.config.licenseKey || "",
2958
2963
  debug: !!config.debugAdTiming
2959
- });
2964
+ }, this.config.channelId != null && {
2965
+ channelId: this.config.channelId
2966
+ }));
2960
2967
  this.adLayer.updateOptions({
2961
2968
  continueLiveStreamDuringAds: !isSinglePipeline && this.shouldContinueLiveStreamDuringAds()
2962
2969
  });
@@ -3208,31 +3215,34 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3208
3215
  this.hls.on(import_hls.default.Events.FRAG_CHANGED, function(_evt, data) {
3209
3216
  var frag = data === null || data === void 0 ? void 0 : data.frag;
3210
3217
  if (!frag) return;
3211
- if (_this.lastAdInsertionPoint && !_this.inAdBreak && !_this.pendingAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
3218
+ if (_this.lastAdInsertionPoint && !_this.inAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
3212
3219
  var segmentName = _this.lastAdInsertionPoint.segment_ts_name;
3213
3220
  if (_this.fragmentMatchesSegment(frag, segmentName)) {
3214
- var _ref;
3221
+ var _ref, _ref1;
3222
+ var _this_pendingAdBreak;
3215
3223
  _this.processedAdInsertionUpdatedAt = _this.lastAdInsertionPoint.updated_at;
3216
3224
  var offsetMs = (_this.lastAdInsertionPoint.offset_seconds || 0) * 1e3;
3225
+ var durationSeconds = (_ref = (_this_pendingAdBreak = _this.pendingAdBreak) === null || _this_pendingAdBreak === void 0 ? void 0 : _this_pendingAdBreak.durationSeconds) !== null && _ref !== void 0 ? _ref : 60;
3226
+ var withPrefetch = _this.pendingAdBreak != null;
3217
3227
  _this.pushAdInsertionDebug("segment_playing", segmentName, {
3218
3228
  offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
3219
- detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
3229
+ detail: "sn=".concat((_ref1 = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref1 !== void 0 ? _ref1 : "?").concat(withPrefetch ? " (prefetch active)" : "")
3220
3230
  });
3221
3231
  if (_this.config.debugAdTiming) {
3222
- console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" now playing — scheduling ad start in ').concat(offsetMs, "ms"));
3232
+ 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
3233
  }
3224
3234
  _this.pushAdInsertionDebug("ad_scheduled", segmentName, {
3225
3235
  offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
3226
- detail: "in ".concat(offsetMs, "ms, dur=60s")
3236
+ detail: "in ".concat(offsetMs, "ms, dur=").concat(durationSeconds, "s").concat(withPrefetch ? " (with prefetch)" : "")
3227
3237
  });
3228
3238
  _this.clearAdInsertionOffsetTimer();
3229
3239
  _this.adInsertionOffsetTimerId = window.setTimeout(function() {
3230
3240
  _this.adInsertionOffsetTimerId = void 0;
3231
3241
  if (_this.inAdBreak) return;
3232
3242
  _this.pushAdInsertionDebug("ad_triggered", segmentName, {
3233
- detail: "ad break started (60s)"
3243
+ detail: "ad break started (".concat(durationSeconds, "s").concat(withPrefetch ? ", with prefetch" : "", ")")
3234
3244
  });
3235
- void _this.handleAdStart(60);
3245
+ void _this.handleAdStart(durationSeconds);
3236
3246
  }, offsetMs);
3237
3247
  }
3238
3248
  }
@@ -4100,7 +4110,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4100
4110
  this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
4101
4111
  offsetSeconds: data.offset_seconds,
4102
4112
  updatedAt: data.updated_at,
4103
- detail: "ch=".concat(data.channel_id, " id=").concat(data.id)
4113
+ detail: "ch=".concat(data.channel_id)
4104
4114
  });
4105
4115
  if (segmentChanged && (this.pendingAdBreak || this.adInsertionOffsetTimerId != null)) {
4106
4116
  this.clearAdInsertionOffsetTimer();
@@ -7744,8 +7754,10 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7744
7754
  if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
7745
7755
  if (disableAds !== void 0) cfg.disableAds = disableAds;
7746
7756
  cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
7747
- if (adcisionChannelId !== void 0) cfg.projectId = String(adcisionChannelId);
7748
- else if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7757
+ if (adcisionChannelId !== void 0) {
7758
+ cfg.projectId = String(adcisionChannelId);
7759
+ cfg.channelId = adcisionChannelId;
7760
+ } else if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7749
7761
  var player = new StormcloudVideoPlayer(cfg);
7750
7762
  playerRef.current = player;
7751
7763
  player.load().then(function() {