stormcloud-video-player 0.3.53 → 0.3.55
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 +1315 -1140
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +391 -221
- package/lib/index.d.ts +391 -221
- package/lib/index.js +1264 -1101
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +547 -148
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +13 -1
- package/lib/players/FilePlayer.cjs +99 -116
- package/lib/players/FilePlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +599 -200
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +678 -279
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +17 -9
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/sdk/ima.cjs +43 -48
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/sdk/ima.d.cts +1 -1
- package/lib/{types-DYelrVG6.d.cts → types-C23mJ_hh.d.cts} +15 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +1124 -961
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/browserCompat.cjs +11 -11
- package/lib/utils/browserCompat.cjs.map +1 -1
- package/lib/utils/polyfills.cjs +13 -13
- package/lib/utils/polyfills.cjs.map +1 -1
- package/lib/utils/tracking.cjs +283 -14
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +12 -2
- package/package.json +1 -1
|
@@ -227,9 +227,17 @@ function _ts_generator(thisArg, body) {
|
|
|
227
227
|
},
|
|
228
228
|
trys: [],
|
|
229
229
|
ops: []
|
|
230
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
231
|
-
return
|
|
232
|
-
|
|
230
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
231
|
+
return d(g, "next", {
|
|
232
|
+
value: verb(0)
|
|
233
|
+
}), d(g, "throw", {
|
|
234
|
+
value: verb(1)
|
|
235
|
+
}), d(g, "return", {
|
|
236
|
+
value: verb(2)
|
|
237
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
238
|
+
value: function() {
|
|
239
|
+
return this;
|
|
240
|
+
}
|
|
233
241
|
}), g;
|
|
234
242
|
function verb(n) {
|
|
235
243
|
return function(v) {
|
|
@@ -329,20 +337,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
329
337
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
330
338
|
var __getProtoOf = Object.getPrototypeOf;
|
|
331
339
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
332
|
-
var __export = function(target, all) {
|
|
340
|
+
var __export = function __export(target, all) {
|
|
333
341
|
for(var name in all)__defProp(target, name, {
|
|
334
342
|
get: all[name],
|
|
335
343
|
enumerable: true
|
|
336
344
|
});
|
|
337
345
|
};
|
|
338
|
-
var __copyProps = function(to, from, except, desc) {
|
|
346
|
+
var __copyProps = function __copyProps(to, from, except, desc) {
|
|
339
347
|
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
340
348
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
341
349
|
try {
|
|
342
350
|
var _loop = function() {
|
|
343
351
|
var key = _step.value;
|
|
344
352
|
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
345
|
-
get: function() {
|
|
353
|
+
get: function get() {
|
|
346
354
|
return from[key];
|
|
347
355
|
},
|
|
348
356
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
@@ -366,7 +374,7 @@ var __copyProps = function(to, from, except, desc) {
|
|
|
366
374
|
}
|
|
367
375
|
return to;
|
|
368
376
|
};
|
|
369
|
-
var __toESM = function(mod, isNodeMode, target) {
|
|
377
|
+
var __toESM = function __toESM(mod, isNodeMode, target) {
|
|
370
378
|
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
371
379
|
// file that has been converted to a CommonJS file using a Babel-
|
|
372
380
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
@@ -376,7 +384,7 @@ var __toESM = function(mod, isNodeMode, target) {
|
|
|
376
384
|
enumerable: true
|
|
377
385
|
}) : target, mod);
|
|
378
386
|
};
|
|
379
|
-
var __toCommonJS = function(mod) {
|
|
387
|
+
var __toCommonJS = function __toCommonJS(mod) {
|
|
380
388
|
return __copyProps(__defProp({}, "__esModule", {
|
|
381
389
|
value: true
|
|
382
390
|
}), mod);
|
|
@@ -384,7 +392,7 @@ var __toCommonJS = function(mod) {
|
|
|
384
392
|
// src/players/HlsPlayer.tsx
|
|
385
393
|
var HlsPlayer_exports = {};
|
|
386
394
|
__export(HlsPlayer_exports, {
|
|
387
|
-
default: function() {
|
|
395
|
+
default: function _default() {
|
|
388
396
|
return HlsPlayer;
|
|
389
397
|
}
|
|
390
398
|
});
|
|
@@ -719,7 +727,7 @@ function createImaController(video, options) {
|
|
|
719
727
|
var fn = _step.value;
|
|
720
728
|
try {
|
|
721
729
|
fn(payload);
|
|
722
|
-
} catch (
|
|
730
|
+
} catch (unused) {}
|
|
723
731
|
}
|
|
724
732
|
} catch (err) {
|
|
725
733
|
_didIteratorError = true;
|
|
@@ -757,7 +765,7 @@ function createImaController(video, options) {
|
|
|
757
765
|
console.error("StormcloudVideoPlayer: The host page is inside a sandboxed iframe without 'allow-scripts'. Google IMA cannot run ads within sandboxed frames. Remove the sandbox attribute or include 'allow-scripts allow-same-origin'.");
|
|
758
766
|
}
|
|
759
767
|
}
|
|
760
|
-
} catch (
|
|
768
|
+
} catch (unused) {}
|
|
761
769
|
if (typeof window !== "undefined" && ((_window_google = window.google) === null || _window_google === void 0 ? void 0 : _window_google.ima)) return Promise.resolve();
|
|
762
770
|
var existing = document.querySelector('script[data-ima="true"]');
|
|
763
771
|
if (existing) {
|
|
@@ -799,9 +807,6 @@ function createImaController(video, options) {
|
|
|
799
807
|
var adDisplayContainer;
|
|
800
808
|
var adContainerEl;
|
|
801
809
|
var lastAdTagUrl;
|
|
802
|
-
var retryAttempts = 0;
|
|
803
|
-
var maxRetries = 2;
|
|
804
|
-
var backoffBaseMs = 500;
|
|
805
810
|
var adsLoadedPromise;
|
|
806
811
|
var adsLoadedResolve;
|
|
807
812
|
var adsLoadedReject;
|
|
@@ -1005,7 +1010,7 @@ function createImaController(video, options) {
|
|
|
1005
1010
|
if (adsManager) {
|
|
1006
1011
|
try {
|
|
1007
1012
|
adsManager.destroy();
|
|
1008
|
-
} catch (
|
|
1013
|
+
} catch (unused) {}
|
|
1009
1014
|
adsManager = void 0;
|
|
1010
1015
|
}
|
|
1011
1016
|
if (adVideoElement) {
|
|
@@ -1016,7 +1021,7 @@ function createImaController(video, options) {
|
|
|
1016
1021
|
if (adsLoader) {
|
|
1017
1022
|
try {
|
|
1018
1023
|
adsLoader.destroy();
|
|
1019
|
-
} catch (
|
|
1024
|
+
} catch (unused) {}
|
|
1020
1025
|
adsLoader = void 0;
|
|
1021
1026
|
}
|
|
1022
1027
|
}
|
|
@@ -1034,7 +1039,7 @@ function createImaController(video, options) {
|
|
|
1034
1039
|
try {
|
|
1035
1040
|
var _adDisplayContainer_initialize;
|
|
1036
1041
|
(_adDisplayContainer_initialize = adDisplayContainer.initialize) === null || _adDisplayContainer_initialize === void 0 ? void 0 : _adDisplayContainer_initialize.call(adDisplayContainer);
|
|
1037
|
-
} catch (
|
|
1042
|
+
} catch (unused) {}
|
|
1038
1043
|
}
|
|
1039
1044
|
}).catch(function() {});
|
|
1040
1045
|
},
|
|
@@ -1098,7 +1103,6 @@ function createImaController(video, options) {
|
|
|
1098
1103
|
_state.sent();
|
|
1099
1104
|
google = window.google;
|
|
1100
1105
|
lastAdTagUrl = vastTagUrl;
|
|
1101
|
-
retryAttempts = 0;
|
|
1102
1106
|
if (!adDisplayContainer) {
|
|
1103
1107
|
container = document.createElement("div");
|
|
1104
1108
|
container.style.position = "absolute";
|
|
@@ -1182,32 +1186,23 @@ function createImaController(video, options) {
|
|
|
1182
1186
|
}
|
|
1183
1187
|
}, 300);
|
|
1184
1188
|
}
|
|
1185
|
-
|
|
1189
|
+
showContentVideo();
|
|
1186
1190
|
if (adsLoadedReject) {
|
|
1187
1191
|
adsLoadedReject(new Error("Ad playback error"));
|
|
1188
1192
|
adsLoadedReject = void 0;
|
|
1189
1193
|
adsLoadedResolve = void 0;
|
|
1190
1194
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
message: errorMessage,
|
|
1203
|
-
cause: innerError,
|
|
1204
|
-
isNoFill: isNoFill
|
|
1205
|
-
});
|
|
1206
|
-
if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1207
|
-
if (video.paused) {
|
|
1208
|
-
var _video_play;
|
|
1209
|
-
(_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function() {});
|
|
1210
|
-
}
|
|
1195
|
+
emit("ad_error", {
|
|
1196
|
+
code: errorCode,
|
|
1197
|
+
vastErrorCode: vastErrorCode,
|
|
1198
|
+
message: errorMessage,
|
|
1199
|
+
cause: innerError,
|
|
1200
|
+
isNoFill: isNoFill
|
|
1201
|
+
});
|
|
1202
|
+
if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
|
|
1203
|
+
if (video.paused) {
|
|
1204
|
+
var _video_play;
|
|
1205
|
+
(_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function() {});
|
|
1211
1206
|
}
|
|
1212
1207
|
}
|
|
1213
1208
|
});
|
|
@@ -1225,7 +1220,7 @@ function createImaController(video, options) {
|
|
|
1225
1220
|
if (adsManager) {
|
|
1226
1221
|
try {
|
|
1227
1222
|
adsManager.setVolume(adVolume);
|
|
1228
|
-
} catch (
|
|
1223
|
+
} catch (unused) {}
|
|
1229
1224
|
}
|
|
1230
1225
|
emit("content_pause");
|
|
1231
1226
|
});
|
|
@@ -1239,7 +1234,7 @@ function createImaController(video, options) {
|
|
|
1239
1234
|
if (adsManager) {
|
|
1240
1235
|
try {
|
|
1241
1236
|
adsManager.setVolume(originalMutedState ? 0 : adVolume);
|
|
1242
|
-
} catch (
|
|
1237
|
+
} catch (unused) {}
|
|
1243
1238
|
}
|
|
1244
1239
|
}
|
|
1245
1240
|
if (adContainerEl) {
|
|
@@ -1253,7 +1248,7 @@ function createImaController(video, options) {
|
|
|
1253
1248
|
adsManager.addEventListener(AdEvent.CONTENT_RESUME_REQUESTED, function() {
|
|
1254
1249
|
adPlaying = false;
|
|
1255
1250
|
setAdPlayingFlag(false);
|
|
1256
|
-
|
|
1251
|
+
showContentVideo();
|
|
1257
1252
|
emit("content_resume");
|
|
1258
1253
|
});
|
|
1259
1254
|
adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, function() {
|
|
@@ -1269,7 +1264,7 @@ function createImaController(video, options) {
|
|
|
1269
1264
|
}
|
|
1270
1265
|
}, 300);
|
|
1271
1266
|
}
|
|
1272
|
-
|
|
1267
|
+
showContentVideo();
|
|
1273
1268
|
emit("all_ads_completed");
|
|
1274
1269
|
});
|
|
1275
1270
|
if (adsLoadedResolve) {
|
|
@@ -1291,7 +1286,7 @@ function createImaController(video, options) {
|
|
|
1291
1286
|
}
|
|
1292
1287
|
}, 300);
|
|
1293
1288
|
}
|
|
1294
|
-
|
|
1289
|
+
showContentVideo();
|
|
1295
1290
|
if (adsLoadedReject) {
|
|
1296
1291
|
adsLoadedReject(new Error("Failed to setup ads manager"));
|
|
1297
1292
|
adsLoadedReject = void 0;
|
|
@@ -1334,7 +1329,7 @@ function createImaController(video, options) {
|
|
|
1334
1329
|
}
|
|
1335
1330
|
}, 300);
|
|
1336
1331
|
}
|
|
1337
|
-
|
|
1332
|
+
showContentVideo();
|
|
1338
1333
|
if (adsLoadedReject) {
|
|
1339
1334
|
adsLoadedReject(new Error(isNoFill ? "No ads available" : "Ads loader error"));
|
|
1340
1335
|
adsLoadedReject = void 0;
|
|
@@ -1400,7 +1395,7 @@ function createImaController(video, options) {
|
|
|
1400
1395
|
}
|
|
1401
1396
|
try {
|
|
1402
1397
|
adsManager.setVolume(originalMutedState ? 0 : adVolume);
|
|
1403
|
-
} catch (
|
|
1398
|
+
} catch (unused) {}
|
|
1404
1399
|
adsManager.start();
|
|
1405
1400
|
return [
|
|
1406
1401
|
2,
|
|
@@ -1482,7 +1477,7 @@ function createImaController(video, options) {
|
|
|
1482
1477
|
try {
|
|
1483
1478
|
;
|
|
1484
1479
|
adsManager === null || adsManager === void 0 ? void 0 : (_adsManager_stop = adsManager.stop) === null || _adsManager_stop === void 0 ? void 0 : _adsManager_stop.call(adsManager);
|
|
1485
|
-
} catch (
|
|
1480
|
+
} catch (unused) {}
|
|
1486
1481
|
destroyAdsManager();
|
|
1487
1482
|
return [
|
|
1488
1483
|
2
|
|
@@ -1513,7 +1508,7 @@ function createImaController(video, options) {
|
|
|
1513
1508
|
try {
|
|
1514
1509
|
var _adsLoader_destroy;
|
|
1515
1510
|
adsLoader === null || adsLoader === void 0 ? void 0 : (_adsLoader_destroy = adsLoader.destroy) === null || _adsLoader_destroy === void 0 ? void 0 : _adsLoader_destroy.call(adsLoader);
|
|
1516
|
-
} catch (
|
|
1511
|
+
} catch (unused) {}
|
|
1517
1512
|
adDisplayContainer = void 0;
|
|
1518
1513
|
adsLoader = void 0;
|
|
1519
1514
|
contentVideoHidden = false;
|
|
@@ -1562,7 +1557,7 @@ function createImaController(video, options) {
|
|
|
1562
1557
|
if (adsManager && adPlaying) {
|
|
1563
1558
|
try {
|
|
1564
1559
|
adsManager.setVolume(clampedVolume);
|
|
1565
|
-
} catch (
|
|
1560
|
+
} catch (unused) {}
|
|
1566
1561
|
}
|
|
1567
1562
|
},
|
|
1568
1563
|
getAdVolume: function getAdVolume() {
|
|
@@ -2666,9 +2661,6 @@ function sendInitialTracking(licenseKey) {
|
|
|
2666
2661
|
headers = {
|
|
2667
2662
|
"Content-Type": "application/json"
|
|
2668
2663
|
};
|
|
2669
|
-
if (licenseKey) {
|
|
2670
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2671
|
-
}
|
|
2672
2664
|
return [
|
|
2673
2665
|
4,
|
|
2674
2666
|
fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track", {
|
|
@@ -2774,6 +2766,234 @@ function sendHeartbeat(licenseKey) {
|
|
|
2774
2766
|
});
|
|
2775
2767
|
})();
|
|
2776
2768
|
}
|
|
2769
|
+
var TRACK_API_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track";
|
|
2770
|
+
function mapToAdTrackingSource(source, adPlayerType) {
|
|
2771
|
+
if (source === "prebid" || source === "ima" || source === "hls") {
|
|
2772
|
+
return source;
|
|
2773
|
+
}
|
|
2774
|
+
if (source === "preload" || source === "ssp") {
|
|
2775
|
+
return source === "ssp" ? "prebid" : "ima";
|
|
2776
|
+
}
|
|
2777
|
+
return adPlayerType === "hls" ? "hls" : "ima";
|
|
2778
|
+
}
|
|
2779
|
+
function postAdTracking(licenseKey, body) {
|
|
2780
|
+
return _async_to_generator(function() {
|
|
2781
|
+
var headers, response;
|
|
2782
|
+
return _ts_generator(this, function(_state) {
|
|
2783
|
+
switch(_state.label){
|
|
2784
|
+
case 0:
|
|
2785
|
+
headers = {
|
|
2786
|
+
"Content-Type": "application/json"
|
|
2787
|
+
};
|
|
2788
|
+
if (licenseKey) {
|
|
2789
|
+
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2790
|
+
}
|
|
2791
|
+
return [
|
|
2792
|
+
4,
|
|
2793
|
+
fetch(TRACK_API_URL, {
|
|
2794
|
+
method: "POST",
|
|
2795
|
+
headers: headers,
|
|
2796
|
+
body: JSON.stringify(body)
|
|
2797
|
+
})
|
|
2798
|
+
];
|
|
2799
|
+
case 1:
|
|
2800
|
+
response = _state.sent();
|
|
2801
|
+
if (!response.ok) {
|
|
2802
|
+
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2803
|
+
}
|
|
2804
|
+
return [
|
|
2805
|
+
4,
|
|
2806
|
+
response.json()
|
|
2807
|
+
];
|
|
2808
|
+
case 2:
|
|
2809
|
+
_state.sent();
|
|
2810
|
+
return [
|
|
2811
|
+
2
|
|
2812
|
+
];
|
|
2813
|
+
}
|
|
2814
|
+
});
|
|
2815
|
+
})();
|
|
2816
|
+
}
|
|
2817
|
+
function sendAdDetectTracking(licenseKey, payload) {
|
|
2818
|
+
return _async_to_generator(function() {
|
|
2819
|
+
var _payload_source, _payload_timestamp, clientInfo, browserId, adDetectInfo, body, error;
|
|
2820
|
+
return _ts_generator(this, function(_state) {
|
|
2821
|
+
switch(_state.label){
|
|
2822
|
+
case 0:
|
|
2823
|
+
_state.trys.push([
|
|
2824
|
+
0,
|
|
2825
|
+
3,
|
|
2826
|
+
,
|
|
2827
|
+
4
|
|
2828
|
+
]);
|
|
2829
|
+
clientInfo = getClientInfo();
|
|
2830
|
+
return [
|
|
2831
|
+
4,
|
|
2832
|
+
getBrowserID(clientInfo)
|
|
2833
|
+
];
|
|
2834
|
+
case 1:
|
|
2835
|
+
browserId = _state.sent();
|
|
2836
|
+
adDetectInfo = _object_spread({
|
|
2837
|
+
source: (_payload_source = payload.source) !== null && _payload_source !== void 0 ? _payload_source : "scte35",
|
|
2838
|
+
timestamp: (_payload_timestamp = payload.timestamp) !== null && _payload_timestamp !== void 0 ? _payload_timestamp : /* @__PURE__ */ new Date().toISOString()
|
|
2839
|
+
}, payload.durationSeconds != null && {
|
|
2840
|
+
durationSeconds: payload.durationSeconds
|
|
2841
|
+
}, payload.ptsSeconds != null && {
|
|
2842
|
+
ptsSeconds: payload.ptsSeconds
|
|
2843
|
+
}, payload.detectedAtFragmentSn != null && {
|
|
2844
|
+
detectedAtFragmentSn: payload.detectedAtFragmentSn
|
|
2845
|
+
});
|
|
2846
|
+
body = _object_spread_props(_object_spread({
|
|
2847
|
+
browserId: browserId
|
|
2848
|
+
}, clientInfo, licenseKey && {
|
|
2849
|
+
licenseKey: licenseKey
|
|
2850
|
+
}), {
|
|
2851
|
+
adDetectInfo: adDetectInfo
|
|
2852
|
+
});
|
|
2853
|
+
return [
|
|
2854
|
+
4,
|
|
2855
|
+
postAdTracking(licenseKey, body)
|
|
2856
|
+
];
|
|
2857
|
+
case 2:
|
|
2858
|
+
_state.sent();
|
|
2859
|
+
return [
|
|
2860
|
+
3,
|
|
2861
|
+
4
|
|
2862
|
+
];
|
|
2863
|
+
case 3:
|
|
2864
|
+
error = _state.sent();
|
|
2865
|
+
console.error("[StormcloudVideoPlayer] Error sending ad-detect tracking:", error);
|
|
2866
|
+
return [
|
|
2867
|
+
3,
|
|
2868
|
+
4
|
|
2869
|
+
];
|
|
2870
|
+
case 4:
|
|
2871
|
+
return [
|
|
2872
|
+
2
|
|
2873
|
+
];
|
|
2874
|
+
}
|
|
2875
|
+
});
|
|
2876
|
+
})();
|
|
2877
|
+
}
|
|
2878
|
+
function sendAdLoadedTracking(licenseKey, payload, adPlayerType) {
|
|
2879
|
+
return _async_to_generator(function() {
|
|
2880
|
+
var clientInfo, browserId, source, adLoadedInfo, body, error;
|
|
2881
|
+
return _ts_generator(this, function(_state) {
|
|
2882
|
+
switch(_state.label){
|
|
2883
|
+
case 0:
|
|
2884
|
+
_state.trys.push([
|
|
2885
|
+
0,
|
|
2886
|
+
3,
|
|
2887
|
+
,
|
|
2888
|
+
4
|
|
2889
|
+
]);
|
|
2890
|
+
clientInfo = getClientInfo();
|
|
2891
|
+
return [
|
|
2892
|
+
4,
|
|
2893
|
+
getBrowserID(clientInfo)
|
|
2894
|
+
];
|
|
2895
|
+
case 1:
|
|
2896
|
+
browserId = _state.sent();
|
|
2897
|
+
source = mapToAdTrackingSource(payload.source, adPlayerType);
|
|
2898
|
+
adLoadedInfo = _object_spread({
|
|
2899
|
+
source: source,
|
|
2900
|
+
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
2901
|
+
}, payload.vastUrl != null && {
|
|
2902
|
+
vastUrl: payload.vastUrl
|
|
2903
|
+
}, payload.durationSeconds != null && {
|
|
2904
|
+
durationSeconds: payload.durationSeconds
|
|
2905
|
+
});
|
|
2906
|
+
body = _object_spread_props(_object_spread({
|
|
2907
|
+
browserId: browserId
|
|
2908
|
+
}, clientInfo, licenseKey && {
|
|
2909
|
+
licenseKey: licenseKey
|
|
2910
|
+
}), {
|
|
2911
|
+
adLoadedInfo: adLoadedInfo
|
|
2912
|
+
});
|
|
2913
|
+
return [
|
|
2914
|
+
4,
|
|
2915
|
+
postAdTracking(licenseKey, body)
|
|
2916
|
+
];
|
|
2917
|
+
case 2:
|
|
2918
|
+
_state.sent();
|
|
2919
|
+
return [
|
|
2920
|
+
3,
|
|
2921
|
+
4
|
|
2922
|
+
];
|
|
2923
|
+
case 3:
|
|
2924
|
+
error = _state.sent();
|
|
2925
|
+
console.error("[StormcloudVideoPlayer] Error sending ad-loaded tracking:", error);
|
|
2926
|
+
return [
|
|
2927
|
+
3,
|
|
2928
|
+
4
|
|
2929
|
+
];
|
|
2930
|
+
case 4:
|
|
2931
|
+
return [
|
|
2932
|
+
2
|
|
2933
|
+
];
|
|
2934
|
+
}
|
|
2935
|
+
});
|
|
2936
|
+
})();
|
|
2937
|
+
}
|
|
2938
|
+
function sendAdImpressionTracking(licenseKey, payload, adPlayerType) {
|
|
2939
|
+
return _async_to_generator(function() {
|
|
2940
|
+
var clientInfo, browserId, source, adImpressionInfo, body, error;
|
|
2941
|
+
return _ts_generator(this, function(_state) {
|
|
2942
|
+
switch(_state.label){
|
|
2943
|
+
case 0:
|
|
2944
|
+
_state.trys.push([
|
|
2945
|
+
0,
|
|
2946
|
+
3,
|
|
2947
|
+
,
|
|
2948
|
+
4
|
|
2949
|
+
]);
|
|
2950
|
+
clientInfo = getClientInfo();
|
|
2951
|
+
return [
|
|
2952
|
+
4,
|
|
2953
|
+
getBrowserID(clientInfo)
|
|
2954
|
+
];
|
|
2955
|
+
case 1:
|
|
2956
|
+
browserId = _state.sent();
|
|
2957
|
+
source = mapToAdTrackingSource(payload.source, adPlayerType);
|
|
2958
|
+
adImpressionInfo = _object_spread({
|
|
2959
|
+
source: source,
|
|
2960
|
+
adIndex: payload.adIndex,
|
|
2961
|
+
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
2962
|
+
}, payload.durationSeconds != null && {
|
|
2963
|
+
durationSeconds: payload.durationSeconds
|
|
2964
|
+
});
|
|
2965
|
+
body = _object_spread_props(_object_spread({
|
|
2966
|
+
browserId: browserId
|
|
2967
|
+
}, clientInfo, licenseKey && {
|
|
2968
|
+
licenseKey: licenseKey
|
|
2969
|
+
}), {
|
|
2970
|
+
adImpressionInfo: adImpressionInfo
|
|
2971
|
+
});
|
|
2972
|
+
return [
|
|
2973
|
+
4,
|
|
2974
|
+
postAdTracking(licenseKey, body)
|
|
2975
|
+
];
|
|
2976
|
+
case 2:
|
|
2977
|
+
_state.sent();
|
|
2978
|
+
return [
|
|
2979
|
+
3,
|
|
2980
|
+
4
|
|
2981
|
+
];
|
|
2982
|
+
case 3:
|
|
2983
|
+
error = _state.sent();
|
|
2984
|
+
console.error("[StormcloudVideoPlayer] Error sending ad-impression tracking:", error);
|
|
2985
|
+
return [
|
|
2986
|
+
3,
|
|
2987
|
+
4
|
|
2988
|
+
];
|
|
2989
|
+
case 4:
|
|
2990
|
+
return [
|
|
2991
|
+
2
|
|
2992
|
+
];
|
|
2993
|
+
}
|
|
2994
|
+
});
|
|
2995
|
+
})();
|
|
2996
|
+
}
|
|
2777
2997
|
// src/utils/polyfills.ts
|
|
2778
2998
|
function polyfillURLSearchParams() {
|
|
2779
2999
|
if (typeof URLSearchParams !== "undefined") {
|
|
@@ -3055,18 +3275,26 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3055
3275
|
this.maxPlaceholderDurationMs = 5e3;
|
|
3056
3276
|
this.isShowingPlaceholder = false;
|
|
3057
3277
|
this.totalAdRequestsInBreak = 0;
|
|
3058
|
-
this.maxTotalAdRequestsPerBreak =
|
|
3278
|
+
this.maxTotalAdRequestsPerBreak = 10;
|
|
3059
3279
|
this.pendingAdBreak = null;
|
|
3060
3280
|
this.consecutiveFailures = 0;
|
|
3061
3281
|
this.maxConsecutiveFailures = 5;
|
|
3062
3282
|
this.lastAdRequestTime = 0;
|
|
3063
|
-
this.minAdRequestIntervalMs =
|
|
3283
|
+
this.minAdRequestIntervalMs = 3e3;
|
|
3064
3284
|
this.backoffBaseMs = 1e3;
|
|
3065
3285
|
this.maxBackoffMs = 15e3;
|
|
3286
|
+
this.globalConsecutiveNoFills = 0;
|
|
3287
|
+
this.globalNoFillThreshold = 3;
|
|
3288
|
+
this.globalNoFillCooldownUntil = 0;
|
|
3289
|
+
this.globalNoFillBackoffBaseMs = 5e3;
|
|
3290
|
+
this.globalNoFillBackoffMaxMs = 6e4;
|
|
3291
|
+
this.globalLastGamRequestTime = 0;
|
|
3292
|
+
this.globalMinGamIntervalMs = 3e3;
|
|
3066
3293
|
this.preloadPool = [];
|
|
3067
|
-
this.maxPreloadPoolSize =
|
|
3294
|
+
this.maxPreloadPoolSize = 2;
|
|
3068
3295
|
this.preloadPoolActive = false;
|
|
3069
3296
|
this.preloadPoolLoopRunning = false;
|
|
3297
|
+
this.adDetectSentForCurrentBreak = false;
|
|
3070
3298
|
this.continuousFetchLoopRunning = false;
|
|
3071
3299
|
initializePolyfills();
|
|
3072
3300
|
var browserOverrides = getBrowserConfigOverrides();
|
|
@@ -3207,7 +3435,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3207
3435
|
});
|
|
3208
3436
|
this.hls.on(import_hls2.default.Events.MANIFEST_PARSED, function(_, data) {
|
|
3209
3437
|
return _async_to_generator(function() {
|
|
3210
|
-
var
|
|
3438
|
+
var _this_config_minSegmentsBeforePlay, _ref, _this_hls_levels, _this_hls, adBehavior, minSegments, _this_video_play;
|
|
3211
3439
|
return _ts_generator(this, function(_state) {
|
|
3212
3440
|
switch(_state.label){
|
|
3213
3441
|
case 0:
|
|
@@ -3216,10 +3444,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3216
3444
|
} else {
|
|
3217
3445
|
;
|
|
3218
3446
|
;
|
|
3219
|
-
this.isLiveStream = (
|
|
3447
|
+
this.isLiveStream = (_ref = (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : (_this_hls_levels = _this_hls.levels) === null || _this_hls_levels === void 0 ? void 0 : _this_hls_levels.some(function(level) {
|
|
3220
3448
|
var _level_details, _level_details1;
|
|
3221
3449
|
return (level === null || level === void 0 ? void 0 : (_level_details = level.details) === null || _level_details === void 0 ? void 0 : _level_details.live) === true || (level === null || level === void 0 ? void 0 : (_level_details1 = level.details) === null || _level_details1 === void 0 ? void 0 : _level_details1.type) === "LIVE";
|
|
3222
|
-
})) !== null &&
|
|
3450
|
+
})) !== null && _ref !== void 0 ? _ref : false;
|
|
3223
3451
|
}
|
|
3224
3452
|
if (this.config.debugAdTiming) {
|
|
3225
3453
|
adBehavior = this.shouldContinueLiveStreamDuringAds() ? "live (main video continues muted during ads)" : "vod (main video pauses during ads)";
|
|
@@ -3283,9 +3511,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3283
3511
|
var tag = "";
|
|
3284
3512
|
var value = "";
|
|
3285
3513
|
if (Array.isArray(entry)) {
|
|
3286
|
-
var _entry_;
|
|
3514
|
+
var _entry_, _entry_1;
|
|
3287
3515
|
tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
|
|
3288
|
-
var _entry_1;
|
|
3289
3516
|
value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
|
|
3290
3517
|
} else if (typeof entry === "string") {
|
|
3291
3518
|
var idx = entry.indexOf(":");
|
|
@@ -3408,9 +3635,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3408
3635
|
var tag = "";
|
|
3409
3636
|
var value = "";
|
|
3410
3637
|
if (Array.isArray(entry)) {
|
|
3411
|
-
var _entry_;
|
|
3638
|
+
var _entry_, _entry_1;
|
|
3412
3639
|
tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
|
|
3413
|
-
var _entry_1;
|
|
3414
3640
|
value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
|
|
3415
3641
|
} else if (typeof entry === "string") {
|
|
3416
3642
|
var idx = entry.indexOf(":");
|
|
@@ -3460,10 +3686,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3460
3686
|
}
|
|
3461
3687
|
});
|
|
3462
3688
|
} else if (tag.includes("EXT-X-DATERANGE")) {
|
|
3689
|
+
var _attrs_CLASS;
|
|
3463
3690
|
var attrs = _this.parseAttributeList(value);
|
|
3464
3691
|
var hasScteOut = "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
3465
3692
|
var hasScteIn = "SCTE35-IN" in attrs || attrs["SCTE35-IN"] !== void 0;
|
|
3466
|
-
var _attrs_CLASS;
|
|
3467
3693
|
var klass = String((_attrs_CLASS = attrs["CLASS"]) !== null && _attrs_CLASS !== void 0 ? _attrs_CLASS : "");
|
|
3468
3694
|
var duration = _this.toNumber(attrs["DURATION"]);
|
|
3469
3695
|
if (hasScteOut || /com\.apple\.hls\.cue/i.test(klass)) {
|
|
@@ -3538,6 +3764,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3538
3764
|
value: function attachImaEventListeners() {
|
|
3539
3765
|
var _this = this;
|
|
3540
3766
|
this.ima.on("all_ads_completed", function() {
|
|
3767
|
+
sendAdImpressionTracking(_this.config.licenseKey, {
|
|
3768
|
+
adIndex: _this.currentAdIndex
|
|
3769
|
+
}, _this.config.adPlayerType).catch(function() {});
|
|
3541
3770
|
var remaining = _this.getRemainingAdMs();
|
|
3542
3771
|
_this.consecutiveFailures = 0;
|
|
3543
3772
|
if (_this.config.debugAdTiming) {
|
|
@@ -3577,6 +3806,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3577
3806
|
_this.clearAdRequestWatchdog();
|
|
3578
3807
|
_this.activeAdRequestToken = null;
|
|
3579
3808
|
_this.showAds = true;
|
|
3809
|
+
_this.resetGamNoFillCounter();
|
|
3580
3810
|
if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null) {
|
|
3581
3811
|
if (_this.adStopTimerId == null) {
|
|
3582
3812
|
_this.currentAdBreakStartWallClockMs = Date.now();
|
|
@@ -3599,6 +3829,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3599
3829
|
}
|
|
3600
3830
|
});
|
|
3601
3831
|
this.ima.on("content_resume", function() {
|
|
3832
|
+
sendAdImpressionTracking(_this.config.licenseKey, {
|
|
3833
|
+
adIndex: _this.currentAdIndex
|
|
3834
|
+
}, _this.config.adPlayerType).catch(function() {});
|
|
3602
3835
|
if (!_this.video.muted) {
|
|
3603
3836
|
_this.video.muted = true;
|
|
3604
3837
|
_this.video.volume = 0;
|
|
@@ -3865,11 +4098,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3865
4098
|
}
|
|
3866
4099
|
var daterangeMatch = text.match(/EXT-X-DATERANGE:([^\r\n]*)/i);
|
|
3867
4100
|
if (daterangeMatch) {
|
|
3868
|
-
var _daterangeMatch_;
|
|
4101
|
+
var _daterangeMatch_, _attrs_CLASS;
|
|
3869
4102
|
var attrs = this.parseAttributeList((_daterangeMatch_ = daterangeMatch[1]) !== null && _daterangeMatch_ !== void 0 ? _daterangeMatch_ : "");
|
|
3870
4103
|
var hasScteOut = "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
|
|
3871
4104
|
var hasScteIn = "SCTE35-IN" in attrs || attrs["SCTE35-IN"] !== void 0;
|
|
3872
|
-
var _attrs_CLASS;
|
|
3873
4105
|
var klass = String((_attrs_CLASS = attrs["CLASS"]) !== null && _attrs_CLASS !== void 0 ? _attrs_CLASS : "");
|
|
3874
4106
|
var duration = this.toNumber(attrs["DURATION"]);
|
|
3875
4107
|
if (hasScteOut || /com\.apple\.hls\.cue/i.test(klass)) {
|
|
@@ -3945,7 +4177,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3945
4177
|
var out = "";
|
|
3946
4178
|
for(var i = 0; i < value.length; i++)out += String.fromCharCode(value[i]);
|
|
3947
4179
|
return out;
|
|
3948
|
-
} catch (
|
|
4180
|
+
} catch (unused) {
|
|
3949
4181
|
return void 0;
|
|
3950
4182
|
}
|
|
3951
4183
|
}
|
|
@@ -3964,6 +4196,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3964
4196
|
});
|
|
3965
4197
|
}
|
|
3966
4198
|
if (marker.type === "start") {
|
|
4199
|
+
var _this_config_immediateManifestAds;
|
|
3967
4200
|
var _this_pendingAdBreak;
|
|
3968
4201
|
if (!this.video.muted) {
|
|
3969
4202
|
this.video.muted = true;
|
|
@@ -3982,13 +4215,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3982
4215
|
}
|
|
3983
4216
|
return;
|
|
3984
4217
|
}
|
|
4218
|
+
if (!this.adDetectSentForCurrentBreak) {
|
|
4219
|
+
this.adDetectSentForCurrentBreak = true;
|
|
4220
|
+
var detectPayload = {};
|
|
4221
|
+
if (marker.durationSeconds != null) detectPayload.durationSeconds = marker.durationSeconds;
|
|
4222
|
+
if (marker.ptsSeconds != null) detectPayload.ptsSeconds = marker.ptsSeconds;
|
|
4223
|
+
sendAdDetectTracking(this.config.licenseKey, detectPayload).catch(function() {});
|
|
4224
|
+
}
|
|
3985
4225
|
var hasPrefetchedAds = this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0;
|
|
3986
4226
|
this.inAdBreak = true;
|
|
3987
4227
|
var durationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : ((_this_pendingAdBreak = this.pendingAdBreak) === null || _this_pendingAdBreak === void 0 ? void 0 : _this_pendingAdBreak.marker.durationSeconds) != null ? this.pendingAdBreak.marker.durationSeconds * 1e3 : void 0;
|
|
3988
4228
|
this.expectedAdBreakDurationMs = durationMs;
|
|
3989
4229
|
this.currentAdBreakStartWallClockMs = Date.now();
|
|
3990
4230
|
var isManifestMarker = this.isManifestBasedMarker(marker);
|
|
3991
|
-
var _this_config_immediateManifestAds;
|
|
3992
4231
|
var forceImmediate = (_this_config_immediateManifestAds = this.config.immediateManifestAds) !== null && _this_config_immediateManifestAds !== void 0 ? _this_config_immediateManifestAds : true;
|
|
3993
4232
|
if (this.config.debugAdTiming) {
|
|
3994
4233
|
console.log("[StormcloudVideoPlayer] Ad start decision:", {
|
|
@@ -4143,9 +4382,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4143
4382
|
var regex = /([A-Z0-9-]+)=(("[^"]*")|([^",]*))(?:,|$)/gi;
|
|
4144
4383
|
var match;
|
|
4145
4384
|
while((match = regex.exec(value)) !== null){
|
|
4146
|
-
var _match_;
|
|
4385
|
+
var _match_, _ref, _match_1;
|
|
4147
4386
|
var key = (_match_ = match[1]) !== null && _match_ !== void 0 ? _match_ : "";
|
|
4148
|
-
var _match_1, _ref;
|
|
4149
4387
|
var rawVal = (_ref = (_match_1 = match[3]) !== null && _match_1 !== void 0 ? _match_1 : match[4]) !== null && _ref !== void 0 ? _ref : "";
|
|
4150
4388
|
if (rawVal.startsWith('"') && rawVal.endsWith('"')) {
|
|
4151
4389
|
rawVal = rawVal.slice(1, -1);
|
|
@@ -4490,13 +4728,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4490
4728
|
{
|
|
4491
4729
|
key: "shouldShowNativeControls",
|
|
4492
4730
|
value: function shouldShowNativeControls() {
|
|
4731
|
+
var _this_config_showCustomControls;
|
|
4493
4732
|
var streamType = this.getStreamType();
|
|
4494
4733
|
if (streamType === "other") {
|
|
4495
|
-
var
|
|
4496
|
-
return !((
|
|
4734
|
+
var _this_config_showCustomControls1;
|
|
4735
|
+
return !((_this_config_showCustomControls1 = this.config.showCustomControls) !== null && _this_config_showCustomControls1 !== void 0 ? _this_config_showCustomControls1 : false);
|
|
4497
4736
|
}
|
|
4498
|
-
|
|
4499
|
-
return !!(this.config.allowNativeHls && !((_this_config_showCustomControls1 = this.config.showCustomControls) !== null && _this_config_showCustomControls1 !== void 0 ? _this_config_showCustomControls1 : false));
|
|
4737
|
+
return !!(this.config.allowNativeHls && !((_this_config_showCustomControls = this.config.showCustomControls) !== null && _this_config_showCustomControls !== void 0 ? _this_config_showCustomControls : false));
|
|
4500
4738
|
}
|
|
4501
4739
|
},
|
|
4502
4740
|
{
|
|
@@ -4541,6 +4779,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4541
4779
|
isFetching: false,
|
|
4542
4780
|
fetchStartTime: Date.now()
|
|
4543
4781
|
});
|
|
4782
|
+
this.adDetectSentForCurrentBreak = true;
|
|
4783
|
+
var detectPayload = {};
|
|
4784
|
+
if (marker.durationSeconds != null) detectPayload.durationSeconds = marker.durationSeconds;
|
|
4785
|
+
if (marker.ptsSeconds != null) detectPayload.ptsSeconds = marker.ptsSeconds;
|
|
4786
|
+
if (fragmentSn !== void 0) detectPayload.detectedAtFragmentSn = fragmentSn;
|
|
4787
|
+
sendAdDetectTracking(this.config.licenseKey, detectPayload).catch(function() {});
|
|
4544
4788
|
if (this.config.debugAdTiming) {
|
|
4545
4789
|
console.log("[PREFETCH] \uD83D\uDD04 Starting ad prefetch for upcoming ad break");
|
|
4546
4790
|
console.log("[PREFETCH] \uD83D\uDCCB Pre-generated ".concat(generatedUrls.length, " VAST URLs"));
|
|
@@ -4604,6 +4848,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4604
4848
|
var _this, loadPromise;
|
|
4605
4849
|
return _ts_generator(this, function(_state) {
|
|
4606
4850
|
_this = this;
|
|
4851
|
+
if (this.isGamInCooldown()) {
|
|
4852
|
+
if (this.config.debugAdTiming) {
|
|
4853
|
+
console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
|
|
4854
|
+
}
|
|
4855
|
+
return [
|
|
4856
|
+
2
|
|
4857
|
+
];
|
|
4858
|
+
}
|
|
4607
4859
|
if (this.preloadPool.some(function(entry) {
|
|
4608
4860
|
return entry.vastUrl === vastUrl;
|
|
4609
4861
|
}) || this.failedVastUrls.has(vastUrl) || this.isUrlInCooldown(vastUrl)) {
|
|
@@ -4633,26 +4885,32 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4633
4885
|
case 1:
|
|
4634
4886
|
_state.trys.push([
|
|
4635
4887
|
1,
|
|
4636
|
-
|
|
4888
|
+
5,
|
|
4637
4889
|
,
|
|
4638
|
-
|
|
4890
|
+
6
|
|
4639
4891
|
]);
|
|
4640
4892
|
continueLiveStreamDuringAds = this.shouldContinueLiveStreamDuringAds();
|
|
4641
4893
|
preloadIma = this.createAdPlayer(continueLiveStreamDuringAds);
|
|
4642
4894
|
preloadIma.initialize();
|
|
4643
|
-
errorListener = function(payload) {
|
|
4895
|
+
errorListener = function errorListener(payload) {
|
|
4644
4896
|
hasAdError = true;
|
|
4645
4897
|
adErrorPayload = payload;
|
|
4646
4898
|
};
|
|
4647
4899
|
preloadIma.on("ad_error", errorListener);
|
|
4648
|
-
errorListenerCleanup = function() {
|
|
4900
|
+
errorListenerCleanup = function errorListenerCleanup() {
|
|
4649
4901
|
return preloadIma.off("ad_error", errorListener);
|
|
4650
4902
|
};
|
|
4651
4903
|
return [
|
|
4652
4904
|
4,
|
|
4653
|
-
|
|
4905
|
+
this.enforceGlobalRateLimit()
|
|
4654
4906
|
];
|
|
4655
4907
|
case 2:
|
|
4908
|
+
_state.sent();
|
|
4909
|
+
return [
|
|
4910
|
+
4,
|
|
4911
|
+
preloadIma.requestAds(vastUrl)
|
|
4912
|
+
];
|
|
4913
|
+
case 3:
|
|
4656
4914
|
_state.sent();
|
|
4657
4915
|
preloadIma.pause();
|
|
4658
4916
|
return [
|
|
@@ -4661,7 +4919,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4661
4919
|
return setTimeout(resolve, 1500);
|
|
4662
4920
|
})
|
|
4663
4921
|
];
|
|
4664
|
-
case
|
|
4922
|
+
case 4:
|
|
4665
4923
|
_state.sent();
|
|
4666
4924
|
preloadIma.pause();
|
|
4667
4925
|
if (hasAdError) {
|
|
@@ -4670,6 +4928,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4670
4928
|
errorListenerCleanup();
|
|
4671
4929
|
}
|
|
4672
4930
|
preloadIma.destroy();
|
|
4931
|
+
this.recordGamNoFill();
|
|
4673
4932
|
if (isNoFill) {
|
|
4674
4933
|
if (this.config.debugAdTiming) {
|
|
4675
4934
|
console.log("[PRELOAD-POOL] ⚠️ Ad preload returned no-fill: ".concat(vastUrl));
|
|
@@ -4696,7 +4955,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4696
4955
|
isReady: true,
|
|
4697
4956
|
loadPromise: Promise.resolve()
|
|
4698
4957
|
};
|
|
4699
|
-
lateErrorListener = function(payload) {
|
|
4958
|
+
lateErrorListener = function lateErrorListener(payload) {
|
|
4700
4959
|
var index = _this.preloadPool.findIndex(function(entry) {
|
|
4701
4960
|
return entry.vastUrl === vastUrl;
|
|
4702
4961
|
});
|
|
@@ -4707,7 +4966,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4707
4966
|
}
|
|
4708
4967
|
try {
|
|
4709
4968
|
preloadIma.destroy();
|
|
4710
|
-
} catch (
|
|
4969
|
+
} catch (unused) {}
|
|
4711
4970
|
}
|
|
4712
4971
|
};
|
|
4713
4972
|
preloadIma.on("ad_error", lateErrorListener);
|
|
@@ -4720,13 +4979,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4720
4979
|
}
|
|
4721
4980
|
return [
|
|
4722
4981
|
3,
|
|
4723
|
-
|
|
4982
|
+
6
|
|
4724
4983
|
];
|
|
4725
|
-
case
|
|
4984
|
+
case 5:
|
|
4726
4985
|
error = _state.sent();
|
|
4727
4986
|
if (errorListenerCleanup) {
|
|
4728
4987
|
errorListenerCleanup();
|
|
4729
4988
|
}
|
|
4989
|
+
this.recordGamNoFill();
|
|
4730
4990
|
if (this.config.debugAdTiming) {
|
|
4731
4991
|
console.warn("[PRELOAD-POOL] ⚠️ Failed to preload ad: ".concat(vastUrl), error);
|
|
4732
4992
|
}
|
|
@@ -4737,9 +4997,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4737
4997
|
}
|
|
4738
4998
|
return [
|
|
4739
4999
|
3,
|
|
4740
|
-
|
|
5000
|
+
6
|
|
4741
5001
|
];
|
|
4742
|
-
case
|
|
5002
|
+
case 6:
|
|
4743
5003
|
return [
|
|
4744
5004
|
2
|
|
4745
5005
|
];
|
|
@@ -4778,6 +5038,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4778
5038
|
3,
|
|
4779
5039
|
10
|
|
4780
5040
|
];
|
|
5041
|
+
if (this.isGamInCooldown()) {
|
|
5042
|
+
if (this.config.debugAdTiming) {
|
|
5043
|
+
console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
|
|
5044
|
+
}
|
|
5045
|
+
return [
|
|
5046
|
+
3,
|
|
5047
|
+
10
|
|
5048
|
+
];
|
|
5049
|
+
}
|
|
4781
5050
|
if (!(!this.inAdBreak && this.preloadPool.length >= this.maxPreloadPoolSize)) return [
|
|
4782
5051
|
3,
|
|
4783
5052
|
3
|
|
@@ -4810,7 +5079,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4810
5079
|
3,
|
|
4811
5080
|
8
|
|
4812
5081
|
];
|
|
4813
|
-
if (!this.preloadPoolActive) {
|
|
5082
|
+
if (!this.preloadPoolActive || this.isGamInCooldown()) {
|
|
4814
5083
|
return [
|
|
4815
5084
|
3,
|
|
4816
5085
|
8
|
|
@@ -4991,6 +5260,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4991
5260
|
firstAdUrl = preloaded.vastUrl;
|
|
4992
5261
|
preloadedController = preloaded.imaController;
|
|
4993
5262
|
usePreloadedAd = true;
|
|
5263
|
+
sendAdLoadedTracking(this.config.licenseKey, {
|
|
5264
|
+
source: "preload",
|
|
5265
|
+
vastUrl: firstAdUrl
|
|
5266
|
+
}, this.config.adPlayerType).catch(function() {});
|
|
4994
5267
|
if (this.config.debugAdTiming) {
|
|
4995
5268
|
console.log("[CONTINUOUS-FETCH] \uD83D\uDE80 Using preloaded ad from pool (preloaded in advance, ready immediately!)");
|
|
4996
5269
|
console.log("[CONTINUOUS-FETCH] Pool still has ".concat(this.preloadPool.length, " preloaded ads ready"));
|
|
@@ -5026,9 +5299,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5026
5299
|
case 1:
|
|
5027
5300
|
_state.trys.push([
|
|
5028
5301
|
1,
|
|
5029
|
-
|
|
5302
|
+
8,
|
|
5030
5303
|
,
|
|
5031
|
-
|
|
5304
|
+
14
|
|
5032
5305
|
]);
|
|
5033
5306
|
if (!(usePreloadedAd && preloadedController)) return [
|
|
5034
5307
|
3,
|
|
@@ -5064,16 +5337,26 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5064
5337
|
this.ima.setAdVolume(adVolume);
|
|
5065
5338
|
return [
|
|
5066
5339
|
3,
|
|
5067
|
-
|
|
5340
|
+
7
|
|
5068
5341
|
];
|
|
5069
5342
|
case 3:
|
|
5343
|
+
return [
|
|
5344
|
+
4,
|
|
5345
|
+
this.enforceGlobalRateLimit()
|
|
5346
|
+
];
|
|
5347
|
+
case 4:
|
|
5348
|
+
_state.sent();
|
|
5070
5349
|
this.lastAdRequestTime = Date.now();
|
|
5071
5350
|
return [
|
|
5072
5351
|
4,
|
|
5073
5352
|
this.ima.requestAds(firstAdUrl)
|
|
5074
5353
|
];
|
|
5075
|
-
case
|
|
5354
|
+
case 5:
|
|
5076
5355
|
_state.sent();
|
|
5356
|
+
sendAdLoadedTracking(this.config.licenseKey, {
|
|
5357
|
+
source: "ssp",
|
|
5358
|
+
vastUrl: firstAdUrl
|
|
5359
|
+
}, this.config.adPlayerType).catch(function() {});
|
|
5077
5360
|
if (this.config.debugAdTiming) {
|
|
5078
5361
|
console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
|
|
5079
5362
|
}
|
|
@@ -5087,7 +5370,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5087
5370
|
4,
|
|
5088
5371
|
this.ima.play()
|
|
5089
5372
|
];
|
|
5090
|
-
case
|
|
5373
|
+
case 6:
|
|
5091
5374
|
_state.sent();
|
|
5092
5375
|
if (this.expectedAdBreakDurationMs != null) {
|
|
5093
5376
|
this.currentAdBreakStartWallClockMs = Date.now();
|
|
@@ -5095,36 +5378,36 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5095
5378
|
}
|
|
5096
5379
|
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
5097
5380
|
this.ima.setAdVolume(adVolume1);
|
|
5098
|
-
_state.label =
|
|
5099
|
-
case
|
|
5381
|
+
_state.label = 7;
|
|
5382
|
+
case 7:
|
|
5100
5383
|
return [
|
|
5101
5384
|
3,
|
|
5102
|
-
|
|
5385
|
+
14
|
|
5103
5386
|
];
|
|
5104
|
-
case
|
|
5387
|
+
case 8:
|
|
5105
5388
|
error = _state.sent();
|
|
5106
5389
|
if (this.config.debugAdTiming) {
|
|
5107
5390
|
console.warn("[CONTINUOUS-FETCH] \u26A0\uFE0F First ad request failed:", error);
|
|
5108
5391
|
}
|
|
5109
5392
|
if (!!usePreloadedAd) return [
|
|
5110
5393
|
3,
|
|
5111
|
-
|
|
5394
|
+
12
|
|
5112
5395
|
];
|
|
5113
5396
|
fallbackPreloaded = this.getPreloadedAd();
|
|
5114
5397
|
if (!fallbackPreloaded) return [
|
|
5115
5398
|
3,
|
|
5116
|
-
|
|
5399
|
+
12
|
|
5117
5400
|
];
|
|
5118
5401
|
if (this.config.debugAdTiming) {
|
|
5119
5402
|
console.log("[CONTINUOUS-FETCH] \uD83D\uDD04 First ad failed, using preloaded fallback");
|
|
5120
5403
|
}
|
|
5121
|
-
_state.label =
|
|
5122
|
-
case
|
|
5404
|
+
_state.label = 9;
|
|
5405
|
+
case 9:
|
|
5123
5406
|
_state.trys.push([
|
|
5124
|
-
|
|
5125
|
-
|
|
5407
|
+
9,
|
|
5408
|
+
11,
|
|
5126
5409
|
,
|
|
5127
|
-
|
|
5410
|
+
12
|
|
5128
5411
|
]);
|
|
5129
5412
|
this.ima.destroy();
|
|
5130
5413
|
this.video.muted = true;
|
|
@@ -5143,7 +5426,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5143
5426
|
4,
|
|
5144
5427
|
this.ima.play()
|
|
5145
5428
|
];
|
|
5146
|
-
case
|
|
5429
|
+
case 10:
|
|
5147
5430
|
_state.sent();
|
|
5148
5431
|
if (this.expectedAdBreakDurationMs != null) {
|
|
5149
5432
|
this.currentAdBreakStartWallClockMs = Date.now();
|
|
@@ -5154,16 +5437,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5154
5437
|
return [
|
|
5155
5438
|
2
|
|
5156
5439
|
];
|
|
5157
|
-
case
|
|
5440
|
+
case 11:
|
|
5158
5441
|
fallbackError = _state.sent();
|
|
5159
5442
|
if (this.config.debugAdTiming) {
|
|
5160
5443
|
console.warn("[CONTINUOUS-FETCH] \u26A0\uFE0F Preloaded fallback also failed:", fallbackError);
|
|
5161
5444
|
}
|
|
5162
5445
|
return [
|
|
5163
5446
|
3,
|
|
5164
|
-
|
|
5447
|
+
12
|
|
5165
5448
|
];
|
|
5166
|
-
case
|
|
5449
|
+
case 12:
|
|
5167
5450
|
if (this.isTemporaryAdError(error)) {
|
|
5168
5451
|
this.temporaryFailureUrls.set(firstAdUrl, Date.now());
|
|
5169
5452
|
if (this.config.debugAdTiming) {
|
|
@@ -5181,13 +5464,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5181
5464
|
4,
|
|
5182
5465
|
this.tryNextAvailableAdWithRateLimit()
|
|
5183
5466
|
];
|
|
5184
|
-
case
|
|
5467
|
+
case 13:
|
|
5185
5468
|
_state.sent();
|
|
5186
5469
|
return [
|
|
5187
5470
|
3,
|
|
5188
|
-
|
|
5471
|
+
14
|
|
5189
5472
|
];
|
|
5190
|
-
case
|
|
5473
|
+
case 14:
|
|
5191
5474
|
return [
|
|
5192
5475
|
2
|
|
5193
5476
|
];
|
|
@@ -5238,6 +5521,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5238
5521
|
"break"
|
|
5239
5522
|
];
|
|
5240
5523
|
}
|
|
5524
|
+
if (_this.isGamInCooldown()) {
|
|
5525
|
+
if (_this.config.debugAdTiming) {
|
|
5526
|
+
console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping URL generation");
|
|
5527
|
+
}
|
|
5528
|
+
return [
|
|
5529
|
+
2,
|
|
5530
|
+
"break"
|
|
5531
|
+
];
|
|
5532
|
+
}
|
|
5241
5533
|
if (_this.consecutiveFailures >= _this.maxConsecutiveFailures) {
|
|
5242
5534
|
if (_this.config.debugAdTiming) {
|
|
5243
5535
|
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive failures (".concat(_this.consecutiveFailures, "), stopping URL generation"));
|
|
@@ -5434,6 +5726,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5434
5726
|
2
|
|
5435
5727
|
];
|
|
5436
5728
|
}
|
|
5729
|
+
if (this.isGamInCooldown()) {
|
|
5730
|
+
if (this.config.debugAdTiming) {
|
|
5731
|
+
console.log("[CIRCUIT-BREAKER] GAM in cooldown, ending ad break gracefully");
|
|
5732
|
+
}
|
|
5733
|
+
this.handleAdPodComplete();
|
|
5734
|
+
return [
|
|
5735
|
+
2
|
|
5736
|
+
];
|
|
5737
|
+
}
|
|
5437
5738
|
if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
|
|
5438
5739
|
if (this.config.debugAdTiming) {
|
|
5439
5740
|
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive failures (".concat(this.consecutiveFailures, "), ending ad break"));
|
|
@@ -5452,6 +5753,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5452
5753
|
if (this.config.debugAdTiming) {
|
|
5453
5754
|
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAF Using preloaded ad from pool (".concat(this.preloadPool.length, " remaining in pool)"));
|
|
5454
5755
|
}
|
|
5756
|
+
sendAdLoadedTracking(this.config.licenseKey, {
|
|
5757
|
+
source: "preload",
|
|
5758
|
+
vastUrl: preloaded.vastUrl
|
|
5759
|
+
}, this.config.adPlayerType).catch(function() {});
|
|
5455
5760
|
_state.label = 1;
|
|
5456
5761
|
case 1:
|
|
5457
5762
|
_state.trys.push([
|
|
@@ -5630,6 +5935,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5630
5935
|
case 0:
|
|
5631
5936
|
remaining = this.getRemainingAdMs();
|
|
5632
5937
|
waitTime = Math.min(this.maxPlaceholderDurationMs, remaining);
|
|
5938
|
+
if (this.isGamInCooldown()) {
|
|
5939
|
+
if (this.config.debugAdTiming) {
|
|
5940
|
+
console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping placeholder wait");
|
|
5941
|
+
}
|
|
5942
|
+
this.handleAdPodComplete();
|
|
5943
|
+
return [
|
|
5944
|
+
2
|
|
5945
|
+
];
|
|
5946
|
+
}
|
|
5633
5947
|
if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
|
|
5634
5948
|
if (this.config.debugAdTiming) {
|
|
5635
5949
|
console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Skipping placeholder - too many consecutive failures");
|
|
@@ -5893,11 +6207,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5893
6207
|
{
|
|
5894
6208
|
key: "ensureAdStoppedByTimer",
|
|
5895
6209
|
value: function ensureAdStoppedByTimer() {
|
|
6210
|
+
var _this_config_adBreakCheckIntervalMs, _this_expectedAdBreakDurationMs;
|
|
5896
6211
|
if (!this.inAdBreak) return;
|
|
5897
6212
|
this.adStopTimerId = void 0;
|
|
5898
6213
|
var adPlaying = this.ima.isAdPlaying();
|
|
5899
6214
|
var pendingAds = this.adPodQueue.length > 0;
|
|
5900
|
-
var _this_config_adBreakCheckIntervalMs;
|
|
5901
6215
|
var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
|
|
5902
6216
|
var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
|
|
5903
6217
|
var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 6e4;
|
|
@@ -5905,7 +6219,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5905
6219
|
if (this.currentAdBreakStartWallClockMs != null) {
|
|
5906
6220
|
elapsedSinceStartMs = Date.now() - this.currentAdBreakStartWallClockMs;
|
|
5907
6221
|
}
|
|
5908
|
-
var _this_expectedAdBreakDurationMs;
|
|
5909
6222
|
var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
|
|
5910
6223
|
var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
|
|
5911
6224
|
var shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
|
|
@@ -6019,6 +6332,73 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6019
6332
|
}
|
|
6020
6333
|
}
|
|
6021
6334
|
},
|
|
6335
|
+
{
|
|
6336
|
+
key: "isGamInCooldown",
|
|
6337
|
+
value: function isGamInCooldown() {
|
|
6338
|
+
return Date.now() < this.globalNoFillCooldownUntil;
|
|
6339
|
+
}
|
|
6340
|
+
},
|
|
6341
|
+
{
|
|
6342
|
+
key: "recordGamNoFill",
|
|
6343
|
+
value: function recordGamNoFill() {
|
|
6344
|
+
this.globalConsecutiveNoFills++;
|
|
6345
|
+
if (this.globalConsecutiveNoFills >= this.globalNoFillThreshold) {
|
|
6346
|
+
var exponent = this.globalConsecutiveNoFills - this.globalNoFillThreshold;
|
|
6347
|
+
var backoff = Math.min(this.globalNoFillBackoffBaseMs * Math.pow(2, exponent), this.globalNoFillBackoffMaxMs);
|
|
6348
|
+
this.globalNoFillCooldownUntil = Date.now() + backoff;
|
|
6349
|
+
if (this.config.debugAdTiming) {
|
|
6350
|
+
console.log("[CIRCUIT-BREAKER] GAM cooldown activated: ".concat(backoff, "ms (").concat(this.globalConsecutiveNoFills, " consecutive no-fills)"));
|
|
6351
|
+
}
|
|
6352
|
+
}
|
|
6353
|
+
}
|
|
6354
|
+
},
|
|
6355
|
+
{
|
|
6356
|
+
key: "resetGamNoFillCounter",
|
|
6357
|
+
value: function resetGamNoFillCounter() {
|
|
6358
|
+
if (this.globalConsecutiveNoFills > 0 && this.config.debugAdTiming) {
|
|
6359
|
+
console.log("[CIRCUIT-BREAKER] Resetting no-fill counter (was ".concat(this.globalConsecutiveNoFills, ")"));
|
|
6360
|
+
}
|
|
6361
|
+
this.globalConsecutiveNoFills = 0;
|
|
6362
|
+
this.globalNoFillCooldownUntil = 0;
|
|
6363
|
+
}
|
|
6364
|
+
},
|
|
6365
|
+
{
|
|
6366
|
+
key: "enforceGlobalRateLimit",
|
|
6367
|
+
value: function enforceGlobalRateLimit() {
|
|
6368
|
+
return _async_to_generator(function() {
|
|
6369
|
+
var now, elapsed, waitMs;
|
|
6370
|
+
return _ts_generator(this, function(_state) {
|
|
6371
|
+
switch(_state.label){
|
|
6372
|
+
case 0:
|
|
6373
|
+
now = Date.now();
|
|
6374
|
+
elapsed = now - this.globalLastGamRequestTime;
|
|
6375
|
+
if (!(elapsed < this.globalMinGamIntervalMs)) return [
|
|
6376
|
+
3,
|
|
6377
|
+
2
|
|
6378
|
+
];
|
|
6379
|
+
waitMs = this.globalMinGamIntervalMs - elapsed;
|
|
6380
|
+
if (this.config.debugAdTiming) {
|
|
6381
|
+
console.log("[RATE-LIMIT] Waiting ".concat(waitMs, "ms before next GAM request"));
|
|
6382
|
+
}
|
|
6383
|
+
return [
|
|
6384
|
+
4,
|
|
6385
|
+
new Promise(function(resolve) {
|
|
6386
|
+
return setTimeout(resolve, waitMs);
|
|
6387
|
+
})
|
|
6388
|
+
];
|
|
6389
|
+
case 1:
|
|
6390
|
+
_state.sent();
|
|
6391
|
+
_state.label = 2;
|
|
6392
|
+
case 2:
|
|
6393
|
+
this.globalLastGamRequestTime = Date.now();
|
|
6394
|
+
return [
|
|
6395
|
+
2
|
|
6396
|
+
];
|
|
6397
|
+
}
|
|
6398
|
+
});
|
|
6399
|
+
}).call(this);
|
|
6400
|
+
}
|
|
6401
|
+
},
|
|
6022
6402
|
{
|
|
6023
6403
|
key: "playSingleAd",
|
|
6024
6404
|
value: function playSingleAd(vastTagUrl) {
|
|
@@ -6050,6 +6430,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6050
6430
|
}
|
|
6051
6431
|
throw new Error("Too many consecutive failures");
|
|
6052
6432
|
}
|
|
6433
|
+
if (this.isGamInCooldown()) {
|
|
6434
|
+
if (this.config.debugAdTiming) {
|
|
6435
|
+
console.warn("[CIRCUIT-BREAKER] GAM in cooldown, skipping ad request");
|
|
6436
|
+
}
|
|
6437
|
+
throw new Error("GAM in cooldown");
|
|
6438
|
+
}
|
|
6053
6439
|
this.recreateImaController();
|
|
6054
6440
|
requestToken = ++this.adRequestTokenCounter;
|
|
6055
6441
|
this.activeAdRequestToken = requestToken;
|
|
@@ -6058,37 +6444,47 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6058
6444
|
case 1:
|
|
6059
6445
|
_state.trys.push([
|
|
6060
6446
|
1,
|
|
6061
|
-
|
|
6447
|
+
12,
|
|
6062
6448
|
,
|
|
6063
|
-
|
|
6449
|
+
17
|
|
6064
6450
|
]);
|
|
6451
|
+
return [
|
|
6452
|
+
4,
|
|
6453
|
+
this.enforceGlobalRateLimit()
|
|
6454
|
+
];
|
|
6455
|
+
case 2:
|
|
6456
|
+
_state.sent();
|
|
6065
6457
|
this.lastAdRequestTime = Date.now();
|
|
6066
6458
|
return [
|
|
6067
6459
|
4,
|
|
6068
6460
|
this.ima.requestAds(vastTagUrl)
|
|
6069
6461
|
];
|
|
6070
|
-
case
|
|
6462
|
+
case 3:
|
|
6071
6463
|
_state.sent();
|
|
6464
|
+
sendAdLoadedTracking(this.config.licenseKey, {
|
|
6465
|
+
source: "ssp",
|
|
6466
|
+
vastUrl: vastTagUrl
|
|
6467
|
+
}, this.config.adPlayerType).catch(function() {});
|
|
6072
6468
|
this.clearAdRequestWatchdog();
|
|
6073
6469
|
if (this.activeAdRequestToken !== requestToken) {
|
|
6074
6470
|
return [
|
|
6075
6471
|
2
|
|
6076
6472
|
];
|
|
6077
6473
|
}
|
|
6078
|
-
_state.label =
|
|
6079
|
-
case
|
|
6474
|
+
_state.label = 4;
|
|
6475
|
+
case 4:
|
|
6080
6476
|
_state.trys.push([
|
|
6081
|
-
|
|
6082
|
-
|
|
6477
|
+
4,
|
|
6478
|
+
6,
|
|
6083
6479
|
,
|
|
6084
|
-
|
|
6480
|
+
11
|
|
6085
6481
|
]);
|
|
6086
6482
|
this.startAdFailsafeTimer(requestToken);
|
|
6087
6483
|
return [
|
|
6088
6484
|
4,
|
|
6089
6485
|
this.ima.play()
|
|
6090
6486
|
];
|
|
6091
|
-
case
|
|
6487
|
+
case 5:
|
|
6092
6488
|
_state.sent();
|
|
6093
6489
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6094
6490
|
this.currentAdBreakStartWallClockMs = Date.now();
|
|
@@ -6102,9 +6498,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6102
6498
|
this.temporaryFailureUrls.delete(vastTagUrl);
|
|
6103
6499
|
return [
|
|
6104
6500
|
3,
|
|
6105
|
-
|
|
6501
|
+
11
|
|
6106
6502
|
];
|
|
6107
|
-
case
|
|
6503
|
+
case 6:
|
|
6108
6504
|
playError = _state.sent();
|
|
6109
6505
|
if (this.config.debugAdTiming) {
|
|
6110
6506
|
console.error("[AD-ERROR] Failed to play ad:", playError);
|
|
@@ -6112,18 +6508,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6112
6508
|
preloadedFallback = this.getPreloadedAd();
|
|
6113
6509
|
if (!preloadedFallback) return [
|
|
6114
6510
|
3,
|
|
6115
|
-
|
|
6511
|
+
10
|
|
6116
6512
|
];
|
|
6117
6513
|
if (this.config.debugAdTiming) {
|
|
6118
6514
|
console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
|
|
6119
6515
|
}
|
|
6120
|
-
_state.label =
|
|
6121
|
-
case
|
|
6516
|
+
_state.label = 7;
|
|
6517
|
+
case 7:
|
|
6122
6518
|
_state.trys.push([
|
|
6123
|
-
|
|
6124
|
-
|
|
6519
|
+
7,
|
|
6520
|
+
9,
|
|
6125
6521
|
,
|
|
6126
|
-
|
|
6522
|
+
10
|
|
6127
6523
|
]);
|
|
6128
6524
|
this.clearAdFailsafeTimer();
|
|
6129
6525
|
this.ima.destroy();
|
|
@@ -6139,7 +6535,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6139
6535
|
4,
|
|
6140
6536
|
this.ima.play()
|
|
6141
6537
|
];
|
|
6142
|
-
case
|
|
6538
|
+
case 8:
|
|
6143
6539
|
_state.sent();
|
|
6144
6540
|
if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
|
|
6145
6541
|
this.currentAdBreakStartWallClockMs = Date.now();
|
|
@@ -6152,16 +6548,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6152
6548
|
return [
|
|
6153
6549
|
2
|
|
6154
6550
|
];
|
|
6155
|
-
case
|
|
6551
|
+
case 9:
|
|
6156
6552
|
fallbackError = _state.sent();
|
|
6157
6553
|
if (this.config.debugAdTiming) {
|
|
6158
6554
|
console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
|
|
6159
6555
|
}
|
|
6160
6556
|
return [
|
|
6161
6557
|
3,
|
|
6162
|
-
|
|
6558
|
+
10
|
|
6163
6559
|
];
|
|
6164
|
-
case
|
|
6560
|
+
case 10:
|
|
6165
6561
|
if (this.isTemporaryAdError(playError)) {
|
|
6166
6562
|
this.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
6167
6563
|
if (this.config.debugAdTiming) {
|
|
@@ -6178,12 +6574,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6178
6574
|
this.activeAdRequestToken = null;
|
|
6179
6575
|
}
|
|
6180
6576
|
throw playError;
|
|
6181
|
-
case
|
|
6577
|
+
case 11:
|
|
6182
6578
|
return [
|
|
6183
6579
|
3,
|
|
6184
|
-
|
|
6580
|
+
17
|
|
6185
6581
|
];
|
|
6186
|
-
case
|
|
6582
|
+
case 12:
|
|
6187
6583
|
error = _state.sent();
|
|
6188
6584
|
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
6189
6585
|
if (this.config.debugAdTiming) {
|
|
@@ -6192,18 +6588,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6192
6588
|
preloadedFallback1 = this.getPreloadedAd();
|
|
6193
6589
|
if (!preloadedFallback1) return [
|
|
6194
6590
|
3,
|
|
6195
|
-
|
|
6591
|
+
16
|
|
6196
6592
|
];
|
|
6197
6593
|
if (this.config.debugAdTiming) {
|
|
6198
6594
|
console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
|
|
6199
6595
|
}
|
|
6200
|
-
_state.label =
|
|
6201
|
-
case
|
|
6596
|
+
_state.label = 13;
|
|
6597
|
+
case 13:
|
|
6202
6598
|
_state.trys.push([
|
|
6203
|
-
|
|
6204
|
-
|
|
6599
|
+
13,
|
|
6600
|
+
15,
|
|
6205
6601
|
,
|
|
6206
|
-
|
|
6602
|
+
16
|
|
6207
6603
|
]);
|
|
6208
6604
|
this.clearAdRequestWatchdog();
|
|
6209
6605
|
this.clearAdFailsafeTimer();
|
|
@@ -6220,7 +6616,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6220
6616
|
4,
|
|
6221
6617
|
this.ima.play()
|
|
6222
6618
|
];
|
|
6223
|
-
case
|
|
6619
|
+
case 14:
|
|
6224
6620
|
_state.sent();
|
|
6225
6621
|
currentMuted2 = this.video.muted;
|
|
6226
6622
|
currentVolume2 = this.video.volume;
|
|
@@ -6229,16 +6625,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6229
6625
|
return [
|
|
6230
6626
|
2
|
|
6231
6627
|
];
|
|
6232
|
-
case
|
|
6628
|
+
case 15:
|
|
6233
6629
|
fallbackError1 = _state.sent();
|
|
6234
6630
|
if (this.config.debugAdTiming) {
|
|
6235
6631
|
console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
|
|
6236
6632
|
}
|
|
6237
6633
|
return [
|
|
6238
6634
|
3,
|
|
6239
|
-
|
|
6635
|
+
16
|
|
6240
6636
|
];
|
|
6241
|
-
case
|
|
6637
|
+
case 16:
|
|
6242
6638
|
if (this.isTemporaryAdError(error)) {
|
|
6243
6639
|
this.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
6244
6640
|
if (this.config.debugAdTiming) {
|
|
@@ -6256,7 +6652,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6256
6652
|
this.activeAdRequestToken = null;
|
|
6257
6653
|
}
|
|
6258
6654
|
throw error;
|
|
6259
|
-
case
|
|
6655
|
+
case 17:
|
|
6260
6656
|
return [
|
|
6261
6657
|
2
|
|
6262
6658
|
];
|
|
@@ -6283,6 +6679,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6283
6679
|
}
|
|
6284
6680
|
this.adRequestQueue = [];
|
|
6285
6681
|
this.inAdBreak = false;
|
|
6682
|
+
this.adDetectSentForCurrentBreak = false;
|
|
6286
6683
|
this.expectedAdBreakDurationMs = void 0;
|
|
6287
6684
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
6288
6685
|
this.clearAdStartTimer();
|
|
@@ -6292,6 +6689,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6292
6689
|
this.currentAdIndex = 0;
|
|
6293
6690
|
this.totalAdsInBreak = 0;
|
|
6294
6691
|
this.consecutiveFailures = 0;
|
|
6692
|
+
this.globalConsecutiveNoFills = 0;
|
|
6295
6693
|
this.ima.stop().catch(function() {});
|
|
6296
6694
|
var restoredMuted = this.ima.getOriginalMutedState();
|
|
6297
6695
|
var restoredVolume = this.ima.getOriginalVolume();
|
|
@@ -6323,6 +6721,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6323
6721
|
key: "handleAdFailure",
|
|
6324
6722
|
value: function handleAdFailure() {
|
|
6325
6723
|
this.consecutiveFailures++;
|
|
6724
|
+
this.recordGamNoFill();
|
|
6326
6725
|
var remaining = this.getRemainingAdMs();
|
|
6327
6726
|
if (this.config.debugAdTiming) {
|
|
6328
6727
|
console.log("[CONTINUOUS-FETCH] Ad failure: remaining=".concat(remaining, "ms, queued ads=").concat(this.adRequestQueue.length, ", consecutiveFailures=").concat(this.consecutiveFailures), this.adRequestQueue.length > 0 ? {
|
|
@@ -6350,8 +6749,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6350
6749
|
key: "startAdRequestWatchdog",
|
|
6351
6750
|
value: function startAdRequestWatchdog(token) {
|
|
6352
6751
|
var _this = this;
|
|
6353
|
-
this.clearAdRequestWatchdog();
|
|
6354
6752
|
var _this_config_adFailsafeTimeoutMs;
|
|
6753
|
+
this.clearAdRequestWatchdog();
|
|
6355
6754
|
var timeoutMs = (_this_config_adFailsafeTimeoutMs = this.config.adFailsafeTimeoutMs) !== null && _this_config_adFailsafeTimeoutMs !== void 0 ? _this_config_adFailsafeTimeoutMs : 1e4;
|
|
6356
6755
|
this.adRequestWatchdogToken = token;
|
|
6357
6756
|
this.adRequestWatchdogId = window.setTimeout(function() {
|
|
@@ -6394,8 +6793,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6394
6793
|
key: "startAdFailsafeTimer",
|
|
6395
6794
|
value: function startAdFailsafeTimer(token) {
|
|
6396
6795
|
var _this = this;
|
|
6397
|
-
this.clearAdFailsafeTimer();
|
|
6398
6796
|
var _this_config_adFailsafeTimeoutMs;
|
|
6797
|
+
this.clearAdFailsafeTimer();
|
|
6399
6798
|
var failsafeMs = (_this_config_adFailsafeTimeoutMs = this.config.adFailsafeTimeoutMs) !== null && _this_config_adFailsafeTimeoutMs !== void 0 ? _this_config_adFailsafeTimeoutMs : 1e4;
|
|
6400
6799
|
this.adFailsafeToken = token;
|
|
6401
6800
|
this.adFailsafeTimerId = window.setTimeout(function() {
|
|
@@ -6716,23 +7115,23 @@ var DASH_EXTENSIONS = /\.(mpd)($|\?)/i;
|
|
|
6716
7115
|
var VIDEO_EXTENSIONS = /\.(mp4|webm|ogg|avi|mov|wmv|flv|mkv)($|\?)/i;
|
|
6717
7116
|
var AUDIO_EXTENSIONS = /\.(mp3|wav|ogg|aac|wma|flac|m4a)($|\?)/i;
|
|
6718
7117
|
var canPlay = {
|
|
6719
|
-
hls: function(url) {
|
|
7118
|
+
hls: function hls(url) {
|
|
6720
7119
|
if (!url || typeof url !== "string") return false;
|
|
6721
7120
|
return HLS_EXTENSIONS.test(url) || HLS_PATHS.test(url);
|
|
6722
7121
|
},
|
|
6723
|
-
dash: function(url) {
|
|
7122
|
+
dash: function dash(url) {
|
|
6724
7123
|
if (!url || typeof url !== "string") return false;
|
|
6725
7124
|
return DASH_EXTENSIONS.test(url);
|
|
6726
7125
|
},
|
|
6727
|
-
video: function(url) {
|
|
7126
|
+
video: function video(url) {
|
|
6728
7127
|
if (!url || typeof url !== "string") return false;
|
|
6729
7128
|
return VIDEO_EXTENSIONS.test(url);
|
|
6730
7129
|
},
|
|
6731
|
-
audio: function(url) {
|
|
7130
|
+
audio: function audio(url) {
|
|
6732
7131
|
if (!url || typeof url !== "string") return false;
|
|
6733
7132
|
return AUDIO_EXTENSIONS.test(url);
|
|
6734
7133
|
},
|
|
6735
|
-
file: function(url) {
|
|
7134
|
+
file: function file(url) {
|
|
6736
7135
|
if (!url || typeof url !== "string") return false;
|
|
6737
7136
|
return VIDEO_EXTENSIONS.test(url) || AUDIO_EXTENSIONS.test(url);
|
|
6738
7137
|
}
|
|
@@ -6743,11 +7142,11 @@ var HlsPlayer = /*#__PURE__*/ function(_import_react_Component) {
|
|
|
6743
7142
|
function HlsPlayer() {
|
|
6744
7143
|
_class_call_check(this, HlsPlayer);
|
|
6745
7144
|
var _this;
|
|
6746
|
-
var _this1
|
|
6747
|
-
_this = _call_super(this, HlsPlayer,
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
7145
|
+
var _this1;
|
|
7146
|
+
_this = _call_super(this, HlsPlayer, arguments), _this1 = _this;
|
|
7147
|
+
_this.player = null;
|
|
7148
|
+
_this.mounted = false;
|
|
7149
|
+
_this.load = function() {
|
|
6751
7150
|
return _async_to_generator(function() {
|
|
6752
7151
|
var _this_props_onMount, _this_props, config, _this_props_onReady, _this_props1, error, _this_props_onError, _this_props2;
|
|
6753
7152
|
return _ts_generator(this, function(_state) {
|
|
@@ -6820,87 +7219,87 @@ var HlsPlayer = /*#__PURE__*/ function(_import_react_Component) {
|
|
|
6820
7219
|
});
|
|
6821
7220
|
})();
|
|
6822
7221
|
};
|
|
6823
|
-
|
|
6824
|
-
if (
|
|
6825
|
-
var video =
|
|
7222
|
+
_this.play = function() {
|
|
7223
|
+
if (_this.props.videoElement) {
|
|
7224
|
+
var video = _this.props.videoElement;
|
|
6826
7225
|
var hasValidSource = video.src || video.currentSrc && video.currentSrc !== "" || video.readyState >= 1;
|
|
6827
7226
|
if (hasValidSource) {
|
|
6828
7227
|
var _video_play, _this_props_onPlay, _this_props;
|
|
6829
7228
|
(_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function(error) {
|
|
6830
7229
|
var _this_props_onError, _this_props;
|
|
6831
7230
|
console.error("[HlsPlayer] Failed to play:", error);
|
|
6832
|
-
(_this_props_onError = (_this_props =
|
|
7231
|
+
(_this_props_onError = (_this_props = _this.props).onError) === null || _this_props_onError === void 0 ? void 0 : _this_props_onError.call(_this_props, error);
|
|
6833
7232
|
});
|
|
6834
|
-
(_this_props_onPlay = (_this_props =
|
|
7233
|
+
(_this_props_onPlay = (_this_props = _this.props).onPlay) === null || _this_props_onPlay === void 0 ? void 0 : _this_props_onPlay.call(_this_props);
|
|
6835
7234
|
} else {
|
|
6836
7235
|
console.warn("[HlsPlayer] Cannot play: video has no valid source");
|
|
6837
7236
|
}
|
|
6838
7237
|
}
|
|
6839
7238
|
};
|
|
6840
|
-
|
|
6841
|
-
if (
|
|
7239
|
+
_this.pause = function() {
|
|
7240
|
+
if (_this.props.videoElement) {
|
|
6842
7241
|
var _this_props_onPause, _this_props;
|
|
6843
|
-
|
|
6844
|
-
(_this_props_onPause = (_this_props =
|
|
7242
|
+
_this.props.videoElement.pause();
|
|
7243
|
+
(_this_props_onPause = (_this_props = _this.props).onPause) === null || _this_props_onPause === void 0 ? void 0 : _this_props_onPause.call(_this_props);
|
|
6845
7244
|
}
|
|
6846
7245
|
};
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
if (
|
|
6850
|
-
|
|
7246
|
+
_this.stop = function() {
|
|
7247
|
+
_this.pause();
|
|
7248
|
+
if (_this.props.videoElement) {
|
|
7249
|
+
_this.props.videoElement.currentTime = 0;
|
|
6851
7250
|
}
|
|
6852
7251
|
};
|
|
6853
|
-
|
|
6854
|
-
if (
|
|
6855
|
-
|
|
7252
|
+
_this.seekTo = function(seconds, keepPlaying) {
|
|
7253
|
+
if (_this.props.videoElement) {
|
|
7254
|
+
_this.props.videoElement.currentTime = seconds;
|
|
6856
7255
|
if (!keepPlaying) {
|
|
6857
|
-
|
|
7256
|
+
_this.pause();
|
|
6858
7257
|
}
|
|
6859
7258
|
}
|
|
6860
7259
|
};
|
|
6861
|
-
|
|
6862
|
-
if (
|
|
6863
|
-
|
|
7260
|
+
_this.setVolume = function(volume) {
|
|
7261
|
+
if (_this.props.videoElement) {
|
|
7262
|
+
_this.props.videoElement.volume = Math.max(0, Math.min(1, volume));
|
|
6864
7263
|
}
|
|
6865
7264
|
};
|
|
6866
|
-
|
|
6867
|
-
if (
|
|
6868
|
-
|
|
7265
|
+
_this.mute = function() {
|
|
7266
|
+
if (_this.props.videoElement) {
|
|
7267
|
+
_this.props.videoElement.muted = true;
|
|
6869
7268
|
}
|
|
6870
7269
|
};
|
|
6871
|
-
|
|
6872
|
-
if (
|
|
6873
|
-
|
|
7270
|
+
_this.unmute = function() {
|
|
7271
|
+
if (_this.props.videoElement) {
|
|
7272
|
+
_this.props.videoElement.muted = false;
|
|
6874
7273
|
}
|
|
6875
7274
|
};
|
|
6876
|
-
|
|
6877
|
-
if (
|
|
6878
|
-
|
|
7275
|
+
_this.setPlaybackRate = function(rate) {
|
|
7276
|
+
if (_this.props.videoElement && rate > 0) {
|
|
7277
|
+
_this.props.videoElement.playbackRate = rate;
|
|
6879
7278
|
}
|
|
6880
7279
|
};
|
|
6881
|
-
|
|
6882
|
-
if (
|
|
6883
|
-
return
|
|
7280
|
+
_this.getDuration = function() {
|
|
7281
|
+
if (_this.props.videoElement && isFinite(_this.props.videoElement.duration)) {
|
|
7282
|
+
return _this.props.videoElement.duration;
|
|
6884
7283
|
}
|
|
6885
7284
|
return null;
|
|
6886
7285
|
};
|
|
6887
|
-
|
|
6888
|
-
if (
|
|
6889
|
-
return
|
|
7286
|
+
_this.getCurrentTime = function() {
|
|
7287
|
+
if (_this.props.videoElement && isFinite(_this.props.videoElement.currentTime)) {
|
|
7288
|
+
return _this.props.videoElement.currentTime;
|
|
6890
7289
|
}
|
|
6891
7290
|
return null;
|
|
6892
7291
|
};
|
|
6893
|
-
|
|
6894
|
-
if (
|
|
6895
|
-
return
|
|
7292
|
+
_this.getSecondsLoaded = function() {
|
|
7293
|
+
if (_this.props.videoElement && _this.props.videoElement.buffered.length > 0) {
|
|
7294
|
+
return _this.props.videoElement.buffered.end(_this.props.videoElement.buffered.length - 1);
|
|
6896
7295
|
}
|
|
6897
7296
|
return null;
|
|
6898
7297
|
};
|
|
6899
|
-
|
|
7298
|
+
_this.getInternalPlayer = function() {
|
|
6900
7299
|
var key = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "player";
|
|
6901
|
-
if (key === "player") return
|
|
6902
|
-
if (key === "video") return
|
|
6903
|
-
if (key === "hls" &&
|
|
7300
|
+
if (key === "player") return _this.player;
|
|
7301
|
+
if (key === "video") return _this.props.videoElement;
|
|
7302
|
+
if (key === "hls" && _this.player) return _this.player.hls;
|
|
6904
7303
|
return null;
|
|
6905
7304
|
};
|
|
6906
7305
|
return _this;
|