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
|
@@ -941,6 +941,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
941
941
|
var destroyed = false;
|
|
942
942
|
var tornDown = false;
|
|
943
943
|
var trackingFired = createEmptyTrackingState();
|
|
944
|
+
var adStallTimerId;
|
|
944
945
|
var currentAdEventHandlers;
|
|
945
946
|
var preloadSlots = /* @__PURE__ */ new Map();
|
|
946
947
|
function emit(event, payload) {
|
|
@@ -1014,6 +1015,14 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1014
1015
|
} else if (debug) {
|
|
1015
1016
|
console.warn("".concat(LOG, " forceMP4Ads: no MP4 files available, falling back to all media files"));
|
|
1016
1017
|
}
|
|
1018
|
+
} else {
|
|
1019
|
+
var mp4Only1 = candidates.filter(function(f) {
|
|
1020
|
+
return !isHlsMediaFile(f);
|
|
1021
|
+
});
|
|
1022
|
+
if (mp4Only1.length > 0) {
|
|
1023
|
+
candidates = mp4Only1;
|
|
1024
|
+
if (debug) console.log("".concat(LOG, " Preferring ").concat(mp4Only1.length, " MP4 file(s) over HLS (mp4-first)"));
|
|
1025
|
+
}
|
|
1017
1026
|
}
|
|
1018
1027
|
var firstFile = candidates[0];
|
|
1019
1028
|
if (candidates.length === 1) return firstFile;
|
|
@@ -1056,7 +1065,14 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1056
1065
|
video.volume = 1;
|
|
1057
1066
|
return video;
|
|
1058
1067
|
}
|
|
1068
|
+
function clearAdStallTimer() {
|
|
1069
|
+
if (adStallTimerId != null) {
|
|
1070
|
+
clearTimeout(adStallTimerId);
|
|
1071
|
+
adStallTimerId = void 0;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1059
1074
|
function removeAdEventListeners() {
|
|
1075
|
+
clearAdStallTimer();
|
|
1060
1076
|
if (!currentAdEventHandlers || !adVideoElement) return;
|
|
1061
1077
|
var el = adVideoElement;
|
|
1062
1078
|
el.removeEventListener("timeupdate", currentAdEventHandlers.timeupdate);
|
|
@@ -1066,6 +1082,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1066
1082
|
el.removeEventListener("volumechange", currentAdEventHandlers.volumechange);
|
|
1067
1083
|
el.removeEventListener("pause", currentAdEventHandlers.pause);
|
|
1068
1084
|
el.removeEventListener("play", currentAdEventHandlers.play);
|
|
1085
|
+
el.removeEventListener("waiting", currentAdEventHandlers.waiting);
|
|
1069
1086
|
currentAdEventHandlers = void 0;
|
|
1070
1087
|
}
|
|
1071
1088
|
function setupAdEventListeners() {
|
|
@@ -1090,6 +1107,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1090
1107
|
}
|
|
1091
1108
|
},
|
|
1092
1109
|
playing: function playing() {
|
|
1110
|
+
clearAdStallTimer();
|
|
1093
1111
|
var ad = currentAd;
|
|
1094
1112
|
if (!ad || trackingFired.start) return;
|
|
1095
1113
|
trackingFired.start = true;
|
|
@@ -1126,6 +1144,16 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1126
1144
|
if (currentAd && adVideoElement && adVideoElement.currentTime > 0) {
|
|
1127
1145
|
fireTrackingPixels2(currentAd.trackingUrls.resume);
|
|
1128
1146
|
}
|
|
1147
|
+
},
|
|
1148
|
+
waiting: function waiting() {
|
|
1149
|
+
clearAdStallTimer();
|
|
1150
|
+
adStallTimerId = setTimeout(function() {
|
|
1151
|
+
adStallTimerId = void 0;
|
|
1152
|
+
if (adPlaying) {
|
|
1153
|
+
if (debug) console.warn("".concat(LOG, " Ad video stalled for too long, treating as error"));
|
|
1154
|
+
handleAdError();
|
|
1155
|
+
}
|
|
1156
|
+
}, 8e3);
|
|
1129
1157
|
}
|
|
1130
1158
|
};
|
|
1131
1159
|
adVideoElement.addEventListener("timeupdate", handlers.timeupdate);
|
|
@@ -1135,6 +1163,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1135
1163
|
adVideoElement.addEventListener("volumechange", handlers.volumechange);
|
|
1136
1164
|
adVideoElement.addEventListener("pause", handlers.pause);
|
|
1137
1165
|
adVideoElement.addEventListener("play", handlers.play);
|
|
1166
|
+
adVideoElement.addEventListener("waiting", handlers.waiting);
|
|
1138
1167
|
currentAdEventHandlers = handlers;
|
|
1139
1168
|
}
|
|
1140
1169
|
function setAdPlayingFlag(isPlaying) {
|
|
@@ -1146,6 +1175,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1146
1175
|
}
|
|
1147
1176
|
function handleAdComplete() {
|
|
1148
1177
|
if (tornDown) return;
|
|
1178
|
+
clearAdStallTimer();
|
|
1149
1179
|
if (debug) console.log("".concat(LOG, " Handling ad completion"));
|
|
1150
1180
|
adPlaying = false;
|
|
1151
1181
|
setAdPlayingFlag(false);
|
|
@@ -1159,6 +1189,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1159
1189
|
function handleAdError() {
|
|
1160
1190
|
if (tornDown) return;
|
|
1161
1191
|
if (!adPlaying) return;
|
|
1192
|
+
clearAdStallTimer();
|
|
1162
1193
|
if (debug) console.log("".concat(LOG, " Handling ad error"));
|
|
1163
1194
|
adPlaying = false;
|
|
1164
1195
|
setAdPlayingFlag(false);
|
|
@@ -1209,6 +1240,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1209
1240
|
adHls.loadSource(mediaFile.url);
|
|
1210
1241
|
adHls.attachMedia(adVideoElement);
|
|
1211
1242
|
adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
|
|
1243
|
+
if (!adPlaying) return;
|
|
1212
1244
|
adVideoElement.play().catch(function(error) {
|
|
1213
1245
|
console.error("".concat(LOG, " Error starting HLS ad playback:"), error);
|
|
1214
1246
|
handleAdError();
|
|
@@ -1842,6 +1874,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1842
1874
|
return 1;
|
|
1843
1875
|
},
|
|
1844
1876
|
showPlaceholder: function showPlaceholder() {
|
|
1877
|
+
if (singleElementMode) return;
|
|
1845
1878
|
contentVideo.style.opacity = "0";
|
|
1846
1879
|
contentVideo.style.visibility = "hidden";
|
|
1847
1880
|
if (!adContainerEl) {
|
|
@@ -3538,7 +3571,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3538
3571
|
}
|
|
3539
3572
|
_this.adLayer.cancelPreload(token);
|
|
3540
3573
|
} else {
|
|
3541
|
-
_this.
|
|
3574
|
+
if (!_this.config.singlePipelineMode) {
|
|
3575
|
+
_this.showPlaceholderLayer();
|
|
3576
|
+
}
|
|
3542
3577
|
_this.adLayer.showPlaceholder();
|
|
3543
3578
|
_this.isInAdTransition = true;
|
|
3544
3579
|
setTimeout(function() {
|
|
@@ -3562,7 +3597,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3562
3597
|
console.log("[StormcloudVideoPlayer] content_resume: skip pending bids, only", remainingNow1, "ms left");
|
|
3563
3598
|
}
|
|
3564
3599
|
} else {
|
|
3565
|
-
_this.
|
|
3600
|
+
if (!_this.config.singlePipelineMode) {
|
|
3601
|
+
_this.showPlaceholderLayer();
|
|
3602
|
+
}
|
|
3566
3603
|
_this.adLayer.showPlaceholder();
|
|
3567
3604
|
_this.isInAdTransition = true;
|
|
3568
3605
|
setTimeout(function() {
|
|
@@ -3921,12 +3958,17 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3921
3958
|
}
|
|
3922
3959
|
}
|
|
3923
3960
|
if (this.inAdBreak) {
|
|
3924
|
-
if (
|
|
3925
|
-
|
|
3926
|
-
if (this.
|
|
3927
|
-
|
|
3961
|
+
if (marker.durationSeconds != null) {
|
|
3962
|
+
var newDurationMs = marker.durationSeconds * 1e3;
|
|
3963
|
+
if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
|
|
3964
|
+
this.expectedAdBreakDurationMs = newDurationMs;
|
|
3965
|
+
var elapsedMs = this.currentAdBreakStartWallClockMs != null ? Date.now() - this.currentAdBreakStartWallClockMs : 0;
|
|
3966
|
+
var remainingMs = Math.max(0, newDurationMs - elapsedMs);
|
|
3967
|
+
this.scheduleAdStopCountdown(remainingMs);
|
|
3968
|
+
if (this.config.debugAdTiming) {
|
|
3969
|
+
console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(remainingMs, "ms"));
|
|
3970
|
+
}
|
|
3928
3971
|
}
|
|
3929
|
-
this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
|
|
3930
3972
|
}
|
|
3931
3973
|
return;
|
|
3932
3974
|
}
|
|
@@ -4007,9 +4049,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4007
4049
|
this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
|
|
4008
4050
|
}
|
|
4009
4051
|
if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
|
|
4010
|
-
var
|
|
4011
|
-
var
|
|
4012
|
-
this.scheduleAdStopCountdown(
|
|
4052
|
+
var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
4053
|
+
var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
|
|
4054
|
+
this.scheduleAdStopCountdown(remainingMs1);
|
|
4013
4055
|
}
|
|
4014
4056
|
if (!this.adLayer.isAdPlaying() && this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0) {
|
|
4015
4057
|
var bids = this.pendingNextAdBids;
|
|
@@ -4930,7 +4972,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4930
4972
|
if (!this.config.disableFiller) this.showAds = true;
|
|
4931
4973
|
if (adBreakDurationMs != null) {
|
|
4932
4974
|
this.startFillerBreakTimer(adBreakDurationMs);
|
|
4933
|
-
} else if (!this.config.disableFiller) {
|
|
4975
|
+
} else if (!this.config.disableFiller && this.preloadedTokens.length === 0) {
|
|
4934
4976
|
this.showPlaceholderLayer();
|
|
4935
4977
|
}
|
|
4936
4978
|
if (!this.config.disableFiller) this.adLayer.showPlaceholder();
|