stormcloud-video-player 0.8.45 → 0.8.47
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 +233 -74
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +230 -75
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +52 -10
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +2 -0
- package/lib/player/HlsEngine.cjs +40 -4
- package/lib/player/HlsEngine.cjs.map +1 -1
- package/lib/player/HlsEngine.d.cts +1 -0
- package/lib/player/StormcloudVideoPlayer.cjs +229 -74
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +229 -74
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +229 -74
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +126 -60
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +229 -74
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/browserCompat.cjs +9 -0
- package/lib/utils/browserCompat.cjs.map +1 -1
- package/lib/utils/browserCompat.d.cts +2 -1
- package/package.json +1 -1
package/lib/sdk/hlsAdPlayer.cjs
CHANGED
|
@@ -200,15 +200,19 @@ module.exports = __toCommonJS(hlsAdPlayer_exports);
|
|
|
200
200
|
var import_hls = __toESM(require("hls.js"), 1);
|
|
201
201
|
var MAX_VAST_WRAPPER_DEPTH = 5;
|
|
202
202
|
function createHlsAdPlayer(contentVideo, options) {
|
|
203
|
+
var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
|
|
203
204
|
var adPlaying = false;
|
|
204
205
|
var originalMutedState = false;
|
|
205
206
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
206
207
|
var listeners = /* @__PURE__ */ new Map();
|
|
207
208
|
var licenseKey = options === null || options === void 0 ? void 0 : options.licenseKey;
|
|
208
209
|
var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
|
|
209
|
-
var
|
|
210
|
+
var AD_CONTAINER_PROP = "__stormcloudAdContainer";
|
|
211
|
+
var AD_VIDEO_PROP = "__stormcloudAdVideo";
|
|
212
|
+
var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
|
|
210
213
|
var adHls;
|
|
211
|
-
var adContainerEl;
|
|
214
|
+
var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
|
|
215
|
+
var adEventHandlers = [];
|
|
212
216
|
var currentAd;
|
|
213
217
|
var podAds = [];
|
|
214
218
|
var podIndex = 0;
|
|
@@ -852,7 +856,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
852
856
|
}
|
|
853
857
|
function setupAdEventListeners() {
|
|
854
858
|
if (!adVideoElement || !currentAd) return;
|
|
855
|
-
|
|
859
|
+
if (adEventHandlers.length > 0) return;
|
|
860
|
+
var onTimeUpdate = function onTimeUpdate() {
|
|
856
861
|
if (!currentAd || !adVideoElement) return;
|
|
857
862
|
noteAdProgress();
|
|
858
863
|
var progress = adVideoElement.currentTime / currentAd.duration;
|
|
@@ -868,15 +873,15 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
868
873
|
trackingFired.thirdQuartile = true;
|
|
869
874
|
fireTrackingPixels(currentAd.trackingUrls.thirdQuartile);
|
|
870
875
|
}
|
|
871
|
-
}
|
|
872
|
-
|
|
876
|
+
};
|
|
877
|
+
var onPlaying = function onPlaying() {
|
|
873
878
|
startStallWatchdog();
|
|
874
879
|
if (!currentAd || trackingFired.start) return;
|
|
875
880
|
trackingFired.start = true;
|
|
876
881
|
fireTrackingPixels(currentAd.trackingUrls.start);
|
|
877
882
|
console.log("[HlsAdPlayer] Ad started playing");
|
|
878
|
-
}
|
|
879
|
-
|
|
883
|
+
};
|
|
884
|
+
var onEnded = function onEnded() {
|
|
880
885
|
if (!currentAd || trackingFired.complete) return;
|
|
881
886
|
trackingFired.complete = true;
|
|
882
887
|
fireTrackingPixels(currentAd.trackingUrls.complete);
|
|
@@ -885,8 +890,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
885
890
|
return;
|
|
886
891
|
}
|
|
887
892
|
handleAdComplete();
|
|
888
|
-
}
|
|
889
|
-
|
|
893
|
+
};
|
|
894
|
+
var onError = function onError(e) {
|
|
890
895
|
if (!adPlaying) return;
|
|
891
896
|
console.error("[HlsAdPlayer] Ad video error:", e);
|
|
892
897
|
if (currentAd) {
|
|
@@ -896,25 +901,100 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
896
901
|
return;
|
|
897
902
|
}
|
|
898
903
|
handleAdError();
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
if (!currentAd) return;
|
|
904
|
+
};
|
|
905
|
+
var onVolumeChange = function onVolumeChange() {
|
|
906
|
+
if (!currentAd || !adVideoElement) return;
|
|
902
907
|
if (adVideoElement.muted) {
|
|
903
908
|
fireTrackingPixels(currentAd.trackingUrls.mute);
|
|
904
909
|
} else {
|
|
905
910
|
fireTrackingPixels(currentAd.trackingUrls.unmute);
|
|
906
911
|
}
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
if (currentAd && !adVideoElement.ended) {
|
|
912
|
+
};
|
|
913
|
+
var onPause = function onPause() {
|
|
914
|
+
if (currentAd && adVideoElement && !adVideoElement.ended) {
|
|
910
915
|
fireTrackingPixels(currentAd.trackingUrls.pause);
|
|
911
916
|
}
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
if (currentAd && adVideoElement.currentTime > 0) {
|
|
917
|
+
};
|
|
918
|
+
var onPlay = function onPlay() {
|
|
919
|
+
if (currentAd && adVideoElement && adVideoElement.currentTime > 0) {
|
|
915
920
|
fireTrackingPixels(currentAd.trackingUrls.resume);
|
|
916
921
|
}
|
|
917
|
-
}
|
|
922
|
+
};
|
|
923
|
+
adEventHandlers = [
|
|
924
|
+
{
|
|
925
|
+
type: "timeupdate",
|
|
926
|
+
handler: onTimeUpdate
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
type: "playing",
|
|
930
|
+
handler: onPlaying
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
type: "ended",
|
|
934
|
+
handler: onEnded
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
type: "error",
|
|
938
|
+
handler: onError
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
type: "volumechange",
|
|
942
|
+
handler: onVolumeChange
|
|
943
|
+
},
|
|
944
|
+
{
|
|
945
|
+
type: "pause",
|
|
946
|
+
handler: onPause
|
|
947
|
+
},
|
|
948
|
+
{
|
|
949
|
+
type: "play",
|
|
950
|
+
handler: onPlay
|
|
951
|
+
}
|
|
952
|
+
];
|
|
953
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
954
|
+
try {
|
|
955
|
+
for(var _iterator = adEventHandlers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
956
|
+
var _step_value = _step.value, type = _step_value.type, handler = _step_value.handler;
|
|
957
|
+
adVideoElement.addEventListener(type, handler);
|
|
958
|
+
}
|
|
959
|
+
} catch (err) {
|
|
960
|
+
_didIteratorError = true;
|
|
961
|
+
_iteratorError = err;
|
|
962
|
+
} finally{
|
|
963
|
+
try {
|
|
964
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
965
|
+
_iterator.return();
|
|
966
|
+
}
|
|
967
|
+
} finally{
|
|
968
|
+
if (_didIteratorError) {
|
|
969
|
+
throw _iteratorError;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
function teardownAdEventListeners() {
|
|
975
|
+
if (adVideoElement) {
|
|
976
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
977
|
+
try {
|
|
978
|
+
for(var _iterator = adEventHandlers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
979
|
+
var _step_value = _step.value, type = _step_value.type, handler = _step_value.handler;
|
|
980
|
+
adVideoElement.removeEventListener(type, handler);
|
|
981
|
+
}
|
|
982
|
+
} catch (err) {
|
|
983
|
+
_didIteratorError = true;
|
|
984
|
+
_iteratorError = err;
|
|
985
|
+
} finally{
|
|
986
|
+
try {
|
|
987
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
988
|
+
_iterator.return();
|
|
989
|
+
}
|
|
990
|
+
} finally{
|
|
991
|
+
if (_didIteratorError) {
|
|
992
|
+
throw _iteratorError;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
adEventHandlers = [];
|
|
918
998
|
}
|
|
919
999
|
function setAdPlayingFlag(isPlaying) {
|
|
920
1000
|
if (isPlaying) {
|
|
@@ -1054,16 +1134,32 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1054
1134
|
}
|
|
1055
1135
|
}, STALL_CHECK_INTERVAL_MS);
|
|
1056
1136
|
}
|
|
1137
|
+
function releaseAdDecoder() {
|
|
1138
|
+
if (adHls) {
|
|
1139
|
+
adHls.destroy();
|
|
1140
|
+
adHls = void 0;
|
|
1141
|
+
}
|
|
1142
|
+
if (adVideoElement) {
|
|
1143
|
+
try {
|
|
1144
|
+
adVideoElement.pause();
|
|
1145
|
+
adVideoElement.removeAttribute("src");
|
|
1146
|
+
adVideoElement.load();
|
|
1147
|
+
} catch (error) {
|
|
1148
|
+
console.warn("[HlsAdPlayer] Error releasing ad decoder:", error);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
if (adContainerEl) {
|
|
1152
|
+
adContainerEl.style.display = "none";
|
|
1153
|
+
adContainerEl.style.pointerEvents = "none";
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1057
1156
|
function handleAdComplete() {
|
|
1058
1157
|
console.log("[HlsAdPlayer] Handling ad completion");
|
|
1059
1158
|
clearStallWatchdog();
|
|
1060
1159
|
adPlaying = false;
|
|
1061
1160
|
setAdPlayingFlag(false);
|
|
1062
1161
|
contentVideo.muted = true;
|
|
1063
|
-
|
|
1064
|
-
adContainerEl.style.display = "none";
|
|
1065
|
-
adContainerEl.style.pointerEvents = "none";
|
|
1066
|
-
}
|
|
1162
|
+
releaseAdDecoder();
|
|
1067
1163
|
if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1068
1164
|
contentVideo.style.visibility = "visible";
|
|
1069
1165
|
contentVideo.style.opacity = "1";
|
|
@@ -1086,10 +1182,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1086
1182
|
adPlaying = false;
|
|
1087
1183
|
setAdPlayingFlag(false);
|
|
1088
1184
|
contentVideo.muted = true;
|
|
1089
|
-
|
|
1090
|
-
adContainerEl.style.display = "none";
|
|
1091
|
-
adContainerEl.style.pointerEvents = "none";
|
|
1092
|
-
}
|
|
1185
|
+
releaseAdDecoder();
|
|
1093
1186
|
if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1094
1187
|
contentVideo.style.visibility = "visible";
|
|
1095
1188
|
contentVideo.style.opacity = "1";
|
|
@@ -1116,6 +1209,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1116
1209
|
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1117
1210
|
adContainerEl = container;
|
|
1118
1211
|
}
|
|
1212
|
+
contentVideo[AD_CONTAINER_PROP] = adContainerEl;
|
|
1119
1213
|
},
|
|
1120
1214
|
requestAds: function requestAds(vastTagUrl) {
|
|
1121
1215
|
return _async_to_generator(function() {
|
|
@@ -1218,8 +1312,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1218
1312
|
if (!adVideoElement) {
|
|
1219
1313
|
adVideoElement = createAdVideoElement();
|
|
1220
1314
|
adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.appendChild(adVideoElement);
|
|
1221
|
-
|
|
1315
|
+
contentVideo[AD_VIDEO_PROP] = adVideoElement;
|
|
1222
1316
|
}
|
|
1317
|
+
setupAdEventListeners();
|
|
1223
1318
|
resetQuartileTracking(true);
|
|
1224
1319
|
contentVolume = contentVideo.volume;
|
|
1225
1320
|
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
@@ -1298,10 +1393,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1298
1393
|
contentVideo.muted = originalMutedState;
|
|
1299
1394
|
contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
|
|
1300
1395
|
console.log("[HlsAdPlayer] Restored mute state on stop: ".concat(previousMutedState, " -> ").concat(originalMutedState, ", volume: ").concat(contentVideo.volume));
|
|
1301
|
-
|
|
1302
|
-
adContainerEl.style.display = "none";
|
|
1303
|
-
adContainerEl.style.pointerEvents = "none";
|
|
1304
|
-
}
|
|
1396
|
+
releaseAdDecoder();
|
|
1305
1397
|
contentVideo.style.visibility = "visible";
|
|
1306
1398
|
contentVideo.style.opacity = "1";
|
|
1307
1399
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
@@ -1312,17 +1404,6 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1312
1404
|
});
|
|
1313
1405
|
}
|
|
1314
1406
|
}
|
|
1315
|
-
if (adHls) {
|
|
1316
|
-
adHls.destroy();
|
|
1317
|
-
adHls = void 0;
|
|
1318
|
-
}
|
|
1319
|
-
if (adVideoElement) {
|
|
1320
|
-
adVideoElement.pause();
|
|
1321
|
-
adVideoElement.removeAttribute("src");
|
|
1322
|
-
try {
|
|
1323
|
-
adVideoElement.load();
|
|
1324
|
-
} catch (unused) {}
|
|
1325
|
-
}
|
|
1326
1407
|
currentAd = void 0;
|
|
1327
1408
|
podAds = [];
|
|
1328
1409
|
podIndex = 0;
|
|
@@ -1361,23 +1442,8 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1361
1442
|
setAdPlayingFlag(false);
|
|
1362
1443
|
contentVideo.muted = originalMutedState;
|
|
1363
1444
|
contentVideo.volume = Math.max(0, Math.min(1, originalVolume));
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
adHls = void 0;
|
|
1367
|
-
}
|
|
1368
|
-
if (adVideoElement) {
|
|
1369
|
-
adVideoElement.pause();
|
|
1370
|
-
adVideoElement.removeAttribute("src");
|
|
1371
|
-
try {
|
|
1372
|
-
adVideoElement.load();
|
|
1373
|
-
} catch (unused) {}
|
|
1374
|
-
adVideoElement.remove();
|
|
1375
|
-
adVideoElement = void 0;
|
|
1376
|
-
}
|
|
1377
|
-
if (adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.parentElement) {
|
|
1378
|
-
adContainerEl.parentElement.removeChild(adContainerEl);
|
|
1379
|
-
}
|
|
1380
|
-
adContainerEl = void 0;
|
|
1445
|
+
teardownAdEventListeners();
|
|
1446
|
+
releaseAdDecoder();
|
|
1381
1447
|
currentAd = void 0;
|
|
1382
1448
|
podAds = [];
|
|
1383
1449
|
podIndex = 0;
|