stormcloud-video-player 0.6.3 → 0.6.4

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.
@@ -1029,6 +1029,7 @@ function createVastAdLayer(contentVideo, options) {
1029
1029
  var destroyed = false;
1030
1030
  var tornDown = false;
1031
1031
  var trackingFired = createEmptyTrackingState();
1032
+ var adStallTimerId;
1032
1033
  var currentAdEventHandlers;
1033
1034
  var preloadSlots = /* @__PURE__ */ new Map();
1034
1035
  function emit(event, payload) {
@@ -1144,7 +1145,14 @@ function createVastAdLayer(contentVideo, options) {
1144
1145
  video.volume = 1;
1145
1146
  return video;
1146
1147
  }
1148
+ function clearAdStallTimer() {
1149
+ if (adStallTimerId != null) {
1150
+ clearTimeout(adStallTimerId);
1151
+ adStallTimerId = void 0;
1152
+ }
1153
+ }
1147
1154
  function removeAdEventListeners() {
1155
+ clearAdStallTimer();
1148
1156
  if (!currentAdEventHandlers || !adVideoElement) return;
1149
1157
  var el = adVideoElement;
1150
1158
  el.removeEventListener("timeupdate", currentAdEventHandlers.timeupdate);
@@ -1154,6 +1162,7 @@ function createVastAdLayer(contentVideo, options) {
1154
1162
  el.removeEventListener("volumechange", currentAdEventHandlers.volumechange);
1155
1163
  el.removeEventListener("pause", currentAdEventHandlers.pause);
1156
1164
  el.removeEventListener("play", currentAdEventHandlers.play);
1165
+ el.removeEventListener("waiting", currentAdEventHandlers.waiting);
1157
1166
  currentAdEventHandlers = void 0;
1158
1167
  }
1159
1168
  function setupAdEventListeners() {
@@ -1178,6 +1187,7 @@ function createVastAdLayer(contentVideo, options) {
1178
1187
  }
1179
1188
  },
1180
1189
  playing: function playing() {
1190
+ clearAdStallTimer();
1181
1191
  var ad = currentAd;
1182
1192
  if (!ad || trackingFired.start) return;
1183
1193
  trackingFired.start = true;
@@ -1214,6 +1224,16 @@ function createVastAdLayer(contentVideo, options) {
1214
1224
  if (currentAd && adVideoElement && adVideoElement.currentTime > 0) {
1215
1225
  fireTrackingPixels2(currentAd.trackingUrls.resume);
1216
1226
  }
1227
+ },
1228
+ waiting: function waiting() {
1229
+ clearAdStallTimer();
1230
+ adStallTimerId = setTimeout(function() {
1231
+ adStallTimerId = void 0;
1232
+ if (adPlaying) {
1233
+ if (debug) console.warn("".concat(LOG, " Ad video stalled for too long, treating as error"));
1234
+ handleAdError();
1235
+ }
1236
+ }, 8e3);
1217
1237
  }
1218
1238
  };
1219
1239
  adVideoElement.addEventListener("timeupdate", handlers.timeupdate);
@@ -1223,6 +1243,7 @@ function createVastAdLayer(contentVideo, options) {
1223
1243
  adVideoElement.addEventListener("volumechange", handlers.volumechange);
1224
1244
  adVideoElement.addEventListener("pause", handlers.pause);
1225
1245
  adVideoElement.addEventListener("play", handlers.play);
1246
+ adVideoElement.addEventListener("waiting", handlers.waiting);
1226
1247
  currentAdEventHandlers = handlers;
1227
1248
  }
1228
1249
  function setAdPlayingFlag(isPlaying) {
@@ -1234,6 +1255,7 @@ function createVastAdLayer(contentVideo, options) {
1234
1255
  }
1235
1256
  function handleAdComplete() {
1236
1257
  if (tornDown) return;
1258
+ clearAdStallTimer();
1237
1259
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1238
1260
  adPlaying = false;
1239
1261
  setAdPlayingFlag(false);
@@ -1247,6 +1269,7 @@ function createVastAdLayer(contentVideo, options) {
1247
1269
  function handleAdError() {
1248
1270
  if (tornDown) return;
1249
1271
  if (!adPlaying) return;
1272
+ clearAdStallTimer();
1250
1273
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1251
1274
  adPlaying = false;
1252
1275
  setAdPlayingFlag(false);
@@ -1297,6 +1320,7 @@ function createVastAdLayer(contentVideo, options) {
1297
1320
  adHls.loadSource(mediaFile.url);
1298
1321
  adHls.attachMedia(adVideoElement);
1299
1322
  adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
1323
+ if (!adPlaying) return;
1300
1324
  adVideoElement.play().catch(function(error) {
1301
1325
  console.error("".concat(LOG, " Error starting HLS ad playback:"), error);
1302
1326
  handleAdError();
@@ -1930,6 +1954,7 @@ function createVastAdLayer(contentVideo, options) {
1930
1954
  return 1;
1931
1955
  },
1932
1956
  showPlaceholder: function showPlaceholder() {
1957
+ if (singleElementMode) return;
1933
1958
  contentVideo.style.opacity = "0";
1934
1959
  contentVideo.style.visibility = "hidden";
1935
1960
  if (!adContainerEl) {
@@ -3626,7 +3651,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3626
3651
  }
3627
3652
  _this.adLayer.cancelPreload(token);
3628
3653
  } else {
3629
- _this.showPlaceholderLayer();
3654
+ if (!_this.config.singlePipelineMode) {
3655
+ _this.showPlaceholderLayer();
3656
+ }
3630
3657
  _this.adLayer.showPlaceholder();
3631
3658
  _this.isInAdTransition = true;
3632
3659
  setTimeout(function() {
@@ -3650,7 +3677,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3650
3677
  console.log("[StormcloudVideoPlayer] content_resume: skip pending bids, only", remainingNow1, "ms left");
3651
3678
  }
3652
3679
  } else {
3653
- _this.showPlaceholderLayer();
3680
+ if (!_this.config.singlePipelineMode) {
3681
+ _this.showPlaceholderLayer();
3682
+ }
3654
3683
  _this.adLayer.showPlaceholder();
3655
3684
  _this.isInAdTransition = true;
3656
3685
  setTimeout(function() {
@@ -5018,7 +5047,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5018
5047
  if (!this.config.disableFiller) this.showAds = true;
5019
5048
  if (adBreakDurationMs != null) {
5020
5049
  this.startFillerBreakTimer(adBreakDurationMs);
5021
- } else if (!this.config.disableFiller) {
5050
+ } else if (!this.config.disableFiller && this.preloadedTokens.length === 0) {
5022
5051
  this.showPlaceholderLayer();
5023
5052
  }
5024
5053
  if (!this.config.disableFiller) this.adLayer.showPlaceholder();