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.
@@ -1030,6 +1030,7 @@ function createVastAdLayer(contentVideo, options) {
1030
1030
  var tornDown = false;
1031
1031
  var trackingFired = createEmptyTrackingState();
1032
1032
  var adStallTimerId;
1033
+ var savedContentVideoStyles;
1033
1034
  var currentAdEventHandlers;
1034
1035
  var preloadSlots = /* @__PURE__ */ new Map();
1035
1036
  function emit(event, payload) {
@@ -1103,6 +1104,14 @@ function createVastAdLayer(contentVideo, options) {
1103
1104
  } else if (debug) {
1104
1105
  console.warn("".concat(LOG, " forceMP4Ads: no MP4 files available, falling back to all media files"));
1105
1106
  }
1107
+ } else {
1108
+ var mp4Only1 = candidates.filter(function(f) {
1109
+ return !isHlsMediaFile(f);
1110
+ });
1111
+ if (mp4Only1.length > 0) {
1112
+ candidates = mp4Only1;
1113
+ if (debug) console.log("".concat(LOG, " Preferring ").concat(mp4Only1.length, " MP4 file(s) over HLS (mp4-first)"));
1114
+ }
1106
1115
  }
1107
1116
  var firstFile = candidates[0];
1108
1117
  if (candidates.length === 1) return firstFile;
@@ -1138,7 +1147,7 @@ function createVastAdLayer(contentVideo, options) {
1138
1147
  video.style.top = "0";
1139
1148
  video.style.width = "100%";
1140
1149
  video.style.height = "100%";
1141
- video.style.objectFit = "contain";
1150
+ video.style.objectFit = "cover";
1142
1151
  video.style.backgroundColor = "#000";
1143
1152
  video.playsInline = true;
1144
1153
  video.muted = false;
@@ -1253,12 +1262,31 @@ function createVastAdLayer(contentVideo, options) {
1253
1262
  delete contentVideo.dataset.stormcloudAdPlaying;
1254
1263
  }
1255
1264
  }
1265
+ function applyContentVideoAdCoverStyles() {
1266
+ if (!singleElementMode) return;
1267
+ savedContentVideoStyles = {
1268
+ objectFit: contentVideo.style.objectFit,
1269
+ width: contentVideo.style.width,
1270
+ height: contentVideo.style.height
1271
+ };
1272
+ contentVideo.style.objectFit = "cover";
1273
+ contentVideo.style.width = "100%";
1274
+ contentVideo.style.height = "100%";
1275
+ }
1276
+ function restoreContentVideoStyles() {
1277
+ if (!singleElementMode || !savedContentVideoStyles) return;
1278
+ contentVideo.style.objectFit = savedContentVideoStyles.objectFit;
1279
+ contentVideo.style.width = savedContentVideoStyles.width;
1280
+ contentVideo.style.height = savedContentVideoStyles.height;
1281
+ savedContentVideoStyles = void 0;
1282
+ }
1256
1283
  function handleAdComplete() {
1257
1284
  if (tornDown) return;
1258
1285
  clearAdStallTimer();
1259
1286
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1260
1287
  adPlaying = false;
1261
1288
  setAdPlayingFlag(false);
1289
+ restoreContentVideoStyles();
1262
1290
  if (adContainerEl) {
1263
1291
  adContainerEl.style.display = "none";
1264
1292
  adContainerEl.style.pointerEvents = "none";
@@ -1273,6 +1301,7 @@ function createVastAdLayer(contentVideo, options) {
1273
1301
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1274
1302
  adPlaying = false;
1275
1303
  setAdPlayingFlag(false);
1304
+ restoreContentVideoStyles();
1276
1305
  if (adContainerEl) {
1277
1306
  adContainerEl.style.display = "none";
1278
1307
  adContainerEl.style.pointerEvents = "none";
@@ -1443,6 +1472,7 @@ function createVastAdLayer(contentVideo, options) {
1443
1472
  ];
1444
1473
  contentVideo.style.visibility = "visible";
1445
1474
  contentVideo.style.opacity = "1";
1475
+ applyContentVideoAdCoverStyles();
1446
1476
  emit("content_pause");
1447
1477
  setupAdEventListeners();
1448
1478
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1681,6 +1711,7 @@ function createVastAdLayer(contentVideo, options) {
1681
1711
  ];
1682
1712
  contentVideo.style.visibility = "visible";
1683
1713
  contentVideo.style.opacity = "1";
1714
+ applyContentVideoAdCoverStyles();
1684
1715
  emit("content_pause");
1685
1716
  setupAdEventListeners();
1686
1717
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1831,6 +1862,7 @@ function createVastAdLayer(contentVideo, options) {
1831
1862
  if (debug) console.log("".concat(LOG, " Stopping ad"));
1832
1863
  adPlaying = false;
1833
1864
  setAdPlayingFlag(false);
1865
+ restoreContentVideoStyles();
1834
1866
  contentVideo.muted = originalMutedState;
1835
1867
  contentVideo.volume = originalMutedState ? 0 : originalVolume;
1836
1868
  contentVideo.style.visibility = "visible";
@@ -1869,6 +1901,7 @@ function createVastAdLayer(contentVideo, options) {
1869
1901
  destroyed = true;
1870
1902
  adPlaying = false;
1871
1903
  setAdPlayingFlag(false);
1904
+ restoreContentVideoStyles();
1872
1905
  contentVideo.muted = originalMutedState;
1873
1906
  contentVideo.volume = originalVolume;
1874
1907
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -4038,12 +4071,17 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4038
4071
  }
4039
4072
  }
4040
4073
  if (this.inAdBreak) {
4041
- if (this.expectedAdBreakDurationMs == null && marker.durationSeconds != null) {
4042
- this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
4043
- if (this.config.debugAdTiming) {
4044
- console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(this.expectedAdBreakDurationMs, "ms"));
4074
+ if (marker.durationSeconds != null) {
4075
+ var newDurationMs = marker.durationSeconds * 1e3;
4076
+ if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
4077
+ this.expectedAdBreakDurationMs = newDurationMs;
4078
+ var elapsedMs = this.currentAdBreakStartWallClockMs != null ? Date.now() - this.currentAdBreakStartWallClockMs : 0;
4079
+ var remainingMs = Math.max(0, newDurationMs - elapsedMs);
4080
+ this.scheduleAdStopCountdown(remainingMs);
4081
+ if (this.config.debugAdTiming) {
4082
+ console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(remainingMs, "ms"));
4083
+ }
4045
4084
  }
4046
- this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
4047
4085
  }
4048
4086
  return;
4049
4087
  }
@@ -4124,9 +4162,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4124
4162
  this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
4125
4163
  }
4126
4164
  if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
4127
- var elapsedMs = Date.now() - this.currentAdBreakStartWallClockMs;
4128
- var remainingMs = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs);
4129
- this.scheduleAdStopCountdown(remainingMs);
4165
+ var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
4166
+ var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
4167
+ this.scheduleAdStopCountdown(remainingMs1);
4130
4168
  }
4131
4169
  if (!this.adLayer.isAdPlaying() && this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0) {
4132
4170
  var bids = this.pendingNextAdBids;