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.js CHANGED
@@ -959,6 +959,7 @@ function createVastAdLayer(contentVideo, options) {
959
959
  var adHls;
960
960
  var adContainerEl;
961
961
  var currentAd;
962
+ var currentMediaFile;
962
963
  var sessionId;
963
964
  var destroyed = false;
964
965
  var tornDown = false;
@@ -1205,7 +1206,12 @@ function createVastAdLayer(contentVideo, options) {
1205
1206
  adContainerEl.style.display = "none";
1206
1207
  adContainerEl.style.pointerEvents = "none";
1207
1208
  }
1208
- emit("ad_impression");
1209
+ emit("ad_impression", {
1210
+ adId: currentAd === null || currentAd === void 0 ? void 0 : currentAd.id,
1211
+ adTitle: currentAd === null || currentAd === void 0 ? void 0 : currentAd.title,
1212
+ adUrl: currentMediaFile === null || currentMediaFile === void 0 ? void 0 : currentMediaFile.url,
1213
+ mediaType: currentMediaFile === null || currentMediaFile === void 0 ? void 0 : currentMediaFile.type
1214
+ });
1209
1215
  emit("content_resume");
1210
1216
  }
1211
1217
  function handleAdError() {
@@ -1227,6 +1233,7 @@ function createVastAdLayer(contentVideo, options) {
1227
1233
  adHls.destroy();
1228
1234
  adHls = void 0;
1229
1235
  }
1236
+ currentMediaFile = void 0;
1230
1237
  if (adVideoElement) {
1231
1238
  if (singleElementMode && adVideoElement === contentVideo) {
1232
1239
  contentVideo.pause();
@@ -1391,6 +1398,7 @@ function createVastAdLayer(contentVideo, options) {
1391
1398
  adVideoElement.volume = Math.max(0, Math.min(1, adVolume2));
1392
1399
  adVideoElement.muted = false;
1393
1400
  mediaFile2 = selectBestMediaFile(ad.mediaFiles);
1401
+ currentMediaFile = mediaFile2;
1394
1402
  if (debug) console.log("".concat(LOG, " Loading ad from: ").concat(mediaFile2.url));
1395
1403
  startPlayback(mediaFile2);
1396
1404
  return [
@@ -1437,6 +1445,7 @@ function createVastAdLayer(contentVideo, options) {
1437
1445
  }
1438
1446
  emit("content_pause");
1439
1447
  mediaFile = selectBestMediaFile(ad.mediaFiles);
1448
+ currentMediaFile = mediaFile;
1440
1449
  if (debug) console.log("".concat(LOG, " Loading ad from: ").concat(mediaFile.url));
1441
1450
  startPlayback(mediaFile);
1442
1451
  return [
@@ -1602,6 +1611,7 @@ function createVastAdLayer(contentVideo, options) {
1602
1611
  ];
1603
1612
  mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
1604
1613
  teardownCurrentPlayback();
1614
+ currentMediaFile = slot.mediaFile;
1605
1615
  adVideoElement = contentVideo;
1606
1616
  adHls = void 0;
1607
1617
  adPlaying = true;
@@ -1636,6 +1646,7 @@ function createVastAdLayer(contentVideo, options) {
1636
1646
  case 2:
1637
1647
  if (smartTVMode && !slot.videoEl) {
1638
1648
  teardownCurrentPlayback();
1649
+ currentMediaFile = slot.mediaFile;
1639
1650
  if (adVideoElement) {
1640
1651
  adVideoElement.remove();
1641
1652
  adVideoElement = void 0;
@@ -1667,6 +1678,7 @@ function createVastAdLayer(contentVideo, options) {
1667
1678
  ];
1668
1679
  }
1669
1680
  teardownCurrentPlayback();
1681
+ currentMediaFile = slot.mediaFile;
1670
1682
  if (adVideoElement && adVideoElement !== slot.videoEl) {
1671
1683
  adVideoElement.remove();
1672
1684
  }
@@ -1798,6 +1810,7 @@ function createVastAdLayer(contentVideo, options) {
1798
1810
  }
1799
1811
  }
1800
1812
  currentAd = void 0;
1813
+ currentMediaFile = void 0;
1801
1814
  tornDown = false;
1802
1815
  return [
1803
1816
  2
@@ -1850,6 +1863,7 @@ function createVastAdLayer(contentVideo, options) {
1850
1863
  }
1851
1864
  adContainerEl = void 0;
1852
1865
  currentAd = void 0;
1866
+ currentMediaFile = void 0;
1853
1867
  listeners.clear();
1854
1868
  },
1855
1869
  isAdPlaying: function isAdPlaying() {
@@ -3625,13 +3639,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3625
3639
  key: "attachAdLayerEventListeners",
3626
3640
  value: function attachAdLayerEventListeners() {
3627
3641
  var _this = this;
3628
- this.adLayer.on("ad_impression", function() {
3642
+ this.adLayer.on("ad_impression", function(payload) {
3629
3643
  if (_this.config.licenseKey) {
3644
+ var _ref;
3645
+ var adUrl = (_ref = payload === null || payload === void 0 ? void 0 : payload.adUrl) !== null && _ref !== void 0 ? _ref : _this.lastServedAdUrl;
3646
+ if (adUrl) {
3647
+ _this.lastServedAdUrl = adUrl;
3648
+ }
3630
3649
  sendAdImpressionTracking(_this.config.licenseKey, _object_spread_props(_object_spread({
3631
3650
  source: _this.getAdSource(),
3632
3651
  adIndex: _this.currentAdIndex
3633
- }, _this.lastServedAdUrl ? {
3634
- adUrl: _this.lastServedAdUrl
3652
+ }, adUrl ? {
3653
+ adUrl: adUrl
3635
3654
  } : {}), {
3636
3655
  timestamp: /* @__PURE__ */ new Date().toISOString()
3637
3656
  }), _this.getAnalyticsContext());