stormcloud-video-player 0.6.4 → 0.6.6

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.
@@ -980,6 +980,7 @@ function createVastAdLayer(contentVideo, options) {
980
980
  var tornDown = false;
981
981
  var trackingFired = createEmptyTrackingState();
982
982
  var adStallTimerId;
983
+ var savedContentVideoStyles;
983
984
  var currentAdEventHandlers;
984
985
  var preloadSlots = /* @__PURE__ */ new Map();
985
986
  function emit(event, payload) {
@@ -1053,6 +1054,14 @@ function createVastAdLayer(contentVideo, options) {
1053
1054
  } else if (debug) {
1054
1055
  console.warn("".concat(LOG, " forceMP4Ads: no MP4 files available, falling back to all media files"));
1055
1056
  }
1057
+ } else {
1058
+ var mp4Only1 = candidates.filter(function(f) {
1059
+ return !isHlsMediaFile(f);
1060
+ });
1061
+ if (mp4Only1.length > 0) {
1062
+ candidates = mp4Only1;
1063
+ if (debug) console.log("".concat(LOG, " Preferring ").concat(mp4Only1.length, " MP4 file(s) over HLS (mp4-first)"));
1064
+ }
1056
1065
  }
1057
1066
  var firstFile = candidates[0];
1058
1067
  if (candidates.length === 1) return firstFile;
@@ -1088,7 +1097,7 @@ function createVastAdLayer(contentVideo, options) {
1088
1097
  video.style.top = "0";
1089
1098
  video.style.width = "100%";
1090
1099
  video.style.height = "100%";
1091
- video.style.objectFit = "contain";
1100
+ video.style.objectFit = "cover";
1092
1101
  video.style.backgroundColor = "#000";
1093
1102
  video.playsInline = true;
1094
1103
  video.muted = false;
@@ -1203,12 +1212,31 @@ function createVastAdLayer(contentVideo, options) {
1203
1212
  delete contentVideo.dataset.stormcloudAdPlaying;
1204
1213
  }
1205
1214
  }
1215
+ function applyContentVideoAdCoverStyles() {
1216
+ if (!singleElementMode) return;
1217
+ savedContentVideoStyles = {
1218
+ objectFit: contentVideo.style.objectFit,
1219
+ width: contentVideo.style.width,
1220
+ height: contentVideo.style.height
1221
+ };
1222
+ contentVideo.style.objectFit = "cover";
1223
+ contentVideo.style.width = "100%";
1224
+ contentVideo.style.height = "100%";
1225
+ }
1226
+ function restoreContentVideoStyles() {
1227
+ if (!singleElementMode || !savedContentVideoStyles) return;
1228
+ contentVideo.style.objectFit = savedContentVideoStyles.objectFit;
1229
+ contentVideo.style.width = savedContentVideoStyles.width;
1230
+ contentVideo.style.height = savedContentVideoStyles.height;
1231
+ savedContentVideoStyles = void 0;
1232
+ }
1206
1233
  function handleAdComplete() {
1207
1234
  if (tornDown) return;
1208
1235
  clearAdStallTimer();
1209
1236
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1210
1237
  adPlaying = false;
1211
1238
  setAdPlayingFlag(false);
1239
+ restoreContentVideoStyles();
1212
1240
  if (adContainerEl) {
1213
1241
  adContainerEl.style.display = "none";
1214
1242
  adContainerEl.style.pointerEvents = "none";
@@ -1223,6 +1251,7 @@ function createVastAdLayer(contentVideo, options) {
1223
1251
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1224
1252
  adPlaying = false;
1225
1253
  setAdPlayingFlag(false);
1254
+ restoreContentVideoStyles();
1226
1255
  if (adContainerEl) {
1227
1256
  adContainerEl.style.display = "none";
1228
1257
  adContainerEl.style.pointerEvents = "none";
@@ -1393,6 +1422,7 @@ function createVastAdLayer(contentVideo, options) {
1393
1422
  ];
1394
1423
  contentVideo.style.visibility = "visible";
1395
1424
  contentVideo.style.opacity = "1";
1425
+ applyContentVideoAdCoverStyles();
1396
1426
  emit("content_pause");
1397
1427
  setupAdEventListeners();
1398
1428
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1631,6 +1661,7 @@ function createVastAdLayer(contentVideo, options) {
1631
1661
  ];
1632
1662
  contentVideo.style.visibility = "visible";
1633
1663
  contentVideo.style.opacity = "1";
1664
+ applyContentVideoAdCoverStyles();
1634
1665
  emit("content_pause");
1635
1666
  setupAdEventListeners();
1636
1667
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1781,6 +1812,7 @@ function createVastAdLayer(contentVideo, options) {
1781
1812
  if (debug) console.log("".concat(LOG, " Stopping ad"));
1782
1813
  adPlaying = false;
1783
1814
  setAdPlayingFlag(false);
1815
+ restoreContentVideoStyles();
1784
1816
  contentVideo.muted = originalMutedState;
1785
1817
  contentVideo.volume = originalMutedState ? 0 : originalVolume;
1786
1818
  contentVideo.style.visibility = "visible";
@@ -1819,6 +1851,7 @@ function createVastAdLayer(contentVideo, options) {
1819
1851
  destroyed = true;
1820
1852
  adPlaying = false;
1821
1853
  setAdPlayingFlag(false);
1854
+ restoreContentVideoStyles();
1822
1855
  contentVideo.muted = originalMutedState;
1823
1856
  contentVideo.volume = originalVolume;
1824
1857
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -3988,12 +4021,17 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3988
4021
  }
3989
4022
  }
3990
4023
  if (this.inAdBreak) {
3991
- if (this.expectedAdBreakDurationMs == null && marker.durationSeconds != null) {
3992
- this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
3993
- if (this.config.debugAdTiming) {
3994
- console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(this.expectedAdBreakDurationMs, "ms"));
4024
+ if (marker.durationSeconds != null) {
4025
+ var newDurationMs = marker.durationSeconds * 1e3;
4026
+ if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
4027
+ this.expectedAdBreakDurationMs = newDurationMs;
4028
+ var elapsedMs = this.currentAdBreakStartWallClockMs != null ? Date.now() - this.currentAdBreakStartWallClockMs : 0;
4029
+ var remainingMs = Math.max(0, newDurationMs - elapsedMs);
4030
+ this.scheduleAdStopCountdown(remainingMs);
4031
+ if (this.config.debugAdTiming) {
4032
+ console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(remainingMs, "ms"));
4033
+ }
3995
4034
  }
3996
- this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
3997
4035
  }
3998
4036
  return;
3999
4037
  }
@@ -4074,9 +4112,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4074
4112
  this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
4075
4113
  }
4076
4114
  if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
4077
- var elapsedMs = Date.now() - this.currentAdBreakStartWallClockMs;
4078
- var remainingMs = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs);
4079
- this.scheduleAdStopCountdown(remainingMs);
4115
+ var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
4116
+ var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
4117
+ this.scheduleAdStopCountdown(remainingMs1);
4080
4118
  }
4081
4119
  if (!this.adLayer.isAdPlaying() && this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0) {
4082
4120
  var bids = this.pendingNextAdBids;