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.d.cts CHANGED
@@ -36,6 +36,7 @@ interface StormcloudVideoPlayerConfig {
36
36
  adTransitionGapMs?: number;
37
37
  singlePipelineMode?: boolean;
38
38
  projectId?: string;
39
+ channelId?: number;
39
40
  }
40
41
  interface AdController {
41
42
  initialize: () => void;
@@ -4111,6 +4112,7 @@ declare function supportsFeature(feature: string): boolean;
4111
4112
  interface AdStormPlayerOptions {
4112
4113
  licenseKey: string;
4113
4114
  debug?: boolean;
4115
+ channelId?: number;
4114
4116
  }
4115
4117
  interface AdStormLayerOptionsUpdate {
4116
4118
  continueLiveStreamDuringAds?: boolean;
package/lib/index.d.ts CHANGED
@@ -36,6 +36,7 @@ interface StormcloudVideoPlayerConfig {
36
36
  adTransitionGapMs?: number;
37
37
  singlePipelineMode?: boolean;
38
38
  projectId?: string;
39
+ channelId?: number;
39
40
  }
40
41
  interface AdController {
41
42
  initialize: () => void;
@@ -4111,6 +4112,7 @@ declare function supportsFeature(feature: string): boolean;
4111
4112
  interface AdStormPlayerOptions {
4112
4113
  licenseKey: string;
4113
4114
  debug?: boolean;
4115
+ channelId?: number;
4114
4116
  }
4115
4117
  interface AdStormLayerOptionsUpdate {
4116
4118
  continueLiveStreamDuringAds?: boolean;
package/lib/index.js CHANGED
@@ -554,7 +554,7 @@ function isSupportedFormat(url, mimeType) {
554
554
  return false;
555
555
  }
556
556
  function createAdStormPlayer(contentVideo, options) {
557
- var licenseKey = options.licenseKey, _options_debug = options.debug, debug = _options_debug === void 0 ? false : _options_debug;
557
+ var licenseKey = options.licenseKey, _options_debug = options.debug, debug = _options_debug === void 0 ? false : _options_debug, channelId = options.channelId;
558
558
  var adPlaying = false;
559
559
  var originalMutedState = false;
560
560
  var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
@@ -760,8 +760,13 @@ function createAdStormPlayer(contentVideo, options) {
760
760
  adVideoElement.load();
761
761
  }
762
762
  function buildVastUrl(durationSeconds) {
763
- var baseUrl = "https://adstorm.co/api-adstorm-dev/adstorm/nab/vast/pod";
764
- return "".concat(baseUrl, "?duration=").concat(Math.ceil(durationSeconds));
763
+ var baseUrl = "https://adstorm.co/api/adstorm/nab/vast/pod";
764
+ var params = new URLSearchParams();
765
+ if (channelId != null) {
766
+ params.set("channel_id", String(channelId));
767
+ }
768
+ params.set("duration", String(Math.ceil(durationSeconds)));
769
+ return "".concat(baseUrl, "?").concat(params.toString());
765
770
  }
766
771
  function parseVastXml(xmlString) {
767
772
  var ads = [];
@@ -2787,10 +2792,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2787
2792
  logBrowserInfo(config.debugAdTiming);
2788
2793
  var browserForAdLayer = detectBrowser();
2789
2794
  var isSinglePipeline = browserForAdLayer.isSmartTV || !!this.config.singlePipelineMode;
2790
- this.adLayer = createAdStormPlayer(this.video, {
2795
+ this.adLayer = createAdStormPlayer(this.video, _object_spread({
2791
2796
  licenseKey: this.config.licenseKey || "",
2792
2797
  debug: !!config.debugAdTiming
2793
- });
2798
+ }, this.config.channelId != null && {
2799
+ channelId: this.config.channelId
2800
+ }));
2794
2801
  this.adLayer.updateOptions({
2795
2802
  continueLiveStreamDuringAds: !isSinglePipeline && this.shouldContinueLiveStreamDuringAds()
2796
2803
  });
@@ -3042,31 +3049,34 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3042
3049
  this.hls.on(Hls.Events.FRAG_CHANGED, function(_evt, data) {
3043
3050
  var frag = data === null || data === void 0 ? void 0 : data.frag;
3044
3051
  if (!frag) return;
3045
- if (_this.lastAdInsertionPoint && !_this.inAdBreak && !_this.pendingAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
3052
+ if (_this.lastAdInsertionPoint && !_this.inAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
3046
3053
  var segmentName = _this.lastAdInsertionPoint.segment_ts_name;
3047
3054
  if (_this.fragmentMatchesSegment(frag, segmentName)) {
3048
- var _ref;
3055
+ var _ref, _ref1;
3056
+ var _this_pendingAdBreak;
3049
3057
  _this.processedAdInsertionUpdatedAt = _this.lastAdInsertionPoint.updated_at;
3050
3058
  var offsetMs = (_this.lastAdInsertionPoint.offset_seconds || 0) * 1e3;
3059
+ var durationSeconds = (_ref = (_this_pendingAdBreak = _this.pendingAdBreak) === null || _this_pendingAdBreak === void 0 ? void 0 : _this_pendingAdBreak.durationSeconds) !== null && _ref !== void 0 ? _ref : 60;
3060
+ var withPrefetch = _this.pendingAdBreak != null;
3051
3061
  _this.pushAdInsertionDebug("segment_playing", segmentName, {
3052
3062
  offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
3053
- detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
3063
+ detail: "sn=".concat((_ref1 = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref1 !== void 0 ? _ref1 : "?").concat(withPrefetch ? " (prefetch active)" : "")
3054
3064
  });
3055
3065
  if (_this.config.debugAdTiming) {
3056
- console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" now playing — scheduling ad start in ').concat(offsetMs, "ms"));
3066
+ 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
3067
  }
3058
3068
  _this.pushAdInsertionDebug("ad_scheduled", segmentName, {
3059
3069
  offsetSeconds: _this.lastAdInsertionPoint.offset_seconds,
3060
- detail: "in ".concat(offsetMs, "ms, dur=60s")
3070
+ detail: "in ".concat(offsetMs, "ms, dur=").concat(durationSeconds, "s").concat(withPrefetch ? " (with prefetch)" : "")
3061
3071
  });
3062
3072
  _this.clearAdInsertionOffsetTimer();
3063
3073
  _this.adInsertionOffsetTimerId = window.setTimeout(function() {
3064
3074
  _this.adInsertionOffsetTimerId = void 0;
3065
3075
  if (_this.inAdBreak) return;
3066
3076
  _this.pushAdInsertionDebug("ad_triggered", segmentName, {
3067
- detail: "ad break started (60s)"
3077
+ detail: "ad break started (".concat(durationSeconds, "s").concat(withPrefetch ? ", with prefetch" : "", ")")
3068
3078
  });
3069
- void _this.handleAdStart(60);
3079
+ void _this.handleAdStart(durationSeconds);
3070
3080
  }, offsetMs);
3071
3081
  }
3072
3082
  }
@@ -3934,7 +3944,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3934
3944
  this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
3935
3945
  offsetSeconds: data.offset_seconds,
3936
3946
  updatedAt: data.updated_at,
3937
- detail: "ch=".concat(data.channel_id, " id=").concat(data.id)
3947
+ detail: "ch=".concat(data.channel_id)
3938
3948
  });
3939
3949
  if (segmentChanged && (this.pendingAdBreak || this.adInsertionOffsetTimerId != null)) {
3940
3950
  this.clearAdInsertionOffsetTimer();
@@ -7578,8 +7588,10 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7578
7588
  if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
7579
7589
  if (disableAds !== void 0) cfg.disableAds = disableAds;
7580
7590
  cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
7581
- if (adcisionChannelId !== void 0) cfg.projectId = String(adcisionChannelId);
7582
- else if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7591
+ if (adcisionChannelId !== void 0) {
7592
+ cfg.projectId = String(adcisionChannelId);
7593
+ cfg.channelId = adcisionChannelId;
7594
+ } else if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7583
7595
  var player = new StormcloudVideoPlayer(cfg);
7584
7596
  playerRef.current = player;
7585
7597
  player.load().then(function() {