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.
package/lib/index.cjs CHANGED
@@ -1124,6 +1124,7 @@ function createVastAdLayer(contentVideo, options) {
1124
1124
  var tornDown = false;
1125
1125
  var trackingFired = createEmptyTrackingState();
1126
1126
  var adStallTimerId;
1127
+ var savedContentVideoStyles;
1127
1128
  var currentAdEventHandlers;
1128
1129
  var preloadSlots = /* @__PURE__ */ new Map();
1129
1130
  function emit(event, payload) {
@@ -1197,6 +1198,14 @@ function createVastAdLayer(contentVideo, options) {
1197
1198
  } else if (debug) {
1198
1199
  console.warn("".concat(LOG, " forceMP4Ads: no MP4 files available, falling back to all media files"));
1199
1200
  }
1201
+ } else {
1202
+ var mp4Only1 = candidates.filter(function(f) {
1203
+ return !isHlsMediaFile(f);
1204
+ });
1205
+ if (mp4Only1.length > 0) {
1206
+ candidates = mp4Only1;
1207
+ if (debug) console.log("".concat(LOG, " Preferring ").concat(mp4Only1.length, " MP4 file(s) over HLS (mp4-first)"));
1208
+ }
1200
1209
  }
1201
1210
  var firstFile = candidates[0];
1202
1211
  if (candidates.length === 1) return firstFile;
@@ -1232,7 +1241,7 @@ function createVastAdLayer(contentVideo, options) {
1232
1241
  video.style.top = "0";
1233
1242
  video.style.width = "100%";
1234
1243
  video.style.height = "100%";
1235
- video.style.objectFit = "contain";
1244
+ video.style.objectFit = "cover";
1236
1245
  video.style.backgroundColor = "#000";
1237
1246
  video.playsInline = true;
1238
1247
  video.muted = false;
@@ -1347,12 +1356,31 @@ function createVastAdLayer(contentVideo, options) {
1347
1356
  delete contentVideo.dataset.stormcloudAdPlaying;
1348
1357
  }
1349
1358
  }
1359
+ function applyContentVideoAdCoverStyles() {
1360
+ if (!singleElementMode) return;
1361
+ savedContentVideoStyles = {
1362
+ objectFit: contentVideo.style.objectFit,
1363
+ width: contentVideo.style.width,
1364
+ height: contentVideo.style.height
1365
+ };
1366
+ contentVideo.style.objectFit = "cover";
1367
+ contentVideo.style.width = "100%";
1368
+ contentVideo.style.height = "100%";
1369
+ }
1370
+ function restoreContentVideoStyles() {
1371
+ if (!singleElementMode || !savedContentVideoStyles) return;
1372
+ contentVideo.style.objectFit = savedContentVideoStyles.objectFit;
1373
+ contentVideo.style.width = savedContentVideoStyles.width;
1374
+ contentVideo.style.height = savedContentVideoStyles.height;
1375
+ savedContentVideoStyles = void 0;
1376
+ }
1350
1377
  function handleAdComplete() {
1351
1378
  if (tornDown) return;
1352
1379
  clearAdStallTimer();
1353
1380
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1354
1381
  adPlaying = false;
1355
1382
  setAdPlayingFlag(false);
1383
+ restoreContentVideoStyles();
1356
1384
  if (adContainerEl) {
1357
1385
  adContainerEl.style.display = "none";
1358
1386
  adContainerEl.style.pointerEvents = "none";
@@ -1367,6 +1395,7 @@ function createVastAdLayer(contentVideo, options) {
1367
1395
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1368
1396
  adPlaying = false;
1369
1397
  setAdPlayingFlag(false);
1398
+ restoreContentVideoStyles();
1370
1399
  if (adContainerEl) {
1371
1400
  adContainerEl.style.display = "none";
1372
1401
  adContainerEl.style.pointerEvents = "none";
@@ -1537,6 +1566,7 @@ function createVastAdLayer(contentVideo, options) {
1537
1566
  ];
1538
1567
  contentVideo.style.visibility = "visible";
1539
1568
  contentVideo.style.opacity = "1";
1569
+ applyContentVideoAdCoverStyles();
1540
1570
  emit("content_pause");
1541
1571
  setupAdEventListeners();
1542
1572
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1775,6 +1805,7 @@ function createVastAdLayer(contentVideo, options) {
1775
1805
  ];
1776
1806
  contentVideo.style.visibility = "visible";
1777
1807
  contentVideo.style.opacity = "1";
1808
+ applyContentVideoAdCoverStyles();
1778
1809
  emit("content_pause");
1779
1810
  setupAdEventListeners();
1780
1811
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1925,6 +1956,7 @@ function createVastAdLayer(contentVideo, options) {
1925
1956
  if (debug) console.log("".concat(LOG, " Stopping ad"));
1926
1957
  adPlaying = false;
1927
1958
  setAdPlayingFlag(false);
1959
+ restoreContentVideoStyles();
1928
1960
  contentVideo.muted = originalMutedState;
1929
1961
  contentVideo.volume = originalMutedState ? 0 : originalVolume;
1930
1962
  contentVideo.style.visibility = "visible";
@@ -1963,6 +1995,7 @@ function createVastAdLayer(contentVideo, options) {
1963
1995
  destroyed = true;
1964
1996
  adPlaying = false;
1965
1997
  setAdPlayingFlag(false);
1998
+ restoreContentVideoStyles();
1966
1999
  contentVideo.muted = originalMutedState;
1967
2000
  contentVideo.volume = originalVolume;
1968
2001
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -4157,12 +4190,17 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4157
4190
  }
4158
4191
  }
4159
4192
  if (this.inAdBreak) {
4160
- if (this.expectedAdBreakDurationMs == null && marker.durationSeconds != null) {
4161
- this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
4162
- if (this.config.debugAdTiming) {
4163
- console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(this.expectedAdBreakDurationMs, "ms"));
4193
+ if (marker.durationSeconds != null) {
4194
+ var newDurationMs = marker.durationSeconds * 1e3;
4195
+ if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
4196
+ this.expectedAdBreakDurationMs = newDurationMs;
4197
+ var elapsedMs = this.currentAdBreakStartWallClockMs != null ? Date.now() - this.currentAdBreakStartWallClockMs : 0;
4198
+ var remainingMs = Math.max(0, newDurationMs - elapsedMs);
4199
+ this.scheduleAdStopCountdown(remainingMs);
4200
+ if (this.config.debugAdTiming) {
4201
+ console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(remainingMs, "ms"));
4202
+ }
4164
4203
  }
4165
- this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
4166
4204
  }
4167
4205
  return;
4168
4206
  }
@@ -4243,9 +4281,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4243
4281
  this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
4244
4282
  }
4245
4283
  if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
4246
- var elapsedMs = Date.now() - this.currentAdBreakStartWallClockMs;
4247
- var remainingMs = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs);
4248
- this.scheduleAdStopCountdown(remainingMs);
4284
+ var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
4285
+ var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
4286
+ this.scheduleAdStopCountdown(remainingMs1);
4249
4287
  }
4250
4288
  if (!this.adLayer.isAdPlaying() && this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0) {
4251
4289
  var bids = this.pendingNextAdBids;