stormcloud-video-player 0.8.63 → 0.8.64

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.
@@ -84,6 +84,29 @@ function _object_spread(target) {
84
84
  }
85
85
  return target;
86
86
  }
87
+ function ownKeys(object, enumerableOnly) {
88
+ var keys = Object.keys(object);
89
+ if (Object.getOwnPropertySymbols) {
90
+ var symbols = Object.getOwnPropertySymbols(object);
91
+ if (enumerableOnly) {
92
+ symbols = symbols.filter(function(sym) {
93
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
94
+ });
95
+ }
96
+ keys.push.apply(keys, symbols);
97
+ }
98
+ return keys;
99
+ }
100
+ function _object_spread_props(target, source) {
101
+ source = source != null ? source : {};
102
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
103
+ else {
104
+ ownKeys(Object(source)).forEach(function(key) {
105
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
106
+ });
107
+ }
108
+ return target;
109
+ }
87
110
  function _to_consumable_array(arr) {
88
111
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
89
112
  }
@@ -1338,12 +1361,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1338
1361
  adPlayer.on("ad_interaction", function(event) {
1339
1362
  if (event) _this.host.onAdInteraction(event);
1340
1363
  });
1341
- adPlayer.on("all_ads_completed", function() {
1342
- sendAdImpressionTracking(_this.host.config.licenseKey, {
1364
+ adPlayer.on("ad_impression", function() {
1365
+ sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
1343
1366
  source: "hls",
1344
- adIndex: _this.timing.currentAdIndex,
1367
+ adIndex: _this.timing.currentAdIndex
1368
+ }, _this.currentVastUrl ? {
1369
+ adUrl: _this.currentVastUrl
1370
+ } : {}), {
1345
1371
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
1346
- }, _this.analyticsContext).catch(function() {});
1372
+ }), _this.analyticsContext).catch(function() {});
1373
+ });
1374
+ adPlayer.on("all_ads_completed", function() {
1347
1375
  _this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
1348
1376
  var remaining = _this.timing.getRemainingAdMs();
1349
1377
  _this.timing.consecutiveFailures = 0;
@@ -1401,11 +1429,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1401
1429
  }
1402
1430
  });
1403
1431
  adPlayer.on("content_resume", function() {
1404
- sendAdImpressionTracking(_this.host.config.licenseKey, {
1405
- source: "hls",
1406
- adIndex: _this.timing.currentAdIndex,
1407
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1408
- }, _this.analyticsContext).catch(function() {});
1409
1432
  if (!_this.host.video.muted) {
1410
1433
  _this.host.video.muted = true;
1411
1434
  if (_this.debug) {
@@ -1601,7 +1624,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1601
1624
  adPlayer = this.host.getAdPlayer();
1602
1625
  requestToken = ++this.timing.adRequestTokenCounter;
1603
1626
  this.timing.activeAdRequestToken = requestToken;
1604
- this.timing.startAdRequestWatchdog(requestToken);
1627
+ this.currentVastUrl = podUrl;
1605
1628
  _state.label = 1;
1606
1629
  case 1:
1607
1630
  _state.trys.push([
@@ -1616,6 +1639,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1616
1639
  ];
1617
1640
  case 2:
1618
1641
  _state.sent();
1642
+ this.timing.startAdRequestWatchdog(requestToken);
1619
1643
  this.timing.lastAdRequestTime = Date.now();
1620
1644
  return [
1621
1645
  4,
@@ -2104,13 +2128,33 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2104
2128
  }
2105
2129
  },
2106
2130
  {
2107
- key: "playSingleAd",
2108
- value: // ───────────────────────────────────────────────────────────────
2131
+ // ───────────────────────────────────────────────────────────────
2109
2132
  // Single ad playback
2110
2133
  // ───────────────────────────────────────────────────────────────
2111
- function playSingleAd(vastTagUrl) {
2134
+ key: "withCurrentPodBudget",
2135
+ value: function withCurrentPodBudget(vastTagUrl) {
2136
+ var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
2137
+ if (!(remaining > 0)) return vastTagUrl;
2138
+ try {
2139
+ var url = new URL(vastTagUrl);
2140
+ if (!url.searchParams.has("pmxd")) return vastTagUrl;
2141
+ var maxMs = Math.round(remaining);
2142
+ url.searchParams.set("pmxd", String(maxMs));
2143
+ var minMs = Number(url.searchParams.get("pmnd"));
2144
+ if (Number.isFinite(minMs) && minMs > maxMs) {
2145
+ url.searchParams.set("pmnd", String(maxMs));
2146
+ }
2147
+ return url.toString();
2148
+ } catch (unused) {
2149
+ return vastTagUrl;
2150
+ }
2151
+ }
2152
+ },
2153
+ {
2154
+ key: "playSingleAd",
2155
+ value: function playSingleAd(vastTagUrl) {
2112
2156
  return _async_to_generator(function() {
2113
- var adPlayer, requestToken, ap, playError, error, errorMessage;
2157
+ var adPlayer, requestToken, ap, requestUrl, playError, error, errorMessage;
2114
2158
  return _ts_generator(this, function(_state) {
2115
2159
  switch(_state.label){
2116
2160
  case 0:
@@ -2137,7 +2181,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2137
2181
  this.recreateAdController();
2138
2182
  requestToken = ++this.timing.adRequestTokenCounter;
2139
2183
  this.timing.activeAdRequestToken = requestToken;
2140
- this.timing.startAdRequestWatchdog(requestToken);
2141
2184
  _state.label = 1;
2142
2185
  case 1:
2143
2186
  _state.trys.push([
@@ -2152,17 +2195,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2152
2195
  ];
2153
2196
  case 2:
2154
2197
  _state.sent();
2198
+ this.timing.startAdRequestWatchdog(requestToken);
2155
2199
  this.timing.lastAdRequestTime = Date.now();
2156
2200
  ap = this.host.getAdPlayer();
2201
+ requestUrl = this.withCurrentPodBudget(vastTagUrl);
2202
+ this.currentVastUrl = requestUrl;
2157
2203
  return [
2158
2204
  4,
2159
- ap.requestAds(vastTagUrl)
2205
+ ap.requestAds(requestUrl)
2160
2206
  ];
2161
2207
  case 3:
2162
2208
  _state.sent();
2163
2209
  sendAdLoadedTracking(this.host.config.licenseKey, {
2164
2210
  source: "hls",
2165
- vastUrl: vastTagUrl,
2211
+ vastUrl: requestUrl,
2166
2212
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2167
2213
  }, this.analyticsContext).catch(function() {});
2168
2214
  this.timing.clearAdRequestWatchdog();