stormcloud-video-player 0.8.29 → 0.8.31
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 +2 -2
- package/lib/index.cjs +293 -1219
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +0 -3
- package/lib/index.d.ts +0 -3
- package/lib/index.js +292 -1219
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +57 -490
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +8 -7
- package/lib/player/AdConfigManager.cjs +12 -53
- package/lib/player/AdConfigManager.cjs.map +1 -1
- package/lib/player/AdConfigManager.d.cts +4 -5
- package/lib/player/AdTimingService.d.cts +1 -1
- package/lib/player/HlsEngine.d.cts +1 -1
- package/lib/player/PlayerControls.d.cts +1 -1
- package/lib/player/Scte35CueManager.d.cts +1 -1
- package/lib/player/Scte35Parser.d.cts +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +293 -1219
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -3
- package/lib/player/playerTypes.d.cts +1 -1
- package/lib/players/HlsPlayer.cjs +293 -1219
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +293 -1219
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +49 -8
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/{types-Xgz2_W1C.d.cts → types-CSHvCbhZ.d.cts} +0 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +293 -1219
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/lib/utils/vastMacros.cjs +10 -15
- package/lib/utils/vastMacros.cjs.map +1 -1
- package/lib/utils/vastMacros.d.cts +0 -1
- package/package.json +1 -1
- package/lib/player/AdPreloadPool.cjs +0 -673
- package/lib/player/AdPreloadPool.cjs.map +0 -1
- package/lib/player/AdPreloadPool.d.cts +0 -37
package/lib/index.js
CHANGED
|
@@ -746,24 +746,65 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
function fetchVastXml(vastTagUrl) {
|
|
749
|
+
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
749
750
|
return _async_to_generator(function() {
|
|
750
|
-
var response;
|
|
751
|
+
var requestVast, response, error;
|
|
751
752
|
return _ts_generator(this, function(_state) {
|
|
752
753
|
switch(_state.label){
|
|
753
754
|
case 0:
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
fetch(vastTagUrl, {
|
|
755
|
+
requestVast = function requestVast(creds) {
|
|
756
|
+
return fetch(vastTagUrl, {
|
|
757
757
|
mode: "cors",
|
|
758
|
-
credentials:
|
|
758
|
+
credentials: creds,
|
|
759
759
|
headers: {
|
|
760
760
|
"Accept": "application/xml, text/xml, */*"
|
|
761
761
|
},
|
|
762
762
|
referrerPolicy: "no-referrer-when-downgrade"
|
|
763
|
-
})
|
|
764
|
-
|
|
763
|
+
});
|
|
764
|
+
};
|
|
765
|
+
_state.label = 1;
|
|
765
766
|
case 1:
|
|
767
|
+
_state.trys.push([
|
|
768
|
+
1,
|
|
769
|
+
3,
|
|
770
|
+
,
|
|
771
|
+
7
|
|
772
|
+
]);
|
|
773
|
+
return [
|
|
774
|
+
4,
|
|
775
|
+
requestVast(credentials)
|
|
776
|
+
];
|
|
777
|
+
case 2:
|
|
766
778
|
response = _state.sent();
|
|
779
|
+
return [
|
|
780
|
+
3,
|
|
781
|
+
7
|
|
782
|
+
];
|
|
783
|
+
case 3:
|
|
784
|
+
error = _state.sent();
|
|
785
|
+
if (!(credentials !== "omit")) return [
|
|
786
|
+
3,
|
|
787
|
+
5
|
|
788
|
+
];
|
|
789
|
+
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
790
|
+
return [
|
|
791
|
+
4,
|
|
792
|
+
requestVast("omit")
|
|
793
|
+
];
|
|
794
|
+
case 4:
|
|
795
|
+
response = _state.sent();
|
|
796
|
+
return [
|
|
797
|
+
3,
|
|
798
|
+
6
|
|
799
|
+
];
|
|
800
|
+
case 5:
|
|
801
|
+
throw error;
|
|
802
|
+
case 6:
|
|
803
|
+
return [
|
|
804
|
+
3,
|
|
805
|
+
7
|
|
806
|
+
];
|
|
807
|
+
case 7:
|
|
767
808
|
if (!response.ok) {
|
|
768
809
|
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
769
810
|
}
|
|
@@ -785,7 +826,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
785
826
|
depth = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : 0, accumulatedTracking = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : createEmptyTrackingUrls();
|
|
786
827
|
return [
|
|
787
828
|
4,
|
|
788
|
-
fetchVastXml(vastTagUrl)
|
|
829
|
+
fetchVastXml(vastTagUrl, depth === 0 ? "include" : "omit")
|
|
789
830
|
];
|
|
790
831
|
case 1:
|
|
791
832
|
vastXml = _state.sent();
|
|
@@ -3463,21 +3504,16 @@ function applyVastMacros(baseUrl, ctx) {
|
|
|
3463
3504
|
if (ctx.pod != null) {
|
|
3464
3505
|
params.set("pod", String(ctx.pod));
|
|
3465
3506
|
}
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
params.
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
if (ctx.podMaxAds != null) {
|
|
3477
|
-
params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
|
|
3478
|
-
}
|
|
3479
|
-
} else if (ctx.adPosition != null) {
|
|
3480
|
-
params.set("ppos", String(ctx.adPosition));
|
|
3507
|
+
params.delete("ppos");
|
|
3508
|
+
params.delete("lip");
|
|
3509
|
+
if (ctx.podMinDurationMs != null) {
|
|
3510
|
+
params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
|
|
3511
|
+
}
|
|
3512
|
+
if (ctx.podMaxDurationMs != null) {
|
|
3513
|
+
params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
|
|
3514
|
+
}
|
|
3515
|
+
if (ctx.podMaxAds != null) {
|
|
3516
|
+
params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
|
|
3481
3517
|
}
|
|
3482
3518
|
var requestUrl = ctx.contentUrl || ctx.pageUrl;
|
|
3483
3519
|
if (requestUrl) {
|
|
@@ -4843,9 +4879,9 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
4843
4879
|
this.consentSignals = {};
|
|
4844
4880
|
this.podCounter = 0;
|
|
4845
4881
|
this.podAssignedByPrefetch = false;
|
|
4846
|
-
this.adRequestPositionInBreak = 0;
|
|
4847
4882
|
this.lastHeartbeatTime = 0;
|
|
4848
4883
|
this.defaultPodMaxAds = 6;
|
|
4884
|
+
this.defaultPodMaxDurationMs = 12e4;
|
|
4849
4885
|
this.config = config;
|
|
4850
4886
|
this.video = video;
|
|
4851
4887
|
}
|
|
@@ -5263,48 +5299,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
5263
5299
|
key: "beginNewAdPod",
|
|
5264
5300
|
value: function beginNewAdPod() {
|
|
5265
5301
|
this.podCounter++;
|
|
5266
|
-
this.adRequestPositionInBreak = 0;
|
|
5267
|
-
}
|
|
5268
|
-
},
|
|
5269
|
-
{
|
|
5270
|
-
key: "generateVastUrlsWithCorrelators",
|
|
5271
|
-
value: function generateVastUrlsWithCorrelators(baseUrl, count, adPlayer, palNonce, inAdBreak) {
|
|
5272
|
-
var urls = [];
|
|
5273
|
-
for(var i = 0; i < count; i++){
|
|
5274
|
-
this.adRequestPositionInBreak++;
|
|
5275
|
-
var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
|
|
5276
|
-
var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
|
|
5277
|
-
var urlWithMacros = applyVastMacros(baseUrl, {
|
|
5278
|
-
correlator: this.viewCorrelator,
|
|
5279
|
-
streamCorrelator: this.streamCorrelator,
|
|
5280
|
-
pod: this.podCounter > 0 ? this.podCounter : void 0,
|
|
5281
|
-
adPosition: this.adRequestPositionInBreak,
|
|
5282
|
-
isCtv: envSignals.isCtv,
|
|
5283
|
-
contentUrl: envSignals.contentUrl,
|
|
5284
|
-
pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
|
|
5285
|
-
adWillPlayMuted: adWillPlayMuted,
|
|
5286
|
-
adWillAutoPlay: !!this.config.autoplay,
|
|
5287
|
-
appId: envSignals.appId,
|
|
5288
|
-
appName: envSignals.appName,
|
|
5289
|
-
sessionId: envSignals.sessionId,
|
|
5290
|
-
deviceId: envSignals.deviceId,
|
|
5291
|
-
deviceIdType: envSignals.deviceIdType,
|
|
5292
|
-
limitAdTracking: envSignals.limitAdTracking,
|
|
5293
|
-
deviceTypeHint: envSignals.deviceTypeHint,
|
|
5294
|
-
adTest: this.config.adTest,
|
|
5295
|
-
consent: this.consentSignals
|
|
5296
|
-
});
|
|
5297
|
-
var finalUrl = palNonce.injectNonce(urlWithMacros);
|
|
5298
|
-
console.log("[StormcloudVideoPlayer] Resolved ad request URL (pod=".concat(this.podCounter, ", pos=").concat(this.adRequestPositionInBreak, "):"), finalUrl);
|
|
5299
|
-
urls.push(finalUrl);
|
|
5300
|
-
}
|
|
5301
|
-
return urls;
|
|
5302
5302
|
}
|
|
5303
5303
|
},
|
|
5304
5304
|
{
|
|
5305
5305
|
key: "resolvePodParams",
|
|
5306
5306
|
value: function resolvePodParams(breakDurationMs) {
|
|
5307
|
-
var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs;
|
|
5307
|
+
var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs != null && this.config.podMaxDurationMs > 0 ? this.config.podMaxDurationMs : this.defaultPodMaxDurationMs;
|
|
5308
5308
|
var maxAds = this.config.podMaxAds && this.config.podMaxAds > 0 ? this.config.podMaxAds : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultPodMaxAds;
|
|
5309
5309
|
var minDurationMs = this.config.podExactDuration && maxDurationMs != null ? maxDurationMs : 0;
|
|
5310
5310
|
return {
|
|
@@ -5958,614 +5958,157 @@ var AdTimingService = /*#__PURE__*/ function() {
|
|
|
5958
5958
|
]);
|
|
5959
5959
|
return AdTimingService;
|
|
5960
5960
|
}();
|
|
5961
|
-
// src/player/
|
|
5962
|
-
var
|
|
5961
|
+
// src/player/PlaceholderLayer.ts
|
|
5962
|
+
var PlaceholderLayer = /*#__PURE__*/ function() {
|
|
5963
5963
|
"use strict";
|
|
5964
|
-
function
|
|
5965
|
-
_class_call_check(this,
|
|
5966
|
-
this.
|
|
5967
|
-
this.
|
|
5968
|
-
this.poolActive = false;
|
|
5969
|
-
this.loopRunning = false;
|
|
5970
|
-
this.deps = deps;
|
|
5964
|
+
function PlaceholderLayer(video, debug) {
|
|
5965
|
+
_class_call_check(this, PlaceholderLayer);
|
|
5966
|
+
this.video = video;
|
|
5967
|
+
this.debug = debug;
|
|
5971
5968
|
}
|
|
5972
|
-
_create_class(
|
|
5969
|
+
_create_class(PlaceholderLayer, [
|
|
5973
5970
|
{
|
|
5974
|
-
key: "
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5971
|
+
key: "ensureContainer",
|
|
5972
|
+
value: function ensureContainer() {
|
|
5973
|
+
if (this.container) {
|
|
5974
|
+
return;
|
|
5975
|
+
}
|
|
5976
|
+
var el = document.createElement("div");
|
|
5977
|
+
el.style.position = "absolute";
|
|
5978
|
+
el.style.left = "0";
|
|
5979
|
+
el.style.top = "0";
|
|
5980
|
+
el.style.right = "0";
|
|
5981
|
+
el.style.bottom = "0";
|
|
5982
|
+
el.style.display = "none";
|
|
5983
|
+
el.style.alignItems = "center";
|
|
5984
|
+
el.style.justifyContent = "center";
|
|
5985
|
+
el.style.pointerEvents = "none";
|
|
5986
|
+
el.style.zIndex = "5";
|
|
5987
|
+
el.style.backgroundColor = "#000";
|
|
5988
|
+
el.style.transition = "opacity 0.3s ease-in-out";
|
|
5989
|
+
el.style.opacity = "0";
|
|
5990
|
+
if (!this.video.parentElement) {
|
|
5991
|
+
if (this.debug) {
|
|
5992
|
+
console.warn("[StormcloudVideoPlayer] Video element has no parent for placeholder container");
|
|
5993
|
+
}
|
|
5994
|
+
return;
|
|
5995
|
+
}
|
|
5996
|
+
this.video.parentElement.appendChild(el);
|
|
5997
|
+
this.container = el;
|
|
5980
5998
|
}
|
|
5981
5999
|
},
|
|
5982
6000
|
{
|
|
5983
|
-
key: "
|
|
5984
|
-
|
|
5985
|
-
|
|
6001
|
+
key: "show",
|
|
6002
|
+
value: function show() {
|
|
6003
|
+
var _this = this;
|
|
6004
|
+
this.ensureContainer();
|
|
6005
|
+
if (!this.container) {
|
|
6006
|
+
return;
|
|
6007
|
+
}
|
|
6008
|
+
if (!this.video.muted) {
|
|
6009
|
+
this.video.muted = true;
|
|
6010
|
+
if (this.debug) {
|
|
6011
|
+
console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
|
|
6012
|
+
}
|
|
6013
|
+
}
|
|
6014
|
+
var wasHidden = this.container.style.display === "none" || this.container.style.opacity === "0";
|
|
6015
|
+
if (wasHidden) {
|
|
6016
|
+
this.container.style.transition = "none";
|
|
6017
|
+
} else {
|
|
6018
|
+
this.container.style.transition = "opacity 0.3s ease-in-out";
|
|
6019
|
+
}
|
|
6020
|
+
this.container.style.backgroundColor = "#000";
|
|
6021
|
+
this.container.style.display = "flex";
|
|
6022
|
+
this.container.offsetHeight;
|
|
6023
|
+
this.container.style.opacity = "1";
|
|
6024
|
+
this.container.style.pointerEvents = "auto";
|
|
6025
|
+
if (wasHidden) {
|
|
6026
|
+
requestAnimationFrame(function() {
|
|
6027
|
+
if (_this.container) {
|
|
6028
|
+
_this.container.style.transition = "opacity 0.3s ease-in-out";
|
|
6029
|
+
}
|
|
6030
|
+
});
|
|
6031
|
+
}
|
|
6032
|
+
if (this.debug) {
|
|
6033
|
+
console.log("[StormcloudVideoPlayer] Showing placeholder layer (between content and ad layer)");
|
|
6034
|
+
}
|
|
5986
6035
|
}
|
|
5987
6036
|
},
|
|
5988
6037
|
{
|
|
5989
|
-
key: "
|
|
5990
|
-
value: function
|
|
5991
|
-
var
|
|
5992
|
-
if (this.
|
|
5993
|
-
if (this.deps.debug) {
|
|
5994
|
-
console.log("[PRELOAD-POOL] Already active, skipping duplicate start");
|
|
5995
|
-
}
|
|
6038
|
+
key: "hide",
|
|
6039
|
+
value: function hide() {
|
|
6040
|
+
var _this = this;
|
|
6041
|
+
if (!this.container) {
|
|
5996
6042
|
return;
|
|
5997
6043
|
}
|
|
5998
|
-
this.
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
try {
|
|
6005
|
-
for(var _iterator = initialUrls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
6006
|
-
var url = _step.value;
|
|
6007
|
-
if (this.pool.length < this.maxPoolSize) {
|
|
6008
|
-
this.preloadAdIntoPool(url);
|
|
6009
|
-
}
|
|
6010
|
-
}
|
|
6011
|
-
} catch (err) {
|
|
6012
|
-
_didIteratorError = true;
|
|
6013
|
-
_iteratorError = err;
|
|
6014
|
-
} finally{
|
|
6015
|
-
try {
|
|
6016
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
6017
|
-
_iterator.return();
|
|
6018
|
-
}
|
|
6019
|
-
} finally{
|
|
6020
|
-
if (_didIteratorError) {
|
|
6021
|
-
throw _iteratorError;
|
|
6022
|
-
}
|
|
6044
|
+
this.container.style.opacity = "0";
|
|
6045
|
+
setTimeout(function() {
|
|
6046
|
+
if (_this.container) {
|
|
6047
|
+
_this.container.style.display = "none";
|
|
6048
|
+
_this.container.style.pointerEvents = "none";
|
|
6049
|
+
_this.container.style.backgroundColor = "#000";
|
|
6023
6050
|
}
|
|
6051
|
+
}, 300);
|
|
6052
|
+
if (this.debug) {
|
|
6053
|
+
console.log("[StormcloudVideoPlayer] Hiding placeholder layer");
|
|
6024
6054
|
}
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6055
|
+
}
|
|
6056
|
+
},
|
|
6057
|
+
{
|
|
6058
|
+
key: "destroy",
|
|
6059
|
+
value: function destroy() {
|
|
6060
|
+
if (this.container) {
|
|
6061
|
+
if (this.container.parentElement) {
|
|
6062
|
+
this.container.parentElement.removeChild(this.container);
|
|
6063
|
+
}
|
|
6064
|
+
this.container = void 0;
|
|
6029
6065
|
}
|
|
6030
6066
|
}
|
|
6067
|
+
}
|
|
6068
|
+
]);
|
|
6069
|
+
return PlaceholderLayer;
|
|
6070
|
+
}();
|
|
6071
|
+
// src/player/HlsEngine.ts
|
|
6072
|
+
import Hls2 from "hls.js";
|
|
6073
|
+
var HlsEngine = /*#__PURE__*/ function() {
|
|
6074
|
+
"use strict";
|
|
6075
|
+
function HlsEngine(config, video, cueManager, timing, callbacks) {
|
|
6076
|
+
_class_call_check(this, HlsEngine);
|
|
6077
|
+
this.isLiveStream = false;
|
|
6078
|
+
this.nativeHlsMode = false;
|
|
6079
|
+
this.videoSrcProtection = null;
|
|
6080
|
+
this.bufferedSegmentsCount = 0;
|
|
6081
|
+
this.shouldAutoplayAfterBuffering = false;
|
|
6082
|
+
this.hasInitialBufferCompleted = false;
|
|
6083
|
+
this.config = config;
|
|
6084
|
+
this.video = video;
|
|
6085
|
+
this.cueManager = cueManager;
|
|
6086
|
+
this.timing = timing;
|
|
6087
|
+
this.callbacks = callbacks;
|
|
6088
|
+
}
|
|
6089
|
+
_create_class(HlsEngine, [
|
|
6090
|
+
{
|
|
6091
|
+
key: "debug",
|
|
6092
|
+
get: function get() {
|
|
6093
|
+
return !!this.config.debugAdTiming;
|
|
6094
|
+
}
|
|
6031
6095
|
},
|
|
6032
6096
|
{
|
|
6033
|
-
key: "
|
|
6034
|
-
value: function
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
return
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
if (this.deps.debug) {
|
|
6042
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
|
|
6043
|
-
}
|
|
6044
|
-
return [
|
|
6045
|
-
2
|
|
6046
|
-
];
|
|
6047
|
-
}
|
|
6048
|
-
if (this.pool.some(function(entry) {
|
|
6049
|
-
return entry.vastUrl === vastUrl;
|
|
6050
|
-
}) || timing.failedVastUrls.has(vastUrl) || timing.isUrlInCooldown(vastUrl)) {
|
|
6051
|
-
return [
|
|
6052
|
-
2
|
|
6053
|
-
];
|
|
6054
|
-
}
|
|
6055
|
-
if (this.pool.length >= this.maxPoolSize) {
|
|
6056
|
-
return [
|
|
6057
|
-
2
|
|
6058
|
-
];
|
|
6059
|
-
}
|
|
6060
|
-
if (this.deps.debug) {
|
|
6061
|
-
console.log("[PRELOAD-POOL] Preloading ad into pool: ".concat(vastUrl));
|
|
6062
|
-
}
|
|
6063
|
-
epoch = timing.adBreakEpoch;
|
|
6064
|
-
loadPromise = function() {
|
|
6065
|
-
return _async_to_generator(function() {
|
|
6066
|
-
var _this, hasAdError, adErrorPayload, errorListenerCleanup, _preloadAd_getLoadedAdDuration, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, loadedDuration, lateErrorListener, _poolEntry_durationSeconds, error;
|
|
6067
|
-
return _ts_generator(this, function(_state) {
|
|
6068
|
-
switch(_state.label){
|
|
6069
|
-
case 0:
|
|
6070
|
-
_this = this;
|
|
6071
|
-
hasAdError = false;
|
|
6072
|
-
adErrorPayload = null;
|
|
6073
|
-
errorListenerCleanup = null;
|
|
6074
|
-
_state.label = 1;
|
|
6075
|
-
case 1:
|
|
6076
|
-
_state.trys.push([
|
|
6077
|
-
1,
|
|
6078
|
-
5,
|
|
6079
|
-
,
|
|
6080
|
-
6
|
|
6081
|
-
]);
|
|
6082
|
-
continueLiveStreamDuringAds = this.deps.shouldContinueLiveStreamDuringAds();
|
|
6083
|
-
preloadAd = this.deps.createAdPlayer(continueLiveStreamDuringAds);
|
|
6084
|
-
preloadAd.initialize();
|
|
6085
|
-
errorListener = function errorListener(payload) {
|
|
6086
|
-
hasAdError = true;
|
|
6087
|
-
adErrorPayload = payload;
|
|
6088
|
-
};
|
|
6089
|
-
preloadAd.on("ad_error", errorListener);
|
|
6090
|
-
errorListenerCleanup = function errorListenerCleanup() {
|
|
6091
|
-
return preloadAd.off("ad_error", errorListener);
|
|
6092
|
-
};
|
|
6093
|
-
return [
|
|
6094
|
-
4,
|
|
6095
|
-
timing.enforceGlobalRateLimit()
|
|
6096
|
-
];
|
|
6097
|
-
case 2:
|
|
6098
|
-
_state.sent();
|
|
6099
|
-
return [
|
|
6100
|
-
4,
|
|
6101
|
-
preloadAd.requestAds(vastUrl)
|
|
6102
|
-
];
|
|
6103
|
-
case 3:
|
|
6104
|
-
_state.sent();
|
|
6105
|
-
preloadAd.pause();
|
|
6106
|
-
return [
|
|
6107
|
-
4,
|
|
6108
|
-
new Promise(function(resolve) {
|
|
6109
|
-
return setTimeout(resolve, 1500);
|
|
6110
|
-
})
|
|
6111
|
-
];
|
|
6112
|
-
case 4:
|
|
6113
|
-
_state.sent();
|
|
6114
|
-
preloadAd.pause();
|
|
6115
|
-
if (hasAdError) {
|
|
6116
|
-
isNoFill = (adErrorPayload === null || adErrorPayload === void 0 ? void 0 : adErrorPayload.isNoFill) || (adErrorPayload === null || adErrorPayload === void 0 ? void 0 : adErrorPayload.code) === 303 || (adErrorPayload === null || adErrorPayload === void 0 ? void 0 : adErrorPayload.vastErrorCode) === 303;
|
|
6117
|
-
if (errorListenerCleanup) {
|
|
6118
|
-
errorListenerCleanup();
|
|
6119
|
-
}
|
|
6120
|
-
preloadAd.destroy();
|
|
6121
|
-
timing.recordGamNoFill();
|
|
6122
|
-
if (isNoFill) {
|
|
6123
|
-
if (this.deps.debug) {
|
|
6124
|
-
console.log("[PRELOAD-POOL] Ad preload returned no-fill: ".concat(vastUrl));
|
|
6125
|
-
}
|
|
6126
|
-
timing.temporaryFailureUrls.set(vastUrl, Date.now());
|
|
6127
|
-
} else {
|
|
6128
|
-
if (this.deps.debug) {
|
|
6129
|
-
console.log("[PRELOAD-POOL] Ad preload failed with error: ".concat(vastUrl), adErrorPayload);
|
|
6130
|
-
}
|
|
6131
|
-
if (adErrorPayload && !timing.isTemporaryAdError(adErrorPayload)) {
|
|
6132
|
-
timing.failedVastUrls.add(vastUrl);
|
|
6133
|
-
} else {
|
|
6134
|
-
timing.temporaryFailureUrls.set(vastUrl, Date.now());
|
|
6135
|
-
}
|
|
6136
|
-
}
|
|
6137
|
-
return [
|
|
6138
|
-
2
|
|
6139
|
-
];
|
|
6140
|
-
}
|
|
6141
|
-
if (!this.poolActive || epoch !== timing.adBreakEpoch) {
|
|
6142
|
-
if (this.deps.debug) {
|
|
6143
|
-
console.log("[PRELOAD-POOL] Discarding preloaded ad - break ended during fetch");
|
|
6144
|
-
}
|
|
6145
|
-
if (errorListenerCleanup) {
|
|
6146
|
-
errorListenerCleanup();
|
|
6147
|
-
}
|
|
6148
|
-
try {
|
|
6149
|
-
preloadAd.destroy();
|
|
6150
|
-
} catch (unused) {}
|
|
6151
|
-
return [
|
|
6152
|
-
2
|
|
6153
|
-
];
|
|
6154
|
-
}
|
|
6155
|
-
poolEntry = {
|
|
6156
|
-
vastUrl: vastUrl,
|
|
6157
|
-
adController: preloadAd,
|
|
6158
|
-
loadedAt: Date.now(),
|
|
6159
|
-
isReady: true,
|
|
6160
|
-
loadPromise: Promise.resolve()
|
|
6161
|
-
};
|
|
6162
|
-
loadedDuration = (_preloadAd_getLoadedAdDuration = preloadAd.getLoadedAdDuration) === null || _preloadAd_getLoadedAdDuration === void 0 ? void 0 : _preloadAd_getLoadedAdDuration.call(preloadAd);
|
|
6163
|
-
if (loadedDuration != null && loadedDuration > 0) {
|
|
6164
|
-
poolEntry.durationSeconds = loadedDuration;
|
|
6165
|
-
}
|
|
6166
|
-
lateErrorListener = function lateErrorListener(payload) {
|
|
6167
|
-
var index = _this.pool.findIndex(function(entry) {
|
|
6168
|
-
return entry.vastUrl === vastUrl;
|
|
6169
|
-
});
|
|
6170
|
-
if (index >= 0) {
|
|
6171
|
-
_this.pool.splice(index, 1);
|
|
6172
|
-
if (_this.deps.debug) {
|
|
6173
|
-
console.log("[PRELOAD-POOL] Late error detected, removed from pool: ".concat(vastUrl), payload);
|
|
6174
|
-
}
|
|
6175
|
-
try {
|
|
6176
|
-
preloadAd.destroy();
|
|
6177
|
-
} catch (unused) {}
|
|
6178
|
-
}
|
|
6179
|
-
};
|
|
6180
|
-
preloadAd.on("ad_error", lateErrorListener);
|
|
6181
|
-
this.pool.push(poolEntry);
|
|
6182
|
-
if (this.deps.debug) {
|
|
6183
|
-
;
|
|
6184
|
-
console.log("[PRELOAD-POOL] Ad preloaded (no errors detected within timeout) (pool size: ".concat(this.pool.length, "/").concat(this.maxPoolSize, ", duration=").concat((_poolEntry_durationSeconds = poolEntry.durationSeconds) !== null && _poolEntry_durationSeconds !== void 0 ? _poolEntry_durationSeconds : "?", "s)"));
|
|
6185
|
-
}
|
|
6186
|
-
if (errorListenerCleanup) {
|
|
6187
|
-
errorListenerCleanup();
|
|
6188
|
-
}
|
|
6189
|
-
return [
|
|
6190
|
-
3,
|
|
6191
|
-
6
|
|
6192
|
-
];
|
|
6193
|
-
case 5:
|
|
6194
|
-
error = _state.sent();
|
|
6195
|
-
if (errorListenerCleanup) {
|
|
6196
|
-
errorListenerCleanup();
|
|
6197
|
-
}
|
|
6198
|
-
timing.recordGamNoFill();
|
|
6199
|
-
if (this.deps.debug) {
|
|
6200
|
-
console.warn("[PRELOAD-POOL] Failed to preload ad: ".concat(vastUrl), error);
|
|
6201
|
-
}
|
|
6202
|
-
if (_instanceof(error, Error) && !timing.isTemporaryAdError(error)) {
|
|
6203
|
-
timing.failedVastUrls.add(vastUrl);
|
|
6204
|
-
} else if (_instanceof(error, Error) && timing.isTemporaryAdError(error)) {
|
|
6205
|
-
timing.temporaryFailureUrls.set(vastUrl, Date.now());
|
|
6206
|
-
}
|
|
6207
|
-
return [
|
|
6208
|
-
3,
|
|
6209
|
-
6
|
|
6210
|
-
];
|
|
6211
|
-
case 6:
|
|
6212
|
-
return [
|
|
6213
|
-
2
|
|
6214
|
-
];
|
|
6215
|
-
}
|
|
6216
|
-
});
|
|
6217
|
-
}).call(_this);
|
|
6218
|
-
}();
|
|
6219
|
-
loadPromise.catch(function() {});
|
|
6220
|
-
return [
|
|
6221
|
-
2
|
|
6222
|
-
];
|
|
6223
|
-
});
|
|
6224
|
-
}).call(this);
|
|
6097
|
+
key: "shouldUseNativeHls",
|
|
6098
|
+
value: function shouldUseNativeHls(getStreamType) {
|
|
6099
|
+
var streamType = getStreamType();
|
|
6100
|
+
if (streamType === "other") {
|
|
6101
|
+
return true;
|
|
6102
|
+
}
|
|
6103
|
+
var canNative = this.video.canPlayType("application/vnd.apple.mpegurl");
|
|
6104
|
+
return !!(this.config.allowNativeHls && canNative);
|
|
6225
6105
|
}
|
|
6226
6106
|
},
|
|
6227
6107
|
{
|
|
6228
|
-
key: "
|
|
6229
|
-
value: function
|
|
6108
|
+
key: "setupNativeHls",
|
|
6109
|
+
value: function setupNativeHls() {
|
|
6230
6110
|
return _async_to_generator(function() {
|
|
6231
|
-
var
|
|
6232
|
-
return _ts_generator(this, function(_state) {
|
|
6233
|
-
switch(_state.label){
|
|
6234
|
-
case 0:
|
|
6235
|
-
if (this.loopRunning) {
|
|
6236
|
-
return [
|
|
6237
|
-
2
|
|
6238
|
-
];
|
|
6239
|
-
}
|
|
6240
|
-
this.loopRunning = true;
|
|
6241
|
-
epoch = this.deps.timing.adBreakEpoch;
|
|
6242
|
-
if (this.deps.debug) {
|
|
6243
|
-
console.log("[PRELOAD-POOL] Starting continuous preload loop");
|
|
6244
|
-
}
|
|
6245
|
-
_state.label = 1;
|
|
6246
|
-
case 1:
|
|
6247
|
-
if (!(this.poolActive && epoch === this.deps.timing.adBreakEpoch)) return [
|
|
6248
|
-
3,
|
|
6249
|
-
10
|
|
6250
|
-
];
|
|
6251
|
-
if (this.deps.timing.isGamInCooldown()) {
|
|
6252
|
-
if (this.deps.debug) {
|
|
6253
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
|
|
6254
|
-
}
|
|
6255
|
-
return [
|
|
6256
|
-
3,
|
|
6257
|
-
10
|
|
6258
|
-
];
|
|
6259
|
-
}
|
|
6260
|
-
if (!(!this.deps.isInAdBreak() && this.pool.length >= this.maxPoolSize)) return [
|
|
6261
|
-
3,
|
|
6262
|
-
3
|
|
6263
|
-
];
|
|
6264
|
-
return [
|
|
6265
|
-
4,
|
|
6266
|
-
new Promise(function(resolve) {
|
|
6267
|
-
return setTimeout(resolve, 2e3);
|
|
6268
|
-
})
|
|
6269
|
-
];
|
|
6270
|
-
case 2:
|
|
6271
|
-
_state.sent();
|
|
6272
|
-
return [
|
|
6273
|
-
3,
|
|
6274
|
-
1
|
|
6275
|
-
];
|
|
6276
|
-
case 3:
|
|
6277
|
-
if (!this.deps.isInAdBreak() && this.deps.getPendingAdBreak() === null) {
|
|
6278
|
-
if (this.deps.debug) {
|
|
6279
|
-
console.log("[PRELOAD-POOL] Ad break cancelled, stopping preload pool");
|
|
6280
|
-
}
|
|
6281
|
-
return [
|
|
6282
|
-
3,
|
|
6283
|
-
10
|
|
6284
|
-
];
|
|
6285
|
-
}
|
|
6286
|
-
_state.label = 4;
|
|
6287
|
-
case 4:
|
|
6288
|
-
if (!(this.pool.length < this.maxPoolSize)) return [
|
|
6289
|
-
3,
|
|
6290
|
-
8
|
|
6291
|
-
];
|
|
6292
|
-
if (!this.poolActive || epoch !== this.deps.timing.adBreakEpoch || this.deps.timing.isGamInCooldown()) {
|
|
6293
|
-
return [
|
|
6294
|
-
3,
|
|
6295
|
-
8
|
|
6296
|
-
];
|
|
6297
|
-
}
|
|
6298
|
-
if (this.deps.isInAdBreak() && !this.deps.timing.hasTimeToStartAnotherAd()) {
|
|
6299
|
-
if (this.deps.debug) {
|
|
6300
|
-
console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
|
|
6301
|
-
}
|
|
6302
|
-
return [
|
|
6303
|
-
3,
|
|
6304
|
-
8
|
|
6305
|
-
];
|
|
6306
|
-
}
|
|
6307
|
-
newUrls = this.deps.generateVastUrlsWithCorrelators(baseVastUrl, 1);
|
|
6308
|
-
newUrl = newUrls[0];
|
|
6309
|
-
if (!(newUrl && !this.deps.timing.failedVastUrls.has(newUrl) && !this.deps.timing.isUrlInCooldown(newUrl))) return [
|
|
6310
|
-
3,
|
|
6311
|
-
6
|
|
6312
|
-
];
|
|
6313
|
-
return [
|
|
6314
|
-
4,
|
|
6315
|
-
this.preloadAdIntoPool(newUrl)
|
|
6316
|
-
];
|
|
6317
|
-
case 5:
|
|
6318
|
-
_state.sent();
|
|
6319
|
-
_state.label = 6;
|
|
6320
|
-
case 6:
|
|
6321
|
-
return [
|
|
6322
|
-
4,
|
|
6323
|
-
new Promise(function(resolve) {
|
|
6324
|
-
return setTimeout(resolve, 1e3);
|
|
6325
|
-
})
|
|
6326
|
-
];
|
|
6327
|
-
case 7:
|
|
6328
|
-
_state.sent();
|
|
6329
|
-
return [
|
|
6330
|
-
3,
|
|
6331
|
-
4
|
|
6332
|
-
];
|
|
6333
|
-
case 8:
|
|
6334
|
-
return [
|
|
6335
|
-
4,
|
|
6336
|
-
new Promise(function(resolve) {
|
|
6337
|
-
return setTimeout(resolve, 2e3);
|
|
6338
|
-
})
|
|
6339
|
-
];
|
|
6340
|
-
case 9:
|
|
6341
|
-
_state.sent();
|
|
6342
|
-
return [
|
|
6343
|
-
3,
|
|
6344
|
-
1
|
|
6345
|
-
];
|
|
6346
|
-
case 10:
|
|
6347
|
-
this.loopRunning = false;
|
|
6348
|
-
if (this.deps.debug) {
|
|
6349
|
-
console.log("[PRELOAD-POOL] Preload loop ended");
|
|
6350
|
-
}
|
|
6351
|
-
return [
|
|
6352
|
-
2
|
|
6353
|
-
];
|
|
6354
|
-
}
|
|
6355
|
-
});
|
|
6356
|
-
}).call(this);
|
|
6357
|
-
}
|
|
6358
|
-
},
|
|
6359
|
-
{
|
|
6360
|
-
key: "getPreloadedAd",
|
|
6361
|
-
value: function getPreloadedAd() {
|
|
6362
|
-
if (this.pool.length === 0) {
|
|
6363
|
-
return null;
|
|
6364
|
-
}
|
|
6365
|
-
var entry = this.pool.shift();
|
|
6366
|
-
if (!entry || !entry.isReady) {
|
|
6367
|
-
return null;
|
|
6368
|
-
}
|
|
6369
|
-
if (this.deps.debug) {
|
|
6370
|
-
console.log("[PRELOAD-POOL] Using preloaded ad from pool (".concat(this.pool.length, " remaining)"));
|
|
6371
|
-
}
|
|
6372
|
-
return {
|
|
6373
|
-
vastUrl: entry.vastUrl,
|
|
6374
|
-
adController: entry.adController
|
|
6375
|
-
};
|
|
6376
|
-
}
|
|
6377
|
-
},
|
|
6378
|
-
{
|
|
6379
|
-
key: "stop",
|
|
6380
|
-
value: function stop() {
|
|
6381
|
-
this.poolActive = false;
|
|
6382
|
-
this.loopRunning = false;
|
|
6383
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
6384
|
-
try {
|
|
6385
|
-
for(var _iterator = this.pool[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
6386
|
-
var entry = _step.value;
|
|
6387
|
-
try {
|
|
6388
|
-
entry.adController.destroy();
|
|
6389
|
-
} catch (error) {
|
|
6390
|
-
if (this.deps.debug) {
|
|
6391
|
-
console.warn("[PRELOAD-POOL] Error destroying preloaded controller:", error);
|
|
6392
|
-
}
|
|
6393
|
-
}
|
|
6394
|
-
}
|
|
6395
|
-
} catch (err) {
|
|
6396
|
-
_didIteratorError = true;
|
|
6397
|
-
_iteratorError = err;
|
|
6398
|
-
} finally{
|
|
6399
|
-
try {
|
|
6400
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
6401
|
-
_iterator.return();
|
|
6402
|
-
}
|
|
6403
|
-
} finally{
|
|
6404
|
-
if (_didIteratorError) {
|
|
6405
|
-
throw _iteratorError;
|
|
6406
|
-
}
|
|
6407
|
-
}
|
|
6408
|
-
}
|
|
6409
|
-
this.pool = [];
|
|
6410
|
-
if (this.deps.debug) {
|
|
6411
|
-
console.log("[PRELOAD-POOL] Preload pool stopped and cleaned up");
|
|
6412
|
-
}
|
|
6413
|
-
}
|
|
6414
|
-
}
|
|
6415
|
-
]);
|
|
6416
|
-
return AdPreloadPool;
|
|
6417
|
-
}();
|
|
6418
|
-
// src/player/PlaceholderLayer.ts
|
|
6419
|
-
var PlaceholderLayer = /*#__PURE__*/ function() {
|
|
6420
|
-
"use strict";
|
|
6421
|
-
function PlaceholderLayer(video, debug) {
|
|
6422
|
-
_class_call_check(this, PlaceholderLayer);
|
|
6423
|
-
this.video = video;
|
|
6424
|
-
this.debug = debug;
|
|
6425
|
-
}
|
|
6426
|
-
_create_class(PlaceholderLayer, [
|
|
6427
|
-
{
|
|
6428
|
-
key: "ensureContainer",
|
|
6429
|
-
value: function ensureContainer() {
|
|
6430
|
-
if (this.container) {
|
|
6431
|
-
return;
|
|
6432
|
-
}
|
|
6433
|
-
var el = document.createElement("div");
|
|
6434
|
-
el.style.position = "absolute";
|
|
6435
|
-
el.style.left = "0";
|
|
6436
|
-
el.style.top = "0";
|
|
6437
|
-
el.style.right = "0";
|
|
6438
|
-
el.style.bottom = "0";
|
|
6439
|
-
el.style.display = "none";
|
|
6440
|
-
el.style.alignItems = "center";
|
|
6441
|
-
el.style.justifyContent = "center";
|
|
6442
|
-
el.style.pointerEvents = "none";
|
|
6443
|
-
el.style.zIndex = "5";
|
|
6444
|
-
el.style.backgroundColor = "#000";
|
|
6445
|
-
el.style.transition = "opacity 0.3s ease-in-out";
|
|
6446
|
-
el.style.opacity = "0";
|
|
6447
|
-
if (!this.video.parentElement) {
|
|
6448
|
-
if (this.debug) {
|
|
6449
|
-
console.warn("[StormcloudVideoPlayer] Video element has no parent for placeholder container");
|
|
6450
|
-
}
|
|
6451
|
-
return;
|
|
6452
|
-
}
|
|
6453
|
-
this.video.parentElement.appendChild(el);
|
|
6454
|
-
this.container = el;
|
|
6455
|
-
}
|
|
6456
|
-
},
|
|
6457
|
-
{
|
|
6458
|
-
key: "show",
|
|
6459
|
-
value: function show() {
|
|
6460
|
-
var _this = this;
|
|
6461
|
-
this.ensureContainer();
|
|
6462
|
-
if (!this.container) {
|
|
6463
|
-
return;
|
|
6464
|
-
}
|
|
6465
|
-
if (!this.video.muted) {
|
|
6466
|
-
this.video.muted = true;
|
|
6467
|
-
if (this.debug) {
|
|
6468
|
-
console.log("[StormcloudVideoPlayer] Muted video when showing placeholder");
|
|
6469
|
-
}
|
|
6470
|
-
}
|
|
6471
|
-
var wasHidden = this.container.style.display === "none" || this.container.style.opacity === "0";
|
|
6472
|
-
if (wasHidden) {
|
|
6473
|
-
this.container.style.transition = "none";
|
|
6474
|
-
} else {
|
|
6475
|
-
this.container.style.transition = "opacity 0.3s ease-in-out";
|
|
6476
|
-
}
|
|
6477
|
-
this.container.style.backgroundColor = "#000";
|
|
6478
|
-
this.container.style.display = "flex";
|
|
6479
|
-
this.container.offsetHeight;
|
|
6480
|
-
this.container.style.opacity = "1";
|
|
6481
|
-
this.container.style.pointerEvents = "auto";
|
|
6482
|
-
if (wasHidden) {
|
|
6483
|
-
requestAnimationFrame(function() {
|
|
6484
|
-
if (_this.container) {
|
|
6485
|
-
_this.container.style.transition = "opacity 0.3s ease-in-out";
|
|
6486
|
-
}
|
|
6487
|
-
});
|
|
6488
|
-
}
|
|
6489
|
-
if (this.debug) {
|
|
6490
|
-
console.log("[StormcloudVideoPlayer] Showing placeholder layer (between content and ad layer)");
|
|
6491
|
-
}
|
|
6492
|
-
}
|
|
6493
|
-
},
|
|
6494
|
-
{
|
|
6495
|
-
key: "hide",
|
|
6496
|
-
value: function hide() {
|
|
6497
|
-
var _this = this;
|
|
6498
|
-
if (!this.container) {
|
|
6499
|
-
return;
|
|
6500
|
-
}
|
|
6501
|
-
this.container.style.opacity = "0";
|
|
6502
|
-
setTimeout(function() {
|
|
6503
|
-
if (_this.container) {
|
|
6504
|
-
_this.container.style.display = "none";
|
|
6505
|
-
_this.container.style.pointerEvents = "none";
|
|
6506
|
-
_this.container.style.backgroundColor = "#000";
|
|
6507
|
-
}
|
|
6508
|
-
}, 300);
|
|
6509
|
-
if (this.debug) {
|
|
6510
|
-
console.log("[StormcloudVideoPlayer] Hiding placeholder layer");
|
|
6511
|
-
}
|
|
6512
|
-
}
|
|
6513
|
-
},
|
|
6514
|
-
{
|
|
6515
|
-
key: "destroy",
|
|
6516
|
-
value: function destroy() {
|
|
6517
|
-
if (this.container) {
|
|
6518
|
-
if (this.container.parentElement) {
|
|
6519
|
-
this.container.parentElement.removeChild(this.container);
|
|
6520
|
-
}
|
|
6521
|
-
this.container = void 0;
|
|
6522
|
-
}
|
|
6523
|
-
}
|
|
6524
|
-
}
|
|
6525
|
-
]);
|
|
6526
|
-
return PlaceholderLayer;
|
|
6527
|
-
}();
|
|
6528
|
-
// src/player/HlsEngine.ts
|
|
6529
|
-
import Hls2 from "hls.js";
|
|
6530
|
-
var HlsEngine = /*#__PURE__*/ function() {
|
|
6531
|
-
"use strict";
|
|
6532
|
-
function HlsEngine(config, video, cueManager, timing, callbacks) {
|
|
6533
|
-
_class_call_check(this, HlsEngine);
|
|
6534
|
-
this.isLiveStream = false;
|
|
6535
|
-
this.nativeHlsMode = false;
|
|
6536
|
-
this.videoSrcProtection = null;
|
|
6537
|
-
this.bufferedSegmentsCount = 0;
|
|
6538
|
-
this.shouldAutoplayAfterBuffering = false;
|
|
6539
|
-
this.hasInitialBufferCompleted = false;
|
|
6540
|
-
this.config = config;
|
|
6541
|
-
this.video = video;
|
|
6542
|
-
this.cueManager = cueManager;
|
|
6543
|
-
this.timing = timing;
|
|
6544
|
-
this.callbacks = callbacks;
|
|
6545
|
-
}
|
|
6546
|
-
_create_class(HlsEngine, [
|
|
6547
|
-
{
|
|
6548
|
-
key: "debug",
|
|
6549
|
-
get: function get() {
|
|
6550
|
-
return !!this.config.debugAdTiming;
|
|
6551
|
-
}
|
|
6552
|
-
},
|
|
6553
|
-
{
|
|
6554
|
-
key: "shouldUseNativeHls",
|
|
6555
|
-
value: function shouldUseNativeHls(getStreamType) {
|
|
6556
|
-
var streamType = getStreamType();
|
|
6557
|
-
if (streamType === "other") {
|
|
6558
|
-
return true;
|
|
6559
|
-
}
|
|
6560
|
-
var canNative = this.video.canPlayType("application/vnd.apple.mpegurl");
|
|
6561
|
-
return !!(this.config.allowNativeHls && canNative);
|
|
6562
|
-
}
|
|
6563
|
-
},
|
|
6564
|
-
{
|
|
6565
|
-
key: "setupNativeHls",
|
|
6566
|
-
value: function setupNativeHls() {
|
|
6567
|
-
return _async_to_generator(function() {
|
|
6568
|
-
var _this_config_isLiveStream, _this_config_lowLatencyMode, adBehavior, _this_video_play;
|
|
6111
|
+
var _this_config_isLiveStream, _this_config_lowLatencyMode, adBehavior, _this_video_play;
|
|
6569
6112
|
return _ts_generator(this, function(_state) {
|
|
6570
6113
|
switch(_state.label){
|
|
6571
6114
|
case 0:
|
|
@@ -7139,7 +6682,7 @@ function resizePlayer(video, adPlayer, debug) {
|
|
|
7139
6682
|
// src/player/AdBreakOrchestrator.ts
|
|
7140
6683
|
var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
7141
6684
|
"use strict";
|
|
7142
|
-
function AdBreakOrchestrator(host, timing,
|
|
6685
|
+
function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
|
|
7143
6686
|
_class_call_check(this, AdBreakOrchestrator);
|
|
7144
6687
|
this.inAdBreak = false;
|
|
7145
6688
|
this.showAds = false;
|
|
@@ -7153,7 +6696,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
7153
6696
|
this.pendingAdBreak = null;
|
|
7154
6697
|
this.host = host;
|
|
7155
6698
|
this.timing = timing;
|
|
7156
|
-
this.preloadPool = preloadPool;
|
|
7157
6699
|
this.adConfig = adConfig;
|
|
7158
6700
|
this.cueManager = cueManager;
|
|
7159
6701
|
this.placeholder = placeholder;
|
|
@@ -7172,23 +6714,19 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
7172
6714
|
}
|
|
7173
6715
|
},
|
|
7174
6716
|
{
|
|
7175
|
-
|
|
7176
|
-
get: // ───────────────────────────────────────────────────────────────
|
|
6717
|
+
// ───────────────────────────────────────────────────────────────
|
|
7177
6718
|
// IMA event listeners
|
|
7178
6719
|
// ───────────────────────────────────────────────────────────────
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
6720
|
+
/**
|
|
6721
|
+
* Produces the next pod ad-request URL for the current break. Every request
|
|
6722
|
+
* (initial and continuous-fetch top-up) carries pod macros (pmad/pmnd/pmxd,
|
|
6723
|
+
* no ppos); pmxd tracks the remaining break time so top-up pods only ask for
|
|
6724
|
+
* what still fits.
|
|
6725
|
+
*/ key: "nextAdRequestUrl",
|
|
7185
6726
|
value: function nextAdRequestUrl(baseVastUrl) {
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
|
|
7190
|
-
}
|
|
7191
|
-
return this.host.generateVastUrls(baseVastUrl, 1)[0];
|
|
6727
|
+
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
6728
|
+
var breakDurationMs = remaining > 0 ? remaining : void 0;
|
|
6729
|
+
return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
|
|
7192
6730
|
}
|
|
7193
6731
|
},
|
|
7194
6732
|
{
|
|
@@ -7360,340 +6898,76 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
7360
6898
|
// ───────────────────────────────────────────────────────────────
|
|
7361
6899
|
function handleAdStart(_marker) {
|
|
7362
6900
|
return _async_to_generator(function() {
|
|
7363
|
-
var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed
|
|
6901
|
+
var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
|
|
7364
6902
|
return _ts_generator(this, function(_state) {
|
|
7365
6903
|
switch(_state.label){
|
|
7366
6904
|
case 0:
|
|
7367
6905
|
scheduled = this.adConfig.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
|
|
7368
6906
|
if (scheduled) {
|
|
7369
|
-
this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
|
|
7370
|
-
}
|
|
7371
|
-
tags = this.adConfig.selectVastTagsForBreak(scheduled);
|
|
7372
|
-
if (tags && tags.length > 0 && tags[0]) {
|
|
7373
|
-
baseVastUrl = tags[0];
|
|
7374
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
7375
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
7376
|
-
} else {
|
|
7377
|
-
this.clearPendingAdBreak();
|
|
7378
|
-
return [
|
|
7379
|
-
2
|
|
7380
|
-
];
|
|
7381
|
-
}
|
|
7382
|
-
adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
|
|
7383
|
-
if (this.debug) {
|
|
7384
|
-
mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
|
|
7385
|
-
console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
7386
|
-
}
|
|
7387
|
-
this.timing.failedVastUrls.clear();
|
|
7388
|
-
this.timing.temporaryFailureUrls.clear();
|
|
7389
|
-
this.timing.consecutiveFailures = 0;
|
|
7390
|
-
this.continuousFetchingActive = true;
|
|
7391
|
-
this.isShowingPlaceholder = false;
|
|
7392
|
-
this.timing.totalAdRequestsInBreak = 0;
|
|
7393
|
-
if (this.adConfig.podAssignedByPrefetch) {
|
|
7394
|
-
this.adConfig.podAssignedByPrefetch = false;
|
|
7395
|
-
} else {
|
|
7396
|
-
this.adConfig.beginNewAdPod();
|
|
7397
|
-
}
|
|
7398
|
-
currentMuted = this.host.video.muted;
|
|
7399
|
-
currentVolume = this.host.video.volume;
|
|
7400
|
-
this.host.getAdPlayer().updateOriginalMutedState(currentMuted, currentVolume);
|
|
7401
|
-
this.inAdBreak = true;
|
|
7402
|
-
this.timing.adBreakPlayedDurationMs = 0;
|
|
7403
|
-
this.timing.currentAdIndex = 0;
|
|
7404
|
-
this.timing.totalAdsInBreak = 0;
|
|
7405
|
-
this.adPodQueue = [];
|
|
7406
|
-
this.showAds = false;
|
|
7407
|
-
if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
7408
|
-
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
7409
|
-
}
|
|
7410
|
-
if (!this.optimizedPodsEnabled) return [
|
|
7411
|
-
3,
|
|
7412
|
-
2
|
|
7413
|
-
];
|
|
7414
|
-
return [
|
|
7415
|
-
4,
|
|
7416
|
-
this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
|
|
7417
|
-
];
|
|
7418
|
-
case 1:
|
|
7419
|
-
podPlayed = _state.sent();
|
|
7420
|
-
if (podPlayed) {
|
|
7421
|
-
return [
|
|
7422
|
-
2
|
|
7423
|
-
];
|
|
7424
|
-
}
|
|
7425
|
-
if (this.debug) {
|
|
7426
|
-
console.log("[POD] Optimized pod unavailable, falling back to sequential single-ad path");
|
|
7427
|
-
}
|
|
7428
|
-
_state.label = 2;
|
|
7429
|
-
case 2:
|
|
7430
|
-
usePreloadedAd = false;
|
|
7431
|
-
preloaded = this.preloadPool.getPreloadedAd();
|
|
7432
|
-
if (preloaded) {
|
|
7433
|
-
firstAdUrl = preloaded.vastUrl;
|
|
7434
|
-
preloadedController = preloaded.adController;
|
|
7435
|
-
usePreloadedAd = true;
|
|
7436
|
-
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
7437
|
-
source: "hls",
|
|
7438
|
-
vastUrl: firstAdUrl,
|
|
7439
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
7440
|
-
}, this.analyticsContext).catch(function() {});
|
|
7441
|
-
if (this.debug) {
|
|
7442
|
-
console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
|
|
7443
|
-
}
|
|
7444
|
-
} else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
|
|
7445
|
-
this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
|
|
7446
|
-
firstAdUrl = this.adRequestQueue.shift();
|
|
7447
|
-
if (this.debug) {
|
|
7448
|
-
console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
|
|
7449
|
-
}
|
|
7450
|
-
this.clearPendingAdBreak();
|
|
7451
|
-
} else {
|
|
7452
|
-
if (this.debug) {
|
|
7453
|
-
console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
|
|
7454
|
-
}
|
|
7455
|
-
firstAdUrl = this.nextAdRequestUrl(baseVastUrl);
|
|
7456
|
-
this.adRequestQueue = [];
|
|
7457
|
-
}
|
|
7458
|
-
if (!firstAdUrl) {
|
|
7459
|
-
if (this.debug) {
|
|
7460
|
-
console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
|
|
7461
|
-
}
|
|
7462
|
-
this.handleAdPodComplete();
|
|
7463
|
-
return [
|
|
7464
|
-
2
|
|
7465
|
-
];
|
|
7466
|
-
}
|
|
7467
|
-
if (this.debug) {
|
|
7468
|
-
console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
|
|
7469
|
-
}
|
|
7470
|
-
_state.label = 3;
|
|
7471
|
-
case 3:
|
|
7472
|
-
_state.trys.push([
|
|
7473
|
-
3,
|
|
7474
|
-
14,
|
|
7475
|
-
,
|
|
7476
|
-
22
|
|
7477
|
-
]);
|
|
7478
|
-
if (!(usePreloadedAd && preloadedController)) return [
|
|
7479
|
-
3,
|
|
7480
|
-
7
|
|
7481
|
-
];
|
|
7482
|
-
if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
|
|
7483
|
-
3,
|
|
7484
|
-
5
|
|
7485
|
-
];
|
|
7486
|
-
this.timing.rejectLoadedAdForDuration(preloadedController);
|
|
7487
|
-
this.startContinuousFetching(baseVastUrl);
|
|
7488
|
-
return [
|
|
7489
|
-
4,
|
|
7490
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
7491
|
-
];
|
|
7492
|
-
case 4:
|
|
7493
|
-
_state.sent();
|
|
7494
|
-
return [
|
|
7495
|
-
2
|
|
7496
|
-
];
|
|
7497
|
-
case 5:
|
|
7498
|
-
adPlayer = this.host.getAdPlayer();
|
|
7499
|
-
preservedMuted = adPlayer.getOriginalMutedState();
|
|
7500
|
-
preservedVolume = adPlayer.getOriginalVolume();
|
|
7501
|
-
adPlayer.destroy();
|
|
7502
|
-
this.host.video.muted = true;
|
|
7503
|
-
this.host.setAdPlayer(preloadedController);
|
|
7504
|
-
preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
|
|
7505
|
-
this.attachImaEventListeners();
|
|
7506
|
-
if (this.debug) {
|
|
7507
|
-
console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
|
|
7508
|
-
}
|
|
7509
|
-
preloadedController.resume();
|
|
7510
|
-
this.timing.consecutiveFailures = 0;
|
|
7511
|
-
this.startContinuousFetching(baseVastUrl);
|
|
7512
|
-
if (!this.optimizedPodsEnabled) {
|
|
7513
|
-
if (!this.preloadPool.active) {
|
|
7514
|
-
this.preloadPool.active = true;
|
|
7515
|
-
}
|
|
7516
|
-
if (!this.preloadPool.isLoopRunning) {
|
|
7517
|
-
this.preloadPool.preloadPoolLoop(baseVastUrl);
|
|
7518
|
-
}
|
|
7519
|
-
}
|
|
7520
|
-
return [
|
|
7521
|
-
4,
|
|
7522
|
-
preloadedController.play()
|
|
7523
|
-
];
|
|
7524
|
-
case 6:
|
|
7525
|
-
_state.sent();
|
|
7526
|
-
this.timing.markAdStarted();
|
|
7527
|
-
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
7528
|
-
this.timing.scheduleAdStopAtBreakBoundary();
|
|
7529
|
-
}
|
|
7530
|
-
adVolume = currentMuted ? 0 : currentVolume;
|
|
7531
|
-
preloadedController.setAdVolume(adVolume);
|
|
7532
|
-
return [
|
|
7533
|
-
3,
|
|
7534
|
-
13
|
|
7535
|
-
];
|
|
7536
|
-
case 7:
|
|
7537
|
-
adPlayer1 = this.host.getAdPlayer();
|
|
7538
|
-
return [
|
|
7539
|
-
4,
|
|
7540
|
-
this.timing.enforceGlobalRateLimit()
|
|
7541
|
-
];
|
|
7542
|
-
case 8:
|
|
7543
|
-
_state.sent();
|
|
7544
|
-
this.timing.lastAdRequestTime = Date.now();
|
|
7545
|
-
return [
|
|
7546
|
-
4,
|
|
7547
|
-
adPlayer1.requestAds(firstAdUrl)
|
|
7548
|
-
];
|
|
7549
|
-
case 9:
|
|
7550
|
-
_state.sent();
|
|
7551
|
-
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
7552
|
-
source: "hls",
|
|
7553
|
-
vastUrl: firstAdUrl,
|
|
7554
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
7555
|
-
}, this.analyticsContext).catch(function() {});
|
|
7556
|
-
if (this.debug) {
|
|
7557
|
-
console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
|
|
7558
|
-
}
|
|
7559
|
-
if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
|
|
7560
|
-
3,
|
|
7561
|
-
11
|
|
7562
|
-
];
|
|
7563
|
-
this.timing.rejectLoadedAdForDuration(adPlayer1);
|
|
7564
|
-
this.recreateAdController();
|
|
7565
|
-
this.startContinuousFetching(baseVastUrl);
|
|
7566
|
-
return [
|
|
7567
|
-
4,
|
|
7568
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
7569
|
-
];
|
|
7570
|
-
case 10:
|
|
7571
|
-
_state.sent();
|
|
7572
|
-
return [
|
|
7573
|
-
2
|
|
7574
|
-
];
|
|
7575
|
-
case 11:
|
|
7576
|
-
this.timing.consecutiveFailures = 0;
|
|
7577
|
-
this.startContinuousFetching(baseVastUrl);
|
|
7578
|
-
if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
|
|
7579
|
-
this.preloadPool.startPreloadPool(baseVastUrl, []);
|
|
7580
|
-
}
|
|
7581
|
-
return [
|
|
7582
|
-
4,
|
|
7583
|
-
adPlayer1.play()
|
|
7584
|
-
];
|
|
7585
|
-
case 12:
|
|
7586
|
-
_state.sent();
|
|
7587
|
-
this.timing.markAdStarted();
|
|
7588
|
-
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
7589
|
-
this.timing.scheduleAdStopAtBreakBoundary();
|
|
7590
|
-
}
|
|
7591
|
-
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
7592
|
-
adPlayer1.setAdVolume(adVolume1);
|
|
7593
|
-
_state.label = 13;
|
|
7594
|
-
case 13:
|
|
7595
|
-
return [
|
|
7596
|
-
3,
|
|
7597
|
-
22
|
|
7598
|
-
];
|
|
7599
|
-
case 14:
|
|
7600
|
-
error = _state.sent();
|
|
7601
|
-
if (this.debug) {
|
|
7602
|
-
console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
|
|
6907
|
+
this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
|
|
7603
6908
|
}
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
6909
|
+
tags = this.adConfig.selectVastTagsForBreak(scheduled);
|
|
6910
|
+
if (tags && tags.length > 0 && tags[0]) {
|
|
6911
|
+
baseVastUrl = tags[0];
|
|
6912
|
+
} else if (this.adConfig.apiVastTagUrl) {
|
|
6913
|
+
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
6914
|
+
} else {
|
|
6915
|
+
this.clearPendingAdBreak();
|
|
6916
|
+
return [
|
|
6917
|
+
2
|
|
6918
|
+
];
|
|
6919
|
+
}
|
|
6920
|
+
adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : scheduled === null || scheduled === void 0 ? void 0 : scheduled.durationMs;
|
|
7613
6921
|
if (this.debug) {
|
|
7614
|
-
|
|
6922
|
+
mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
|
|
6923
|
+
console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
7615
6924
|
}
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
_state.trys.push([
|
|
7619
|
-
15,
|
|
7620
|
-
19,
|
|
7621
|
-
,
|
|
7622
|
-
20
|
|
7623
|
-
]);
|
|
7624
|
-
if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
|
|
7625
|
-
3,
|
|
7626
|
-
17
|
|
7627
|
-
];
|
|
7628
|
-
this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
|
|
7629
|
-
this.startContinuousFetching(baseVastUrl);
|
|
7630
|
-
return [
|
|
7631
|
-
4,
|
|
7632
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
7633
|
-
];
|
|
7634
|
-
case 16:
|
|
7635
|
-
_state.sent();
|
|
7636
|
-
return [
|
|
7637
|
-
2
|
|
7638
|
-
];
|
|
7639
|
-
case 17:
|
|
7640
|
-
this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
|
|
6925
|
+
this.timing.failedVastUrls.clear();
|
|
6926
|
+
this.timing.temporaryFailureUrls.clear();
|
|
7641
6927
|
this.timing.consecutiveFailures = 0;
|
|
7642
|
-
this.
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
6928
|
+
this.continuousFetchingActive = true;
|
|
6929
|
+
this.isShowingPlaceholder = false;
|
|
6930
|
+
this.timing.totalAdRequestsInBreak = 0;
|
|
6931
|
+
if (this.adConfig.podAssignedByPrefetch) {
|
|
6932
|
+
this.adConfig.podAssignedByPrefetch = false;
|
|
6933
|
+
} else {
|
|
6934
|
+
this.adConfig.beginNewAdPod();
|
|
7646
6935
|
}
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
this.
|
|
7655
|
-
|
|
7656
|
-
|
|
6936
|
+
currentMuted = this.host.video.muted;
|
|
6937
|
+
currentVolume = this.host.video.volume;
|
|
6938
|
+
this.host.getAdPlayer().updateOriginalMutedState(currentMuted, currentVolume);
|
|
6939
|
+
this.inAdBreak = true;
|
|
6940
|
+
this.timing.adBreakPlayedDurationMs = 0;
|
|
6941
|
+
this.timing.currentAdIndex = 0;
|
|
6942
|
+
this.timing.totalAdsInBreak = 0;
|
|
6943
|
+
this.adPodQueue = [];
|
|
6944
|
+
this.showAds = false;
|
|
6945
|
+
if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
6946
|
+
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
7657
6947
|
}
|
|
7658
|
-
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
7659
|
-
ap.setAdVolume(adVolume2);
|
|
7660
6948
|
return [
|
|
7661
|
-
|
|
6949
|
+
4,
|
|
6950
|
+
this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
|
|
7662
6951
|
];
|
|
7663
|
-
case
|
|
7664
|
-
|
|
7665
|
-
if (
|
|
7666
|
-
console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
|
|
7667
|
-
}
|
|
7668
|
-
return [
|
|
6952
|
+
case 1:
|
|
6953
|
+
podPlayed = _state.sent();
|
|
6954
|
+
if (!!podPlayed) return [
|
|
7669
6955
|
3,
|
|
7670
|
-
|
|
6956
|
+
3
|
|
7671
6957
|
];
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
|
|
7675
|
-
if (this.debug) {
|
|
7676
|
-
console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
|
|
7677
|
-
}
|
|
7678
|
-
} else {
|
|
7679
|
-
this.timing.failedVastUrls.add(firstAdUrl);
|
|
7680
|
-
if (this.debug) {
|
|
7681
|
-
console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
|
|
7682
|
-
}
|
|
6958
|
+
if (this.debug) {
|
|
6959
|
+
console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
|
|
7683
6960
|
}
|
|
7684
|
-
this.
|
|
6961
|
+
this.continuousFetchingActive = true;
|
|
7685
6962
|
this.startContinuousFetching(baseVastUrl);
|
|
7686
6963
|
return [
|
|
7687
6964
|
4,
|
|
7688
6965
|
this.tryNextAvailableAdWithRateLimit()
|
|
7689
6966
|
];
|
|
7690
|
-
case
|
|
6967
|
+
case 2:
|
|
7691
6968
|
_state.sent();
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
22
|
|
7695
|
-
];
|
|
7696
|
-
case 22:
|
|
6969
|
+
_state.label = 3;
|
|
6970
|
+
case 3:
|
|
7697
6971
|
return [
|
|
7698
6972
|
2
|
|
7699
6973
|
];
|
|
@@ -7767,7 +7041,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
7767
7041
|
];
|
|
7768
7042
|
}
|
|
7769
7043
|
if (this.debug) {
|
|
7770
|
-
console.log(podCount === 1 ? "[POD] Response contained a single ad; playing it and enabling
|
|
7044
|
+
console.log(podCount === 1 ? "[POD] Response contained a single ad; playing it and enabling pod top-up" : "[POD] Optimized pod returned ".concat(podCount, " ads; playing pod in one controller"));
|
|
7771
7045
|
}
|
|
7772
7046
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
7773
7047
|
source: "hls",
|
|
@@ -7787,10 +7061,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
7787
7061
|
}
|
|
7788
7062
|
adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
|
|
7789
7063
|
this.timing.consecutiveFailures = 0;
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
this.startContinuousFetching(baseVastUrl);
|
|
7793
|
-
}
|
|
7064
|
+
this.continuousFetchingActive = true;
|
|
7065
|
+
this.startContinuousFetching(baseVastUrl);
|
|
7794
7066
|
return [
|
|
7795
7067
|
2,
|
|
7796
7068
|
true
|
|
@@ -7823,20 +7095,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
7823
7095
|
}).call(this);
|
|
7824
7096
|
}
|
|
7825
7097
|
},
|
|
7826
|
-
{
|
|
7827
|
-
key: "swapToPreloadedAdPlayer",
|
|
7828
|
-
value: function swapToPreloadedAdPlayer(preloadedController) {
|
|
7829
|
-
var adPlayer = this.host.getAdPlayer();
|
|
7830
|
-
var preservedMuted = adPlayer.getOriginalMutedState();
|
|
7831
|
-
var preservedVolume = adPlayer.getOriginalVolume();
|
|
7832
|
-
adPlayer.destroy();
|
|
7833
|
-
this.host.video.muted = true;
|
|
7834
|
-
this.host.setAdPlayer(preloadedController);
|
|
7835
|
-
this.attachImaEventListeners();
|
|
7836
|
-
preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
|
|
7837
|
-
preloadedController.resume();
|
|
7838
|
-
}
|
|
7839
|
-
},
|
|
7840
7098
|
{
|
|
7841
7099
|
// ───────────────────────────────────────────────────────────────
|
|
7842
7100
|
// Continuous fetching
|
|
@@ -8087,7 +7345,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8087
7345
|
value: function tryNextAvailableAd() {
|
|
8088
7346
|
var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
|
8089
7347
|
return _async_to_generator(function() {
|
|
8090
|
-
var remaining,
|
|
7348
|
+
var remaining, nextAdUrl, error, errorMessage, maxRetries;
|
|
8091
7349
|
return _ts_generator(this, function(_state) {
|
|
8092
7350
|
switch(_state.label){
|
|
8093
7351
|
case 0:
|
|
@@ -8125,132 +7383,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8125
7383
|
];
|
|
8126
7384
|
}
|
|
8127
7385
|
this.timing.cleanupTemporaryFailures();
|
|
8128
|
-
preloaded = this.preloadPool.getPreloadedAd();
|
|
8129
|
-
if (!preloaded) return [
|
|
8130
|
-
3,
|
|
8131
|
-
6
|
|
8132
|
-
];
|
|
8133
|
-
if (this.debug) {
|
|
8134
|
-
console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
|
|
8135
|
-
}
|
|
8136
|
-
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
8137
|
-
source: "hls",
|
|
8138
|
-
vastUrl: preloaded.vastUrl,
|
|
8139
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
8140
|
-
}, this.analyticsContext).catch(function() {});
|
|
8141
7386
|
_state.label = 1;
|
|
8142
7387
|
case 1:
|
|
8143
|
-
_state.trys.push([
|
|
8144
|
-
1,
|
|
8145
|
-
5,
|
|
8146
|
-
,
|
|
8147
|
-
6
|
|
8148
|
-
]);
|
|
8149
|
-
if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
|
|
8150
|
-
3,
|
|
8151
|
-
3
|
|
8152
|
-
];
|
|
8153
|
-
this.timing.rejectLoadedAdForDuration(preloaded.adController);
|
|
8154
|
-
return [
|
|
8155
|
-
4,
|
|
8156
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
8157
|
-
];
|
|
8158
|
-
case 2:
|
|
8159
|
-
_state.sent();
|
|
8160
|
-
return [
|
|
8161
|
-
2
|
|
8162
|
-
];
|
|
8163
|
-
case 3:
|
|
8164
|
-
this.swapToPreloadedAdPlayer(preloaded.adController);
|
|
8165
|
-
ap = this.host.getAdPlayer();
|
|
8166
|
-
return [
|
|
8167
|
-
4,
|
|
8168
|
-
ap.play()
|
|
8169
|
-
];
|
|
8170
|
-
case 4:
|
|
8171
|
-
_state.sent();
|
|
8172
|
-
this.timing.markAdStarted();
|
|
8173
|
-
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
8174
|
-
this.timing.scheduleAdStopAtBreakBoundary();
|
|
8175
|
-
}
|
|
8176
|
-
ap.setAdVolume(getAdAudioVolume(ap));
|
|
8177
|
-
this.timing.consecutiveFailures = 0;
|
|
8178
|
-
return [
|
|
8179
|
-
2
|
|
8180
|
-
];
|
|
8181
|
-
case 5:
|
|
8182
|
-
error = _state.sent();
|
|
8183
|
-
if (this.debug) {
|
|
8184
|
-
console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
|
|
8185
|
-
}
|
|
8186
|
-
return [
|
|
8187
|
-
3,
|
|
8188
|
-
6
|
|
8189
|
-
];
|
|
8190
|
-
case 6:
|
|
8191
7388
|
if (!(this.adRequestQueue.length > 0)) return [
|
|
8192
7389
|
3,
|
|
8193
|
-
|
|
7390
|
+
9
|
|
8194
7391
|
];
|
|
8195
7392
|
nextAdUrl = this.adRequestQueue.shift();
|
|
8196
7393
|
if (!nextAdUrl) return [
|
|
8197
7394
|
3,
|
|
8198
|
-
|
|
7395
|
+
1
|
|
8199
7396
|
];
|
|
8200
7397
|
if (this.timing.failedVastUrls.has(nextAdUrl)) {
|
|
8201
7398
|
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
|
|
8202
7399
|
return [
|
|
8203
7400
|
3,
|
|
8204
|
-
|
|
7401
|
+
1
|
|
8205
7402
|
];
|
|
8206
7403
|
}
|
|
8207
7404
|
if (this.timing.isUrlInCooldown(nextAdUrl)) {
|
|
8208
7405
|
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
|
|
8209
7406
|
return [
|
|
8210
7407
|
3,
|
|
8211
|
-
|
|
7408
|
+
1
|
|
8212
7409
|
];
|
|
8213
7410
|
}
|
|
8214
7411
|
if (this.debug) {
|
|
8215
7412
|
console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
|
|
8216
7413
|
}
|
|
8217
|
-
_state.label =
|
|
8218
|
-
case
|
|
7414
|
+
_state.label = 2;
|
|
7415
|
+
case 2:
|
|
8219
7416
|
_state.trys.push([
|
|
8220
|
-
|
|
8221
|
-
|
|
7417
|
+
2,
|
|
7418
|
+
4,
|
|
8222
7419
|
,
|
|
8223
|
-
|
|
7420
|
+
8
|
|
8224
7421
|
]);
|
|
8225
7422
|
return [
|
|
8226
7423
|
4,
|
|
8227
7424
|
this.playSingleAd(nextAdUrl)
|
|
8228
7425
|
];
|
|
8229
|
-
case
|
|
7426
|
+
case 3:
|
|
8230
7427
|
_state.sent();
|
|
8231
7428
|
this.timing.consecutiveFailures = 0;
|
|
8232
7429
|
return [
|
|
8233
7430
|
3,
|
|
8234
|
-
|
|
7431
|
+
8
|
|
8235
7432
|
];
|
|
8236
|
-
case
|
|
8237
|
-
|
|
8238
|
-
errorMessage =
|
|
7433
|
+
case 4:
|
|
7434
|
+
error = _state.sent();
|
|
7435
|
+
errorMessage = error.message;
|
|
8239
7436
|
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
|
|
8240
7437
|
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
8241
7438
|
3,
|
|
8242
|
-
|
|
7439
|
+
6
|
|
8243
7440
|
];
|
|
8244
7441
|
return [
|
|
8245
7442
|
4,
|
|
8246
7443
|
this.tryNextAvailableAdWithRateLimit()
|
|
8247
7444
|
];
|
|
8248
|
-
case
|
|
7445
|
+
case 5:
|
|
8249
7446
|
_state.sent();
|
|
8250
7447
|
return [
|
|
8251
7448
|
2
|
|
8252
7449
|
];
|
|
8253
|
-
case
|
|
7450
|
+
case 6:
|
|
8254
7451
|
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
8255
7452
|
this.timing.consecutiveFailures++;
|
|
8256
7453
|
}
|
|
@@ -8258,21 +7455,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8258
7455
|
4,
|
|
8259
7456
|
this.tryNextAvailableAdWithRateLimit()
|
|
8260
7457
|
];
|
|
8261
|
-
case
|
|
7458
|
+
case 7:
|
|
8262
7459
|
_state.sent();
|
|
8263
7460
|
return [
|
|
8264
7461
|
3,
|
|
8265
|
-
|
|
7462
|
+
8
|
|
8266
7463
|
];
|
|
8267
|
-
case
|
|
7464
|
+
case 8:
|
|
8268
7465
|
return [
|
|
8269
7466
|
2
|
|
8270
7467
|
];
|
|
8271
|
-
case
|
|
7468
|
+
case 9:
|
|
8272
7469
|
maxRetries = 3;
|
|
8273
7470
|
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
8274
7471
|
3,
|
|
8275
|
-
|
|
7472
|
+
12
|
|
8276
7473
|
];
|
|
8277
7474
|
if (this.debug) {
|
|
8278
7475
|
console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
@@ -8283,18 +7480,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8283
7480
|
return setTimeout(resolve, 500);
|
|
8284
7481
|
})
|
|
8285
7482
|
];
|
|
8286
|
-
case
|
|
7483
|
+
case 10:
|
|
8287
7484
|
_state.sent();
|
|
8288
7485
|
return [
|
|
8289
7486
|
4,
|
|
8290
7487
|
this.tryNextAvailableAd(retryCount + 1)
|
|
8291
7488
|
];
|
|
8292
|
-
case
|
|
7489
|
+
case 11:
|
|
8293
7490
|
_state.sent();
|
|
8294
7491
|
return [
|
|
8295
7492
|
2
|
|
8296
7493
|
];
|
|
8297
|
-
case
|
|
7494
|
+
case 12:
|
|
8298
7495
|
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
8299
7496
|
this.showPlaceholderAndWaitForAds();
|
|
8300
7497
|
} else {
|
|
@@ -8316,7 +7513,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8316
7513
|
// ───────────────────────────────────────────────────────────────
|
|
8317
7514
|
function playSingleAd(vastTagUrl) {
|
|
8318
7515
|
return _async_to_generator(function() {
|
|
8319
|
-
var adPlayer, requestToken, ap, playError,
|
|
7516
|
+
var adPlayer, requestToken, ap, playError, error, errorMessage;
|
|
8320
7517
|
return _ts_generator(this, function(_state) {
|
|
8321
7518
|
switch(_state.label){
|
|
8322
7519
|
case 0:
|
|
@@ -8348,9 +7545,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8348
7545
|
case 1:
|
|
8349
7546
|
_state.trys.push([
|
|
8350
7547
|
1,
|
|
8351
|
-
|
|
7548
|
+
8,
|
|
8352
7549
|
,
|
|
8353
|
-
|
|
7550
|
+
9
|
|
8354
7551
|
]);
|
|
8355
7552
|
return [
|
|
8356
7553
|
4,
|
|
@@ -8386,7 +7583,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8386
7583
|
4,
|
|
8387
7584
|
6,
|
|
8388
7585
|
,
|
|
8389
|
-
|
|
7586
|
+
7
|
|
8390
7587
|
]);
|
|
8391
7588
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
8392
7589
|
return [
|
|
@@ -8404,55 +7601,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8404
7601
|
this.timing.temporaryFailureUrls.delete(vastTagUrl);
|
|
8405
7602
|
return [
|
|
8406
7603
|
3,
|
|
8407
|
-
|
|
7604
|
+
7
|
|
8408
7605
|
];
|
|
8409
7606
|
case 6:
|
|
8410
7607
|
playError = _state.sent();
|
|
8411
7608
|
if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
|
|
8412
|
-
preloadedFallback = this.preloadPool.getPreloadedAd();
|
|
8413
|
-
if (!preloadedFallback) return [
|
|
8414
|
-
3,
|
|
8415
|
-
10
|
|
8416
|
-
];
|
|
8417
|
-
if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
|
|
8418
|
-
_state.label = 7;
|
|
8419
|
-
case 7:
|
|
8420
|
-
_state.trys.push([
|
|
8421
|
-
7,
|
|
8422
|
-
9,
|
|
8423
|
-
,
|
|
8424
|
-
10
|
|
8425
|
-
]);
|
|
8426
|
-
if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
|
|
8427
|
-
this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
|
|
8428
|
-
throw playError;
|
|
8429
|
-
}
|
|
8430
|
-
this.timing.clearAdFailsafeTimer();
|
|
8431
|
-
this.swapToPreloadedAdPlayer(preloadedFallback.adController);
|
|
8432
|
-
this.timing.consecutiveFailures = 0;
|
|
8433
|
-
fbAp = this.host.getAdPlayer();
|
|
8434
|
-
return [
|
|
8435
|
-
4,
|
|
8436
|
-
fbAp.play()
|
|
8437
|
-
];
|
|
8438
|
-
case 8:
|
|
8439
|
-
_state.sent();
|
|
8440
|
-
this.timing.markAdStarted();
|
|
8441
|
-
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
8442
|
-
this.timing.scheduleAdStopAtBreakBoundary();
|
|
8443
|
-
}
|
|
8444
|
-
fbAp.setAdVolume(getAdAudioVolume(fbAp));
|
|
8445
|
-
return [
|
|
8446
|
-
2
|
|
8447
|
-
];
|
|
8448
|
-
case 9:
|
|
8449
|
-
fallbackError = _state.sent();
|
|
8450
|
-
if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
|
|
8451
|
-
return [
|
|
8452
|
-
3,
|
|
8453
|
-
10
|
|
8454
|
-
];
|
|
8455
|
-
case 10:
|
|
8456
7609
|
if (this.timing.isTemporaryAdError(playError)) {
|
|
8457
7610
|
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
8458
7611
|
if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
|
|
@@ -8465,57 +7618,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8465
7618
|
this.timing.activeAdRequestToken = null;
|
|
8466
7619
|
}
|
|
8467
7620
|
throw playError;
|
|
8468
|
-
case
|
|
7621
|
+
case 7:
|
|
8469
7622
|
return [
|
|
8470
7623
|
3,
|
|
8471
|
-
|
|
7624
|
+
9
|
|
8472
7625
|
];
|
|
8473
|
-
case
|
|
7626
|
+
case 8:
|
|
8474
7627
|
error = _state.sent();
|
|
8475
7628
|
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
8476
7629
|
if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
|
|
8477
|
-
preloadedFallback1 = this.preloadPool.getPreloadedAd();
|
|
8478
|
-
if (!preloadedFallback1) return [
|
|
8479
|
-
3,
|
|
8480
|
-
16
|
|
8481
|
-
];
|
|
8482
|
-
if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
|
|
8483
|
-
_state.label = 13;
|
|
8484
|
-
case 13:
|
|
8485
|
-
_state.trys.push([
|
|
8486
|
-
13,
|
|
8487
|
-
15,
|
|
8488
|
-
,
|
|
8489
|
-
16
|
|
8490
|
-
]);
|
|
8491
|
-
if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
|
|
8492
|
-
this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
|
|
8493
|
-
throw error;
|
|
8494
|
-
}
|
|
8495
|
-
this.timing.clearAdRequestWatchdog();
|
|
8496
|
-
this.timing.clearAdFailsafeTimer();
|
|
8497
|
-
this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
|
|
8498
|
-
this.timing.consecutiveFailures = 0;
|
|
8499
|
-
fbAp1 = this.host.getAdPlayer();
|
|
8500
|
-
return [
|
|
8501
|
-
4,
|
|
8502
|
-
fbAp1.play()
|
|
8503
|
-
];
|
|
8504
|
-
case 14:
|
|
8505
|
-
_state.sent();
|
|
8506
|
-
this.timing.markAdStarted();
|
|
8507
|
-
fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
|
|
8508
|
-
return [
|
|
8509
|
-
2
|
|
8510
|
-
];
|
|
8511
|
-
case 15:
|
|
8512
|
-
fallbackError1 = _state.sent();
|
|
8513
|
-
if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
|
|
8514
|
-
return [
|
|
8515
|
-
3,
|
|
8516
|
-
16
|
|
8517
|
-
];
|
|
8518
|
-
case 16:
|
|
8519
7630
|
if (this.timing.isTemporaryAdError(error)) {
|
|
8520
7631
|
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
8521
7632
|
if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
|
|
@@ -8529,7 +7640,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8529
7640
|
this.timing.activeAdRequestToken = null;
|
|
8530
7641
|
}
|
|
8531
7642
|
throw error;
|
|
8532
|
-
case
|
|
7643
|
+
case 9:
|
|
8533
7644
|
return [
|
|
8534
7645
|
2
|
|
8535
7646
|
];
|
|
@@ -8719,7 +7830,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8719
7830
|
}
|
|
8720
7831
|
this.timing.resetForBreakEnd();
|
|
8721
7832
|
this.stopContinuousFetching();
|
|
8722
|
-
this.preloadPool.stop();
|
|
8723
7833
|
this.clearPendingAdBreak();
|
|
8724
7834
|
if (this.isShowingPlaceholder) {
|
|
8725
7835
|
this.host.getAdPlayer().hidePlaceholder();
|
|
@@ -8830,25 +7940,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8830
7940
|
return _this.adBreak.handleAdFailure();
|
|
8831
7941
|
}
|
|
8832
7942
|
});
|
|
8833
|
-
this.preloadPool = new AdPreloadPool({
|
|
8834
|
-
debug: !!this.config.debugAdTiming,
|
|
8835
|
-
createAdPlayer: function createAdPlayer(c) {
|
|
8836
|
-
return _this.createAdPlayer(c);
|
|
8837
|
-
},
|
|
8838
|
-
shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
|
|
8839
|
-
return _this.shouldContinueLiveStreamDuringAds();
|
|
8840
|
-
},
|
|
8841
|
-
timing: this.timing,
|
|
8842
|
-
generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
|
|
8843
|
-
return _this.generateVastUrls(base, count);
|
|
8844
|
-
},
|
|
8845
|
-
isInAdBreak: function isInAdBreak() {
|
|
8846
|
-
return _this.adBreak.inAdBreak;
|
|
8847
|
-
},
|
|
8848
|
-
getPendingAdBreak: function getPendingAdBreak() {
|
|
8849
|
-
return _this.adBreak.pendingAdBreak;
|
|
8850
|
-
}
|
|
8851
|
-
});
|
|
8852
7943
|
this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
|
|
8853
7944
|
this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
|
|
8854
7945
|
onManifestParsed: function onManifestParsed(isLive) {
|
|
@@ -8895,13 +7986,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8895
7986
|
getLiveSyncPosition: function getLiveSyncPosition() {
|
|
8896
7987
|
return _this.hlsEngine.getLiveSyncPosition();
|
|
8897
7988
|
},
|
|
8898
|
-
generateVastUrls: function generateVastUrls(base, count) {
|
|
8899
|
-
return _this.generateVastUrls(base, count);
|
|
8900
|
-
},
|
|
8901
7989
|
generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
|
|
8902
7990
|
return _this.generatePodVastUrl(base, breakDurationMs);
|
|
8903
7991
|
}
|
|
8904
|
-
}, this.timing, this.
|
|
7992
|
+
}, this.timing, this.adConfig, this.cueManager, this.placeholder);
|
|
8905
7993
|
}
|
|
8906
7994
|
_create_class(StormcloudVideoPlayer, [
|
|
8907
7995
|
{
|
|
@@ -8926,12 +8014,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
8926
8014
|
} : {}));
|
|
8927
8015
|
}
|
|
8928
8016
|
},
|
|
8929
|
-
{
|
|
8930
|
-
key: "generateVastUrls",
|
|
8931
|
-
value: function generateVastUrls(baseUrl, count) {
|
|
8932
|
-
return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
|
|
8933
|
-
}
|
|
8934
|
-
},
|
|
8935
8017
|
{
|
|
8936
8018
|
key: "generatePodVastUrl",
|
|
8937
8019
|
value: function generatePodVastUrl(baseUrl, breakDurationMs) {
|
|
@@ -9327,11 +8409,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9327
8409
|
}
|
|
9328
8410
|
this.adConfig.beginNewAdPod();
|
|
9329
8411
|
this.adConfig.podAssignedByPrefetch = true;
|
|
9330
|
-
var optimizedPods = this.config.optimizedPods !== false;
|
|
9331
8412
|
var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
|
|
9332
|
-
var generatedUrls =
|
|
8413
|
+
var generatedUrls = [
|
|
9333
8414
|
this.generatePodVastUrl(baseVastUrl, breakDurationMs)
|
|
9334
|
-
]
|
|
8415
|
+
];
|
|
9335
8416
|
this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
|
|
9336
8417
|
marker: marker
|
|
9337
8418
|
}, fragmentSn !== void 0 ? {
|
|
@@ -9353,15 +8434,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9353
8434
|
}, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
|
|
9354
8435
|
if (this.debug) {
|
|
9355
8436
|
console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
|
|
9356
|
-
console.log("[PREFETCH] Pre-generated
|
|
9357
|
-
}
|
|
9358
|
-
if (optimizedPods) {
|
|
9359
|
-
if (this.debug) {
|
|
9360
|
-
console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
|
|
9361
|
-
}
|
|
9362
|
-
return;
|
|
8437
|
+
console.log("[PREFETCH] Pre-generated pod request URL");
|
|
9363
8438
|
}
|
|
9364
|
-
this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
|
|
9365
8439
|
}
|
|
9366
8440
|
},
|
|
9367
8441
|
{
|
|
@@ -9600,7 +8674,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
9600
8674
|
value: function destroy() {
|
|
9601
8675
|
var _this_adPlayer;
|
|
9602
8676
|
this.adBreak.stopContinuousFetching();
|
|
9603
|
-
this.preloadPool.stop();
|
|
9604
8677
|
this.timing.destroy();
|
|
9605
8678
|
this.adBreak.clearPendingAdBreak();
|
|
9606
8679
|
this.placeholder.destroy();
|