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.
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'react';
2
- import { S as StormcloudVideoPlayerConfig } from '../types-DrBGHN4q.cjs';
2
+ import { S as StormcloudVideoPlayerConfig } from '../types-CIHDHY7A.cjs';
3
3
 
4
4
  interface HlsPlayerProps extends StormcloudVideoPlayerConfig {
5
5
  onMount?: (player: any) => void;
@@ -620,7 +620,7 @@ function isSupportedFormat(url, mimeType) {
620
620
  return false;
621
621
  }
622
622
  function createAdStormPlayer(contentVideo, options) {
623
- var licenseKey = options.licenseKey, _options_debug = options.debug, debug = _options_debug === void 0 ? false : _options_debug;
623
+ var licenseKey = options.licenseKey, _options_debug = options.debug, debug = _options_debug === void 0 ? false : _options_debug, channelId = options.channelId;
624
624
  var adPlaying = false;
625
625
  var originalMutedState = false;
626
626
  var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
@@ -826,8 +826,13 @@ function createAdStormPlayer(contentVideo, options) {
826
826
  adVideoElement.load();
827
827
  }
828
828
  function buildVastUrl(durationSeconds) {
829
- var baseUrl = "https://adstorm.co/api-adstorm-dev/adstorm/nab/vast/pod";
830
- return "".concat(baseUrl, "?duration=").concat(Math.ceil(durationSeconds));
829
+ var baseUrl = "https://adstorm.co/api/adstorm/nab/vast/pod";
830
+ var params = new URLSearchParams();
831
+ if (channelId != null) {
832
+ params.set("channel_id", String(channelId));
833
+ }
834
+ params.set("duration", String(Math.ceil(durationSeconds)));
835
+ return "".concat(baseUrl, "?").concat(params.toString());
831
836
  }
832
837
  function parseVastXml(xmlString) {
833
838
  var ads = [];
@@ -2825,10 +2830,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2825
2830
  logBrowserInfo(config.debugAdTiming);
2826
2831
  var browserForAdLayer = detectBrowser();
2827
2832
  var isSinglePipeline = browserForAdLayer.isSmartTV || !!this.config.singlePipelineMode;
2828
- this.adLayer = createAdStormPlayer(this.video, {
2833
+ this.adLayer = createAdStormPlayer(this.video, _object_spread({
2829
2834
  licenseKey: this.config.licenseKey || "",
2830
2835
  debug: !!config.debugAdTiming
2831
- });
2836
+ }, this.config.channelId != null && {
2837
+ channelId: this.config.channelId
2838
+ }));
2832
2839
  this.adLayer.updateOptions({
2833
2840
  continueLiveStreamDuringAds: !isSinglePipeline && this.shouldContinueLiveStreamDuringAds()
2834
2841
  });
@@ -3080,31 +3087,34 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3080
3087
  this.hls.on(import_hls.default.Events.FRAG_CHANGED, function(_evt, data) {
3081
3088
  var frag = data === null || data === void 0 ? void 0 : data.frag;
3082
3089
  if (!frag) return;
3083
- if (_this.lastAdInsertionPoint && !_this.inAdBreak && !_this.pendingAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
3090
+ if (_this.lastAdInsertionPoint && !_this.inAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
3084
3091
  var segmentName = _this.lastAdInsertionPoint.segment_ts_name;
3085
3092
  if (_this.fragmentMatchesSegment(frag, segmentName)) {
3086
- var _ref;
3093
+ var _ref, _ref1;
3094
+ var _this_pendingAdBreak;
3087
3095
  _this.processedAdInsertionUpdatedAt = _this.lastAdInsertionPoint.updated_at;
3088
3096
  var offsetMs = (_this.lastAdInsertionPoint.offset_seconds || 0) * 1e3;
3097
+ var durationSeconds = (_ref = (_this_pendingAdBreak = _this.pendingAdBreak) === null || _this_pendingAdBreak === void 0 ? void 0 : _this_pendingAdBreak.durationSeconds) !== null && _ref !== void 0 ? _ref : 60;
3098
+ var withPrefetch = _this.pendingAdBreak != null;
3089
3099
  _this.pushAdInsertionDebug("segment_playing", segmentName, {
3090
3100
  offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
3091
- detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
3101
+ detail: "sn=".concat((_ref1 = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref1 !== void 0 ? _ref1 : "?").concat(withPrefetch ? " (prefetch active)" : "")
3092
3102
  });
3093
3103
  if (_this.config.debugAdTiming) {
3094
- console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" now playing — scheduling ad start in ').concat(offsetMs, "ms"));
3104
+ 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)" : ""));
3095
3105
  }
3096
3106
  _this.pushAdInsertionDebug("ad_scheduled", segmentName, {
3097
3107
  offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
3098
- detail: "in ".concat(offsetMs, "ms, dur=60s")
3108
+ detail: "in ".concat(offsetMs, "ms, dur=").concat(durationSeconds, "s").concat(withPrefetch ? " (with prefetch)" : "")
3099
3109
  });
3100
3110
  _this.clearAdInsertionOffsetTimer();
3101
3111
  _this.adInsertionOffsetTimerId = window.setTimeout(function() {
3102
3112
  _this.adInsertionOffsetTimerId = void 0;
3103
3113
  if (_this.inAdBreak) return;
3104
3114
  _this.pushAdInsertionDebug("ad_triggered", segmentName, {
3105
- detail: "ad break started (60s)"
3115
+ detail: "ad break started (".concat(durationSeconds, "s").concat(withPrefetch ? ", with prefetch" : "", ")")
3106
3116
  });
3107
- void _this.handleAdStart(60);
3117
+ void _this.handleAdStart(durationSeconds);
3108
3118
  }, offsetMs);
3109
3119
  }
3110
3120
  }
@@ -3972,7 +3982,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3972
3982
  this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
3973
3983
  offsetSeconds: data.offset_seconds,
3974
3984
  updatedAt: data.updated_at,
3975
- detail: "ch=".concat(data.channel_id, " id=").concat(data.id)
3985
+ detail: "ch=".concat(data.channel_id)
3976
3986
  });
3977
3987
  if (segmentChanged && (this.pendingAdBreak || this.adInsertionOffsetTimerId != null)) {
3978
3988
  this.clearAdInsertionOffsetTimer();