stormcloud-video-player 0.6.9 → 0.6.10

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
@@ -1119,6 +1119,7 @@ function createVastAdLayer(contentVideo, options) {
1119
1119
  var adHls;
1120
1120
  var adContainerEl;
1121
1121
  var currentAd;
1122
+ var currentMediaFile;
1122
1123
  var sessionId;
1123
1124
  var destroyed = false;
1124
1125
  var tornDown = false;
@@ -1365,7 +1366,12 @@ function createVastAdLayer(contentVideo, options) {
1365
1366
  adContainerEl.style.display = "none";
1366
1367
  adContainerEl.style.pointerEvents = "none";
1367
1368
  }
1368
- emit("ad_impression");
1369
+ emit("ad_impression", {
1370
+ adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
1371
+ adTitle: currentAd === null || currentAd === void 0 ? void 0 : currentAd.title,
1372
+ adUrl: currentMediaFile === null || currentMediaFile === void 0 ? void 0 : currentMediaFile.url,
1373
+ mediaType: currentMediaFile === null || currentMediaFile === void 0 ? void 0 : currentMediaFile.type
1374
+ });
1369
1375
  emit("content_resume");
1370
1376
  }
1371
1377
  function handleAdError() {
@@ -1387,6 +1393,7 @@ function createVastAdLayer(contentVideo, options) {
1387
1393
  adHls.destroy();
1388
1394
  adHls = void 0;
1389
1395
  }
1396
+ currentMediaFile = void 0;
1390
1397
  if (adVideoElement) {
1391
1398
  if (singleElementMode && adVideoElement === contentVideo) {
1392
1399
  contentVideo.pause();
@@ -1551,6 +1558,7 @@ function createVastAdLayer(contentVideo, options) {
1551
1558
  adVideoElement.volume = Math.max(0, Math.min(1, adVolume2));
1552
1559
  adVideoElement.muted = false;
1553
1560
  mediaFile2 = selectBestMediaFile(ad.mediaFiles);
1561
+ currentMediaFile = mediaFile2;
1554
1562
  if (debug) console.log("".concat(LOG, " Loading ad from: ").concat(mediaFile2.url));
1555
1563
  startPlayback(mediaFile2);
1556
1564
  return [
@@ -1597,6 +1605,7 @@ function createVastAdLayer(contentVideo, options) {
1597
1605
  }
1598
1606
  emit("content_pause");
1599
1607
  mediaFile = selectBestMediaFile(ad.mediaFiles);
1608
+ currentMediaFile = mediaFile;
1600
1609
  if (debug) console.log("".concat(LOG, " Loading ad from: ").concat(mediaFile.url));
1601
1610
  startPlayback(mediaFile);
1602
1611
  return [
@@ -1762,6 +1771,7 @@ function createVastAdLayer(contentVideo, options) {
1762
1771
  ];
1763
1772
  mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
1764
1773
  teardownCurrentPlayback();
1774
+ currentMediaFile = slot.mediaFile;
1765
1775
  adVideoElement = contentVideo;
1766
1776
  adHls = void 0;
1767
1777
  adPlaying = true;
@@ -1796,6 +1806,7 @@ function createVastAdLayer(contentVideo, options) {
1796
1806
  case 2:
1797
1807
  if (smartTVMode && !slot.videoEl) {
1798
1808
  teardownCurrentPlayback();
1809
+ currentMediaFile = slot.mediaFile;
1799
1810
  if (adVideoElement) {
1800
1811
  adVideoElement.remove();
1801
1812
  adVideoElement = void 0;
@@ -1827,6 +1838,7 @@ function createVastAdLayer(contentVideo, options) {
1827
1838
  ];
1828
1839
  }
1829
1840
  teardownCurrentPlayback();
1841
+ currentMediaFile = slot.mediaFile;
1830
1842
  if (adVideoElement && adVideoElement !== slot.videoEl) {
1831
1843
  adVideoElement.remove();
1832
1844
  }
@@ -1958,6 +1970,7 @@ function createVastAdLayer(contentVideo, options) {
1958
1970
  }
1959
1971
  }
1960
1972
  currentAd = void 0;
1973
+ currentMediaFile = void 0;
1961
1974
  tornDown = false;
1962
1975
  return [
1963
1976
  2
@@ -2010,6 +2023,7 @@ function createVastAdLayer(contentVideo, options) {
2010
2023
  }
2011
2024
  adContainerEl = void 0;
2012
2025
  currentAd = void 0;
2026
+ currentMediaFile = void 0;
2013
2027
  listeners.clear();
2014
2028
  },
2015
2029
  isAdPlaying: function isAdPlaying() {
@@ -3782,13 +3796,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3782
3796
  key: "attachAdLayerEventListeners",
3783
3797
  value: function attachAdLayerEventListeners() {
3784
3798
  var _this = this;
3785
- this.adLayer.on("ad_impression", function() {
3799
+ this.adLayer.on("ad_impression", function(payload) {
3786
3800
  if (_this.config.licenseKey) {
3801
+ var _ref;
3802
+ var adUrl = (_ref = payload === null || payload === void 0 ? void 0 : payload.adUrl) !== null && _ref !== void 0 ? _ref : _this.lastServedAdUrl;
3803
+ if (adUrl) {
3804
+ _this.lastServedAdUrl = adUrl;
3805
+ }
3787
3806
  sendAdImpressionTracking(_this.config.licenseKey, _object_spread_props(_object_spread({
3788
3807
  source: _this.getAdSource(),
3789
3808
  adIndex: _this.currentAdIndex
3790
- }, _this.lastServedAdUrl ? {
3791
- adUrl: _this.lastServedAdUrl
3809
+ }, adUrl ? {
3810
+ adUrl: adUrl
3792
3811
  } : {}), {
3793
3812
  timestamp: /* @__PURE__ */ new Date().toISOString()
3794
3813
  }), _this.getAnalyticsContext());