stormcloud-video-player 0.8.34 → 0.8.35
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 +105 -16
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +105 -16
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +36 -16
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +3 -7
- package/lib/player/AdConfigManager.d.cts +1 -1
- package/lib/player/AdTimingService.d.cts +1 -1
- package/lib/player/HlsEngine.d.cts +1 -1
- package/lib/player/PlayerControls.d.cts +1 -1
- package/lib/player/Scte35CueManager.d.cts +1 -1
- package/lib/player/Scte35Parser.d.cts +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +105 -16
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/player/playerTypes.d.cts +1 -1
- package/lib/players/HlsPlayer.cjs +105 -16
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +105 -16
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +62 -0
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/{types-CSHvCbhZ.d.cts → types-cTqIKw_D.d.cts} +1 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +105 -16
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/browserCompat.cjs +1 -0
- package/lib/utils/browserCompat.cjs.map +1 -1
- package/lib/utils/browserCompat.d.cts +1 -0
- package/lib/utils/tracking.d.cts +1 -1
- package/package.json +1 -1
package/lib/sdk/hlsAdPlayer.cjs
CHANGED
|
@@ -217,6 +217,11 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
217
217
|
var preloadingAds = /* @__PURE__ */ new Map();
|
|
218
218
|
var destroyed = false;
|
|
219
219
|
var pendingTimeouts = [];
|
|
220
|
+
var STALL_TIMEOUT_MS = 4e3;
|
|
221
|
+
var STALL_CHECK_INTERVAL_MS = 1e3;
|
|
222
|
+
var stallWatchdogId;
|
|
223
|
+
var lastAdProgressTime = 0;
|
|
224
|
+
var lastAdProgressPosition = 0;
|
|
220
225
|
var trackingFired = {
|
|
221
226
|
impression: false,
|
|
222
227
|
start: false,
|
|
@@ -849,6 +854,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
849
854
|
if (!adVideoElement || !currentAd) return;
|
|
850
855
|
adVideoElement.addEventListener("timeupdate", function() {
|
|
851
856
|
if (!currentAd || !adVideoElement) return;
|
|
857
|
+
noteAdProgress();
|
|
852
858
|
var progress = adVideoElement.currentTime / currentAd.duration;
|
|
853
859
|
if (progress >= 0.25 && !trackingFired.firstQuartile) {
|
|
854
860
|
trackingFired.firstQuartile = true;
|
|
@@ -864,6 +870,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
864
870
|
}
|
|
865
871
|
});
|
|
866
872
|
adVideoElement.addEventListener("playing", function() {
|
|
873
|
+
startStallWatchdog();
|
|
867
874
|
if (!currentAd || trackingFired.start) return;
|
|
868
875
|
trackingFired.start = true;
|
|
869
876
|
fireTrackingPixels(currentAd.trackingUrls.start);
|
|
@@ -1004,8 +1011,52 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1004
1011
|
return false;
|
|
1005
1012
|
}
|
|
1006
1013
|
}
|
|
1014
|
+
function clearStallWatchdog() {
|
|
1015
|
+
if (stallWatchdogId != null) {
|
|
1016
|
+
clearInterval(stallWatchdogId);
|
|
1017
|
+
stallWatchdogId = void 0;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
function noteAdProgress() {
|
|
1021
|
+
lastAdProgressTime = Date.now();
|
|
1022
|
+
if (adVideoElement) {
|
|
1023
|
+
lastAdProgressPosition = adVideoElement.currentTime;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
function handleAdStall() {
|
|
1027
|
+
console.warn("[HlsAdPlayer] Ad playback stalled (no progress) - recovering to avoid a blank frame");
|
|
1028
|
+
clearStallWatchdog();
|
|
1029
|
+
if (currentAd) {
|
|
1030
|
+
fireTrackingPixels(currentAd.trackingUrls.error);
|
|
1031
|
+
}
|
|
1032
|
+
if (podIndex < podAds.length - 1 && advanceToNextPodAd()) {
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
handleAdError();
|
|
1036
|
+
}
|
|
1037
|
+
function startStallWatchdog() {
|
|
1038
|
+
clearStallWatchdog();
|
|
1039
|
+
noteAdProgress();
|
|
1040
|
+
stallWatchdogId = window.setInterval(function() {
|
|
1041
|
+
if (!adPlaying || !adVideoElement) {
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
if (adVideoElement.currentTime > lastAdProgressPosition + 0.05) {
|
|
1045
|
+
noteAdProgress();
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
if (adVideoElement.paused) {
|
|
1049
|
+
noteAdProgress();
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
if (Date.now() - lastAdProgressTime >= STALL_TIMEOUT_MS) {
|
|
1053
|
+
handleAdStall();
|
|
1054
|
+
}
|
|
1055
|
+
}, STALL_CHECK_INTERVAL_MS);
|
|
1056
|
+
}
|
|
1007
1057
|
function handleAdComplete() {
|
|
1008
1058
|
console.log("[HlsAdPlayer] Handling ad completion");
|
|
1059
|
+
clearStallWatchdog();
|
|
1009
1060
|
adPlaying = false;
|
|
1010
1061
|
setAdPlayingFlag(false);
|
|
1011
1062
|
contentVideo.muted = true;
|
|
@@ -1013,6 +1064,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1013
1064
|
adContainerEl.style.display = "none";
|
|
1014
1065
|
adContainerEl.style.pointerEvents = "none";
|
|
1015
1066
|
}
|
|
1067
|
+
if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1068
|
+
contentVideo.style.visibility = "visible";
|
|
1069
|
+
contentVideo.style.opacity = "1";
|
|
1070
|
+
}
|
|
1016
1071
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
1017
1072
|
if (contentVideo.paused) {
|
|
1018
1073
|
console.log("[HlsAdPlayer] Content video paused in live mode, resuming playback");
|
|
@@ -1025,6 +1080,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1025
1080
|
}
|
|
1026
1081
|
function handleAdError() {
|
|
1027
1082
|
console.log("[HlsAdPlayer] Handling ad error");
|
|
1083
|
+
clearStallWatchdog();
|
|
1028
1084
|
adPlaying = false;
|
|
1029
1085
|
setAdPlayingFlag(false);
|
|
1030
1086
|
contentVideo.muted = true;
|
|
@@ -1032,6 +1088,10 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1032
1088
|
adContainerEl.style.display = "none";
|
|
1033
1089
|
adContainerEl.style.pointerEvents = "none";
|
|
1034
1090
|
}
|
|
1091
|
+
if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1092
|
+
contentVideo.style.visibility = "visible";
|
|
1093
|
+
contentVideo.style.opacity = "1";
|
|
1094
|
+
}
|
|
1035
1095
|
emit("ad_error");
|
|
1036
1096
|
}
|
|
1037
1097
|
return {
|
|
@@ -1229,6 +1289,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1229
1289
|
var previousMutedState;
|
|
1230
1290
|
return _ts_generator(this, function(_state) {
|
|
1231
1291
|
console.log("[HlsAdPlayer] Stopping ad");
|
|
1292
|
+
clearStallWatchdog();
|
|
1232
1293
|
adPlaying = false;
|
|
1233
1294
|
setAdPlayingFlag(false);
|
|
1234
1295
|
previousMutedState = contentVideo.muted;
|
|
@@ -1267,6 +1328,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1267
1328
|
destroy: function destroy() {
|
|
1268
1329
|
console.log("[HlsAdPlayer] Destroying");
|
|
1269
1330
|
destroyed = true;
|
|
1331
|
+
clearStallWatchdog();
|
|
1270
1332
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1271
1333
|
try {
|
|
1272
1334
|
for(var _iterator = pendingTimeouts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|