stormcloud-video-player 0.6.3 → 0.6.5
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/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +53 -11
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +53 -11
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +53 -11
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +53 -11
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +53 -11
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/vastAdLayer.cjs +33 -0
- package/lib/sdk/vastAdLayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +53 -11
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -993,6 +993,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
993
993
|
var destroyed = false;
|
|
994
994
|
var tornDown = false;
|
|
995
995
|
var trackingFired = createEmptyTrackingState();
|
|
996
|
+
var adStallTimerId;
|
|
996
997
|
var currentAdEventHandlers;
|
|
997
998
|
var preloadSlots = /* @__PURE__ */ new Map();
|
|
998
999
|
function emit(event, payload) {
|
|
@@ -1066,6 +1067,14 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1066
1067
|
} else if (debug) {
|
|
1067
1068
|
console.warn("".concat(LOG, " forceMP4Ads: no MP4 files available, falling back to all media files"));
|
|
1068
1069
|
}
|
|
1070
|
+
} else {
|
|
1071
|
+
var mp4Only1 = candidates.filter(function(f) {
|
|
1072
|
+
return !isHlsMediaFile(f);
|
|
1073
|
+
});
|
|
1074
|
+
if (mp4Only1.length > 0) {
|
|
1075
|
+
candidates = mp4Only1;
|
|
1076
|
+
if (debug) console.log("".concat(LOG, " Preferring ").concat(mp4Only1.length, " MP4 file(s) over HLS (mp4-first)"));
|
|
1077
|
+
}
|
|
1069
1078
|
}
|
|
1070
1079
|
var firstFile = candidates[0];
|
|
1071
1080
|
if (candidates.length === 1) return firstFile;
|
|
@@ -1108,7 +1117,14 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1108
1117
|
video.volume = 1;
|
|
1109
1118
|
return video;
|
|
1110
1119
|
}
|
|
1120
|
+
function clearAdStallTimer() {
|
|
1121
|
+
if (adStallTimerId != null) {
|
|
1122
|
+
clearTimeout(adStallTimerId);
|
|
1123
|
+
adStallTimerId = void 0;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1111
1126
|
function removeAdEventListeners() {
|
|
1127
|
+
clearAdStallTimer();
|
|
1112
1128
|
if (!currentAdEventHandlers || !adVideoElement) return;
|
|
1113
1129
|
var el = adVideoElement;
|
|
1114
1130
|
el.removeEventListener("timeupdate", currentAdEventHandlers.timeupdate);
|
|
@@ -1118,6 +1134,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1118
1134
|
el.removeEventListener("volumechange", currentAdEventHandlers.volumechange);
|
|
1119
1135
|
el.removeEventListener("pause", currentAdEventHandlers.pause);
|
|
1120
1136
|
el.removeEventListener("play", currentAdEventHandlers.play);
|
|
1137
|
+
el.removeEventListener("waiting", currentAdEventHandlers.waiting);
|
|
1121
1138
|
currentAdEventHandlers = void 0;
|
|
1122
1139
|
}
|
|
1123
1140
|
function setupAdEventListeners() {
|
|
@@ -1142,6 +1159,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1142
1159
|
}
|
|
1143
1160
|
},
|
|
1144
1161
|
playing: function playing() {
|
|
1162
|
+
clearAdStallTimer();
|
|
1145
1163
|
var ad = currentAd;
|
|
1146
1164
|
if (!ad || trackingFired.start) return;
|
|
1147
1165
|
trackingFired.start = true;
|
|
@@ -1178,6 +1196,16 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1178
1196
|
if (currentAd && adVideoElement && adVideoElement.currentTime > 0) {
|
|
1179
1197
|
fireTrackingPixels2(currentAd.trackingUrls.resume);
|
|
1180
1198
|
}
|
|
1199
|
+
},
|
|
1200
|
+
waiting: function waiting() {
|
|
1201
|
+
clearAdStallTimer();
|
|
1202
|
+
adStallTimerId = setTimeout(function() {
|
|
1203
|
+
adStallTimerId = void 0;
|
|
1204
|
+
if (adPlaying) {
|
|
1205
|
+
if (debug) console.warn("".concat(LOG, " Ad video stalled for too long, treating as error"));
|
|
1206
|
+
handleAdError();
|
|
1207
|
+
}
|
|
1208
|
+
}, 8e3);
|
|
1181
1209
|
}
|
|
1182
1210
|
};
|
|
1183
1211
|
adVideoElement.addEventListener("timeupdate", handlers.timeupdate);
|
|
@@ -1187,6 +1215,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1187
1215
|
adVideoElement.addEventListener("volumechange", handlers.volumechange);
|
|
1188
1216
|
adVideoElement.addEventListener("pause", handlers.pause);
|
|
1189
1217
|
adVideoElement.addEventListener("play", handlers.play);
|
|
1218
|
+
adVideoElement.addEventListener("waiting", handlers.waiting);
|
|
1190
1219
|
currentAdEventHandlers = handlers;
|
|
1191
1220
|
}
|
|
1192
1221
|
function setAdPlayingFlag(isPlaying) {
|
|
@@ -1198,6 +1227,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1198
1227
|
}
|
|
1199
1228
|
function handleAdComplete() {
|
|
1200
1229
|
if (tornDown) return;
|
|
1230
|
+
clearAdStallTimer();
|
|
1201
1231
|
if (debug) console.log("".concat(LOG, " Handling ad completion"));
|
|
1202
1232
|
adPlaying = false;
|
|
1203
1233
|
setAdPlayingFlag(false);
|
|
@@ -1211,6 +1241,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1211
1241
|
function handleAdError() {
|
|
1212
1242
|
if (tornDown) return;
|
|
1213
1243
|
if (!adPlaying) return;
|
|
1244
|
+
clearAdStallTimer();
|
|
1214
1245
|
if (debug) console.log("".concat(LOG, " Handling ad error"));
|
|
1215
1246
|
adPlaying = false;
|
|
1216
1247
|
setAdPlayingFlag(false);
|
|
@@ -1261,6 +1292,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1261
1292
|
adHls.loadSource(mediaFile.url);
|
|
1262
1293
|
adHls.attachMedia(adVideoElement);
|
|
1263
1294
|
adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
|
|
1295
|
+
if (!adPlaying) return;
|
|
1264
1296
|
adVideoElement.play().catch(function(error) {
|
|
1265
1297
|
console.error("".concat(LOG, " Error starting HLS ad playback:"), error);
|
|
1266
1298
|
handleAdError();
|
|
@@ -1894,6 +1926,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1894
1926
|
return 1;
|
|
1895
1927
|
},
|
|
1896
1928
|
showPlaceholder: function showPlaceholder() {
|
|
1929
|
+
if (singleElementMode) return;
|
|
1897
1930
|
contentVideo.style.opacity = "0";
|
|
1898
1931
|
contentVideo.style.visibility = "hidden";
|
|
1899
1932
|
if (!adContainerEl) {
|
|
@@ -3590,7 +3623,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3590
3623
|
}
|
|
3591
3624
|
_this.adLayer.cancelPreload(token);
|
|
3592
3625
|
} else {
|
|
3593
|
-
_this.
|
|
3626
|
+
if (!_this.config.singlePipelineMode) {
|
|
3627
|
+
_this.showPlaceholderLayer();
|
|
3628
|
+
}
|
|
3594
3629
|
_this.adLayer.showPlaceholder();
|
|
3595
3630
|
_this.isInAdTransition = true;
|
|
3596
3631
|
setTimeout(function() {
|
|
@@ -3614,7 +3649,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3614
3649
|
console.log("[StormcloudVideoPlayer] content_resume: skip pending bids, only", remainingNow1, "ms left");
|
|
3615
3650
|
}
|
|
3616
3651
|
} else {
|
|
3617
|
-
_this.
|
|
3652
|
+
if (!_this.config.singlePipelineMode) {
|
|
3653
|
+
_this.showPlaceholderLayer();
|
|
3654
|
+
}
|
|
3618
3655
|
_this.adLayer.showPlaceholder();
|
|
3619
3656
|
_this.isInAdTransition = true;
|
|
3620
3657
|
setTimeout(function() {
|
|
@@ -3973,12 +4010,17 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3973
4010
|
}
|
|
3974
4011
|
}
|
|
3975
4012
|
if (this.inAdBreak) {
|
|
3976
|
-
if (
|
|
3977
|
-
|
|
3978
|
-
if (this.
|
|
3979
|
-
|
|
4013
|
+
if (marker.durationSeconds != null) {
|
|
4014
|
+
var newDurationMs = marker.durationSeconds * 1e3;
|
|
4015
|
+
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
4016
|
+
this.expectedAdBreakDurationMs = newDurationMs;
|
|
4017
|
+
var elapsedMs = this.currentAdBreakStartWallClockMs != null ? Date.now() - this.currentAdBreakStartWallClockMs : 0;
|
|
4018
|
+
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
4019
|
+
this.scheduleAdStopCountdown(remainingMs);
|
|
4020
|
+
if (this.config.debugAdTiming) {
|
|
4021
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(remainingMs, "ms"));
|
|
4022
|
+
}
|
|
3980
4023
|
}
|
|
3981
|
-
this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
|
|
3982
4024
|
}
|
|
3983
4025
|
return;
|
|
3984
4026
|
}
|
|
@@ -4059,9 +4101,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4059
4101
|
this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
|
|
4060
4102
|
}
|
|
4061
4103
|
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4062
|
-
var
|
|
4063
|
-
var
|
|
4064
|
-
this.scheduleAdStopCountdown(
|
|
4104
|
+
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4105
|
+
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4106
|
+
this.scheduleAdStopCountdown(remainingMs1);
|
|
4065
4107
|
}
|
|
4066
4108
|
if (!this.adLayer.isAdPlaying() && this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0) {
|
|
4067
4109
|
var bids = this.pendingNextAdBids;
|
|
@@ -4982,7 +5024,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4982
5024
|
if (!this.config.disableFiller) this.showAds = true;
|
|
4983
5025
|
if (adBreakDurationMs != null) {
|
|
4984
5026
|
this.startFillerBreakTimer(adBreakDurationMs);
|
|
4985
|
-
} else if (!this.config.disableFiller) {
|
|
5027
|
+
} else if (!this.config.disableFiller && this.preloadedTokens.length === 0) {
|
|
4986
5028
|
this.showPlaceholderLayer();
|
|
4987
5029
|
}
|
|
4988
5030
|
if (!this.config.disableFiller) this.adLayer.showPlaceholder();
|