stormcloud-video-player 0.8.28 → 0.8.30
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 +80 -1038
- 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 +80 -1039
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +59 -483
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +9 -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 +80 -1038
- 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 +80 -1038
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +80 -1038
- package/lib/players/index.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 +80 -1038
- 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
|
@@ -1256,7 +1256,7 @@ function getAdAudioVolume(adPlayer) {
|
|
|
1256
1256
|
}
|
|
1257
1257
|
// src/player/AdBreakOrchestrator.ts
|
|
1258
1258
|
var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
1259
|
-
function AdBreakOrchestrator(host, timing,
|
|
1259
|
+
function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
|
|
1260
1260
|
_class_call_check(this, AdBreakOrchestrator);
|
|
1261
1261
|
this.inAdBreak = false;
|
|
1262
1262
|
this.showAds = false;
|
|
@@ -1270,7 +1270,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1270
1270
|
this.pendingAdBreak = null;
|
|
1271
1271
|
this.host = host;
|
|
1272
1272
|
this.timing = timing;
|
|
1273
|
-
this.preloadPool = preloadPool;
|
|
1274
1273
|
this.adConfig = adConfig;
|
|
1275
1274
|
this.cueManager = cueManager;
|
|
1276
1275
|
this.placeholder = placeholder;
|
|
@@ -1289,12 +1288,19 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1289
1288
|
}
|
|
1290
1289
|
},
|
|
1291
1290
|
{
|
|
1292
|
-
|
|
1293
|
-
get: // ───────────────────────────────────────────────────────────────
|
|
1291
|
+
// ───────────────────────────────────────────────────────────────
|
|
1294
1292
|
// IMA event listeners
|
|
1295
1293
|
// ───────────────────────────────────────────────────────────────
|
|
1296
|
-
|
|
1297
|
-
|
|
1294
|
+
/**
|
|
1295
|
+
* Produces the next pod ad-request URL for the current break. Every request
|
|
1296
|
+
* (initial and continuous-fetch top-up) carries pod macros (pmad/pmnd/pmxd,
|
|
1297
|
+
* no ppos); pmxd tracks the remaining break time so top-up pods only ask for
|
|
1298
|
+
* what still fits.
|
|
1299
|
+
*/ key: "nextAdRequestUrl",
|
|
1300
|
+
value: function nextAdRequestUrl(baseVastUrl) {
|
|
1301
|
+
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
1302
|
+
var breakDurationMs = remaining > 0 ? remaining : void 0;
|
|
1303
|
+
return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
|
|
1298
1304
|
}
|
|
1299
1305
|
},
|
|
1300
1306
|
{
|
|
@@ -1466,7 +1472,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1466
1472
|
// ───────────────────────────────────────────────────────────────
|
|
1467
1473
|
function handleAdStart(_marker) {
|
|
1468
1474
|
return _async_to_generator(function() {
|
|
1469
|
-
var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed
|
|
1475
|
+
var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
|
|
1470
1476
|
return _ts_generator(this, function(_state) {
|
|
1471
1477
|
switch(_state.label){
|
|
1472
1478
|
case 0:
|
|
@@ -1513,292 +1519,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1513
1519
|
if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
1514
1520
|
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
1515
1521
|
}
|
|
1516
|
-
if (!this.optimizedPodsEnabled) return [
|
|
1517
|
-
3,
|
|
1518
|
-
2
|
|
1519
|
-
];
|
|
1520
1522
|
return [
|
|
1521
1523
|
4,
|
|
1522
1524
|
this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
|
|
1523
1525
|
];
|
|
1524
1526
|
case 1:
|
|
1525
1527
|
podPlayed = _state.sent();
|
|
1526
|
-
if (podPlayed)
|
|
1527
|
-
return [
|
|
1528
|
-
2
|
|
1529
|
-
];
|
|
1530
|
-
}
|
|
1531
|
-
if (this.debug) {
|
|
1532
|
-
console.log("[POD] Optimized pod unavailable, falling back to sequential single-ad path");
|
|
1533
|
-
}
|
|
1534
|
-
_state.label = 2;
|
|
1535
|
-
case 2:
|
|
1536
|
-
usePreloadedAd = false;
|
|
1537
|
-
preloaded = this.preloadPool.getPreloadedAd();
|
|
1538
|
-
if (preloaded) {
|
|
1539
|
-
firstAdUrl = preloaded.vastUrl;
|
|
1540
|
-
preloadedController = preloaded.adController;
|
|
1541
|
-
usePreloadedAd = true;
|
|
1542
|
-
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
1543
|
-
source: "hls",
|
|
1544
|
-
vastUrl: firstAdUrl,
|
|
1545
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
1546
|
-
}, this.analyticsContext).catch(function() {});
|
|
1547
|
-
if (this.debug) {
|
|
1548
|
-
console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
|
|
1549
|
-
}
|
|
1550
|
-
} else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
|
|
1551
|
-
this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
|
|
1552
|
-
firstAdUrl = this.adRequestQueue.shift();
|
|
1553
|
-
if (this.debug) {
|
|
1554
|
-
console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
|
|
1555
|
-
}
|
|
1556
|
-
this.clearPendingAdBreak();
|
|
1557
|
-
} else {
|
|
1558
|
-
if (this.debug) {
|
|
1559
|
-
console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
|
|
1560
|
-
}
|
|
1561
|
-
firstAdUrlArray = this.host.generateVastUrls(baseVastUrl, 1);
|
|
1562
|
-
firstAdUrl = firstAdUrlArray[0];
|
|
1563
|
-
this.adRequestQueue = [];
|
|
1564
|
-
}
|
|
1565
|
-
if (!firstAdUrl) {
|
|
1566
|
-
if (this.debug) {
|
|
1567
|
-
console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
|
|
1568
|
-
}
|
|
1569
|
-
this.handleAdPodComplete();
|
|
1570
|
-
return [
|
|
1571
|
-
2
|
|
1572
|
-
];
|
|
1573
|
-
}
|
|
1574
|
-
if (this.debug) {
|
|
1575
|
-
console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
|
|
1576
|
-
}
|
|
1577
|
-
_state.label = 3;
|
|
1578
|
-
case 3:
|
|
1579
|
-
_state.trys.push([
|
|
1580
|
-
3,
|
|
1581
|
-
14,
|
|
1582
|
-
,
|
|
1583
|
-
22
|
|
1584
|
-
]);
|
|
1585
|
-
if (!(usePreloadedAd && preloadedController)) return [
|
|
1586
|
-
3,
|
|
1587
|
-
7
|
|
1588
|
-
];
|
|
1589
|
-
if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
|
|
1590
|
-
3,
|
|
1591
|
-
5
|
|
1592
|
-
];
|
|
1593
|
-
this.timing.rejectLoadedAdForDuration(preloadedController);
|
|
1594
|
-
this.startContinuousFetching(baseVastUrl);
|
|
1595
|
-
return [
|
|
1596
|
-
4,
|
|
1597
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
1598
|
-
];
|
|
1599
|
-
case 4:
|
|
1600
|
-
_state.sent();
|
|
1601
|
-
return [
|
|
1602
|
-
2
|
|
1603
|
-
];
|
|
1604
|
-
case 5:
|
|
1605
|
-
adPlayer = this.host.getAdPlayer();
|
|
1606
|
-
preservedMuted = adPlayer.getOriginalMutedState();
|
|
1607
|
-
preservedVolume = adPlayer.getOriginalVolume();
|
|
1608
|
-
adPlayer.destroy();
|
|
1609
|
-
this.host.video.muted = true;
|
|
1610
|
-
this.host.setAdPlayer(preloadedController);
|
|
1611
|
-
preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
|
|
1612
|
-
this.attachImaEventListeners();
|
|
1613
|
-
if (this.debug) {
|
|
1614
|
-
console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
|
|
1615
|
-
}
|
|
1616
|
-
preloadedController.resume();
|
|
1617
|
-
this.timing.consecutiveFailures = 0;
|
|
1618
|
-
this.startContinuousFetching(baseVastUrl);
|
|
1619
|
-
if (!this.preloadPool.active) {
|
|
1620
|
-
this.preloadPool.active = true;
|
|
1621
|
-
}
|
|
1622
|
-
if (!this.preloadPool.isLoopRunning) {
|
|
1623
|
-
this.preloadPool.preloadPoolLoop(baseVastUrl);
|
|
1624
|
-
}
|
|
1625
|
-
return [
|
|
1626
|
-
4,
|
|
1627
|
-
preloadedController.play()
|
|
1628
|
-
];
|
|
1629
|
-
case 6:
|
|
1630
|
-
_state.sent();
|
|
1631
|
-
this.timing.markAdStarted();
|
|
1632
|
-
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
1633
|
-
this.timing.scheduleAdStopAtBreakBoundary();
|
|
1634
|
-
}
|
|
1635
|
-
adVolume = currentMuted ? 0 : currentVolume;
|
|
1636
|
-
preloadedController.setAdVolume(adVolume);
|
|
1637
|
-
return [
|
|
1528
|
+
if (!!podPlayed) return [
|
|
1638
1529
|
3,
|
|
1639
|
-
|
|
1640
|
-
];
|
|
1641
|
-
case 7:
|
|
1642
|
-
adPlayer1 = this.host.getAdPlayer();
|
|
1643
|
-
return [
|
|
1644
|
-
4,
|
|
1645
|
-
this.timing.enforceGlobalRateLimit()
|
|
1646
|
-
];
|
|
1647
|
-
case 8:
|
|
1648
|
-
_state.sent();
|
|
1649
|
-
this.timing.lastAdRequestTime = Date.now();
|
|
1650
|
-
return [
|
|
1651
|
-
4,
|
|
1652
|
-
adPlayer1.requestAds(firstAdUrl)
|
|
1653
|
-
];
|
|
1654
|
-
case 9:
|
|
1655
|
-
_state.sent();
|
|
1656
|
-
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
1657
|
-
source: "hls",
|
|
1658
|
-
vastUrl: firstAdUrl,
|
|
1659
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
1660
|
-
}, this.analyticsContext).catch(function() {});
|
|
1661
|
-
if (this.debug) {
|
|
1662
|
-
console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
|
|
1663
|
-
}
|
|
1664
|
-
if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
|
|
1665
|
-
3,
|
|
1666
|
-
11
|
|
1667
|
-
];
|
|
1668
|
-
this.timing.rejectLoadedAdForDuration(adPlayer1);
|
|
1669
|
-
this.recreateAdController();
|
|
1670
|
-
this.startContinuousFetching(baseVastUrl);
|
|
1671
|
-
return [
|
|
1672
|
-
4,
|
|
1673
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
1674
|
-
];
|
|
1675
|
-
case 10:
|
|
1676
|
-
_state.sent();
|
|
1677
|
-
return [
|
|
1678
|
-
2
|
|
1679
|
-
];
|
|
1680
|
-
case 11:
|
|
1681
|
-
this.timing.consecutiveFailures = 0;
|
|
1682
|
-
this.startContinuousFetching(baseVastUrl);
|
|
1683
|
-
if (!this.preloadPool.active) {
|
|
1684
|
-
this.preloadPool.startPreloadPool(baseVastUrl, []);
|
|
1685
|
-
}
|
|
1686
|
-
return [
|
|
1687
|
-
4,
|
|
1688
|
-
adPlayer1.play()
|
|
1689
|
-
];
|
|
1690
|
-
case 12:
|
|
1691
|
-
_state.sent();
|
|
1692
|
-
this.timing.markAdStarted();
|
|
1693
|
-
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
1694
|
-
this.timing.scheduleAdStopAtBreakBoundary();
|
|
1695
|
-
}
|
|
1696
|
-
adVolume1 = currentMuted ? 0 : currentVolume;
|
|
1697
|
-
adPlayer1.setAdVolume(adVolume1);
|
|
1698
|
-
_state.label = 13;
|
|
1699
|
-
case 13:
|
|
1700
|
-
return [
|
|
1701
|
-
3,
|
|
1702
|
-
22
|
|
1703
|
-
];
|
|
1704
|
-
case 14:
|
|
1705
|
-
error = _state.sent();
|
|
1706
|
-
if (this.debug) {
|
|
1707
|
-
console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
|
|
1708
|
-
}
|
|
1709
|
-
if (!!usePreloadedAd) return [
|
|
1710
|
-
3,
|
|
1711
|
-
20
|
|
1712
|
-
];
|
|
1713
|
-
fallbackPreloaded = this.preloadPool.getPreloadedAd();
|
|
1714
|
-
if (!fallbackPreloaded) return [
|
|
1715
|
-
3,
|
|
1716
|
-
20
|
|
1717
|
-
];
|
|
1718
|
-
if (this.debug) {
|
|
1719
|
-
console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
|
|
1720
|
-
}
|
|
1721
|
-
_state.label = 15;
|
|
1722
|
-
case 15:
|
|
1723
|
-
_state.trys.push([
|
|
1724
|
-
15,
|
|
1725
|
-
19,
|
|
1726
|
-
,
|
|
1727
|
-
20
|
|
1728
|
-
]);
|
|
1729
|
-
if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
|
|
1730
|
-
3,
|
|
1731
|
-
17
|
|
1732
|
-
];
|
|
1733
|
-
this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
|
|
1734
|
-
this.startContinuousFetching(baseVastUrl);
|
|
1735
|
-
return [
|
|
1736
|
-
4,
|
|
1737
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
1738
|
-
];
|
|
1739
|
-
case 16:
|
|
1740
|
-
_state.sent();
|
|
1741
|
-
return [
|
|
1742
|
-
2
|
|
1743
|
-
];
|
|
1744
|
-
case 17:
|
|
1745
|
-
this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
|
|
1746
|
-
this.timing.consecutiveFailures = 0;
|
|
1747
|
-
this.startContinuousFetching(baseVastUrl);
|
|
1748
|
-
if (!this.preloadPool.active) {
|
|
1749
|
-
this.preloadPool.active = true;
|
|
1750
|
-
this.preloadPool.preloadPoolLoop(baseVastUrl);
|
|
1751
|
-
}
|
|
1752
|
-
ap = this.host.getAdPlayer();
|
|
1753
|
-
return [
|
|
1754
|
-
4,
|
|
1755
|
-
ap.play()
|
|
1756
|
-
];
|
|
1757
|
-
case 18:
|
|
1758
|
-
_state.sent();
|
|
1759
|
-
this.timing.markAdStarted();
|
|
1760
|
-
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
1761
|
-
this.timing.scheduleAdStopAtBreakBoundary();
|
|
1762
|
-
}
|
|
1763
|
-
adVolume2 = currentMuted ? 0 : currentVolume;
|
|
1764
|
-
ap.setAdVolume(adVolume2);
|
|
1765
|
-
return [
|
|
1766
|
-
2
|
|
1530
|
+
3
|
|
1767
1531
|
];
|
|
1768
|
-
case 19:
|
|
1769
|
-
fallbackError = _state.sent();
|
|
1770
1532
|
if (this.debug) {
|
|
1771
|
-
console.
|
|
1533
|
+
console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
|
|
1772
1534
|
}
|
|
1773
|
-
|
|
1774
|
-
3,
|
|
1775
|
-
20
|
|
1776
|
-
];
|
|
1777
|
-
case 20:
|
|
1778
|
-
if (this.timing.isTemporaryAdError(error)) {
|
|
1779
|
-
this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
|
|
1780
|
-
if (this.debug) {
|
|
1781
|
-
console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
|
|
1782
|
-
}
|
|
1783
|
-
} else {
|
|
1784
|
-
this.timing.failedVastUrls.add(firstAdUrl);
|
|
1785
|
-
if (this.debug) {
|
|
1786
|
-
console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
this.timing.consecutiveFailures++;
|
|
1535
|
+
this.continuousFetchingActive = true;
|
|
1790
1536
|
this.startContinuousFetching(baseVastUrl);
|
|
1791
1537
|
return [
|
|
1792
1538
|
4,
|
|
1793
1539
|
this.tryNextAvailableAdWithRateLimit()
|
|
1794
1540
|
];
|
|
1795
|
-
case
|
|
1541
|
+
case 2:
|
|
1796
1542
|
_state.sent();
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
22
|
|
1800
|
-
];
|
|
1801
|
-
case 22:
|
|
1543
|
+
_state.label = 3;
|
|
1544
|
+
case 3:
|
|
1802
1545
|
return [
|
|
1803
1546
|
2
|
|
1804
1547
|
];
|
|
@@ -1872,7 +1615,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1872
1615
|
];
|
|
1873
1616
|
}
|
|
1874
1617
|
if (this.debug) {
|
|
1875
|
-
console.log(podCount === 1 ? "[POD] Response contained a single ad; playing it and enabling
|
|
1618
|
+
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"));
|
|
1876
1619
|
}
|
|
1877
1620
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
1878
1621
|
source: "hls",
|
|
@@ -1892,13 +1635,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1892
1635
|
}
|
|
1893
1636
|
adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
|
|
1894
1637
|
this.timing.consecutiveFailures = 0;
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
this.startContinuousFetching(baseVastUrl);
|
|
1898
|
-
if (!this.preloadPool.active) {
|
|
1899
|
-
this.preloadPool.startPreloadPool(baseVastUrl, []);
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1638
|
+
this.continuousFetchingActive = true;
|
|
1639
|
+
this.startContinuousFetching(baseVastUrl);
|
|
1902
1640
|
return [
|
|
1903
1641
|
2,
|
|
1904
1642
|
true
|
|
@@ -1931,20 +1669,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1931
1669
|
}).call(this);
|
|
1932
1670
|
}
|
|
1933
1671
|
},
|
|
1934
|
-
{
|
|
1935
|
-
key: "swapToPreloadedAdPlayer",
|
|
1936
|
-
value: function swapToPreloadedAdPlayer(preloadedController) {
|
|
1937
|
-
var adPlayer = this.host.getAdPlayer();
|
|
1938
|
-
var preservedMuted = adPlayer.getOriginalMutedState();
|
|
1939
|
-
var preservedVolume = adPlayer.getOriginalVolume();
|
|
1940
|
-
adPlayer.destroy();
|
|
1941
|
-
this.host.video.muted = true;
|
|
1942
|
-
this.host.setAdPlayer(preloadedController);
|
|
1943
|
-
this.attachImaEventListeners();
|
|
1944
|
-
preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
|
|
1945
|
-
preloadedController.resume();
|
|
1946
|
-
}
|
|
1947
|
-
},
|
|
1948
1672
|
{
|
|
1949
1673
|
// ───────────────────────────────────────────────────────────────
|
|
1950
1674
|
// Continuous fetching
|
|
@@ -2038,7 +1762,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2038
1762
|
"continue"
|
|
2039
1763
|
];
|
|
2040
1764
|
case 2:
|
|
2041
|
-
newAdUrl = _this.
|
|
1765
|
+
newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
|
|
2042
1766
|
if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
|
|
2043
1767
|
3,
|
|
2044
1768
|
4
|
|
@@ -2195,7 +1919,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2195
1919
|
value: function tryNextAvailableAd() {
|
|
2196
1920
|
var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
|
2197
1921
|
return _async_to_generator(function() {
|
|
2198
|
-
var remaining,
|
|
1922
|
+
var remaining, nextAdUrl, error, errorMessage, maxRetries;
|
|
2199
1923
|
return _ts_generator(this, function(_state) {
|
|
2200
1924
|
switch(_state.label){
|
|
2201
1925
|
case 0:
|
|
@@ -2233,132 +1957,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2233
1957
|
];
|
|
2234
1958
|
}
|
|
2235
1959
|
this.timing.cleanupTemporaryFailures();
|
|
2236
|
-
preloaded = this.preloadPool.getPreloadedAd();
|
|
2237
|
-
if (!preloaded) return [
|
|
2238
|
-
3,
|
|
2239
|
-
6
|
|
2240
|
-
];
|
|
2241
|
-
if (this.debug) {
|
|
2242
|
-
console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
|
|
2243
|
-
}
|
|
2244
|
-
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
2245
|
-
source: "hls",
|
|
2246
|
-
vastUrl: preloaded.vastUrl,
|
|
2247
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
2248
|
-
}, this.analyticsContext).catch(function() {});
|
|
2249
1960
|
_state.label = 1;
|
|
2250
1961
|
case 1:
|
|
2251
|
-
_state.trys.push([
|
|
2252
|
-
1,
|
|
2253
|
-
5,
|
|
2254
|
-
,
|
|
2255
|
-
6
|
|
2256
|
-
]);
|
|
2257
|
-
if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
|
|
2258
|
-
3,
|
|
2259
|
-
3
|
|
2260
|
-
];
|
|
2261
|
-
this.timing.rejectLoadedAdForDuration(preloaded.adController);
|
|
2262
|
-
return [
|
|
2263
|
-
4,
|
|
2264
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
2265
|
-
];
|
|
2266
|
-
case 2:
|
|
2267
|
-
_state.sent();
|
|
2268
|
-
return [
|
|
2269
|
-
2
|
|
2270
|
-
];
|
|
2271
|
-
case 3:
|
|
2272
|
-
this.swapToPreloadedAdPlayer(preloaded.adController);
|
|
2273
|
-
ap = this.host.getAdPlayer();
|
|
2274
|
-
return [
|
|
2275
|
-
4,
|
|
2276
|
-
ap.play()
|
|
2277
|
-
];
|
|
2278
|
-
case 4:
|
|
2279
|
-
_state.sent();
|
|
2280
|
-
this.timing.markAdStarted();
|
|
2281
|
-
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
2282
|
-
this.timing.scheduleAdStopAtBreakBoundary();
|
|
2283
|
-
}
|
|
2284
|
-
ap.setAdVolume(getAdAudioVolume(ap));
|
|
2285
|
-
this.timing.consecutiveFailures = 0;
|
|
2286
|
-
return [
|
|
2287
|
-
2
|
|
2288
|
-
];
|
|
2289
|
-
case 5:
|
|
2290
|
-
error = _state.sent();
|
|
2291
|
-
if (this.debug) {
|
|
2292
|
-
console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
|
|
2293
|
-
}
|
|
2294
|
-
return [
|
|
2295
|
-
3,
|
|
2296
|
-
6
|
|
2297
|
-
];
|
|
2298
|
-
case 6:
|
|
2299
1962
|
if (!(this.adRequestQueue.length > 0)) return [
|
|
2300
1963
|
3,
|
|
2301
|
-
|
|
1964
|
+
9
|
|
2302
1965
|
];
|
|
2303
1966
|
nextAdUrl = this.adRequestQueue.shift();
|
|
2304
1967
|
if (!nextAdUrl) return [
|
|
2305
1968
|
3,
|
|
2306
|
-
|
|
1969
|
+
1
|
|
2307
1970
|
];
|
|
2308
1971
|
if (this.timing.failedVastUrls.has(nextAdUrl)) {
|
|
2309
1972
|
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
|
|
2310
1973
|
return [
|
|
2311
1974
|
3,
|
|
2312
|
-
|
|
1975
|
+
1
|
|
2313
1976
|
];
|
|
2314
1977
|
}
|
|
2315
1978
|
if (this.timing.isUrlInCooldown(nextAdUrl)) {
|
|
2316
1979
|
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
|
|
2317
1980
|
return [
|
|
2318
1981
|
3,
|
|
2319
|
-
|
|
1982
|
+
1
|
|
2320
1983
|
];
|
|
2321
1984
|
}
|
|
2322
1985
|
if (this.debug) {
|
|
2323
1986
|
console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
|
|
2324
1987
|
}
|
|
2325
|
-
_state.label =
|
|
2326
|
-
case
|
|
1988
|
+
_state.label = 2;
|
|
1989
|
+
case 2:
|
|
2327
1990
|
_state.trys.push([
|
|
2328
|
-
|
|
2329
|
-
|
|
1991
|
+
2,
|
|
1992
|
+
4,
|
|
2330
1993
|
,
|
|
2331
|
-
|
|
1994
|
+
8
|
|
2332
1995
|
]);
|
|
2333
1996
|
return [
|
|
2334
1997
|
4,
|
|
2335
1998
|
this.playSingleAd(nextAdUrl)
|
|
2336
1999
|
];
|
|
2337
|
-
case
|
|
2000
|
+
case 3:
|
|
2338
2001
|
_state.sent();
|
|
2339
2002
|
this.timing.consecutiveFailures = 0;
|
|
2340
2003
|
return [
|
|
2341
2004
|
3,
|
|
2342
|
-
|
|
2005
|
+
8
|
|
2343
2006
|
];
|
|
2344
|
-
case
|
|
2345
|
-
|
|
2346
|
-
errorMessage =
|
|
2007
|
+
case 4:
|
|
2008
|
+
error = _state.sent();
|
|
2009
|
+
errorMessage = error.message;
|
|
2347
2010
|
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
|
|
2348
2011
|
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
2349
2012
|
3,
|
|
2350
|
-
|
|
2013
|
+
6
|
|
2351
2014
|
];
|
|
2352
2015
|
return [
|
|
2353
2016
|
4,
|
|
2354
2017
|
this.tryNextAvailableAdWithRateLimit()
|
|
2355
2018
|
];
|
|
2356
|
-
case
|
|
2019
|
+
case 5:
|
|
2357
2020
|
_state.sent();
|
|
2358
2021
|
return [
|
|
2359
2022
|
2
|
|
2360
2023
|
];
|
|
2361
|
-
case
|
|
2024
|
+
case 6:
|
|
2362
2025
|
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
2363
2026
|
this.timing.consecutiveFailures++;
|
|
2364
2027
|
}
|
|
@@ -2366,21 +2029,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2366
2029
|
4,
|
|
2367
2030
|
this.tryNextAvailableAdWithRateLimit()
|
|
2368
2031
|
];
|
|
2369
|
-
case
|
|
2032
|
+
case 7:
|
|
2370
2033
|
_state.sent();
|
|
2371
2034
|
return [
|
|
2372
2035
|
3,
|
|
2373
|
-
|
|
2036
|
+
8
|
|
2374
2037
|
];
|
|
2375
|
-
case
|
|
2038
|
+
case 8:
|
|
2376
2039
|
return [
|
|
2377
2040
|
2
|
|
2378
2041
|
];
|
|
2379
|
-
case
|
|
2042
|
+
case 9:
|
|
2380
2043
|
maxRetries = 3;
|
|
2381
2044
|
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
2382
2045
|
3,
|
|
2383
|
-
|
|
2046
|
+
12
|
|
2384
2047
|
];
|
|
2385
2048
|
if (this.debug) {
|
|
2386
2049
|
console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
@@ -2391,18 +2054,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2391
2054
|
return setTimeout(resolve, 500);
|
|
2392
2055
|
})
|
|
2393
2056
|
];
|
|
2394
|
-
case
|
|
2057
|
+
case 10:
|
|
2395
2058
|
_state.sent();
|
|
2396
2059
|
return [
|
|
2397
2060
|
4,
|
|
2398
2061
|
this.tryNextAvailableAd(retryCount + 1)
|
|
2399
2062
|
];
|
|
2400
|
-
case
|
|
2063
|
+
case 11:
|
|
2401
2064
|
_state.sent();
|
|
2402
2065
|
return [
|
|
2403
2066
|
2
|
|
2404
2067
|
];
|
|
2405
|
-
case
|
|
2068
|
+
case 12:
|
|
2406
2069
|
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
2407
2070
|
this.showPlaceholderAndWaitForAds();
|
|
2408
2071
|
} else {
|
|
@@ -2424,7 +2087,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2424
2087
|
// ───────────────────────────────────────────────────────────────
|
|
2425
2088
|
function playSingleAd(vastTagUrl) {
|
|
2426
2089
|
return _async_to_generator(function() {
|
|
2427
|
-
var adPlayer, requestToken, ap, playError,
|
|
2090
|
+
var adPlayer, requestToken, ap, playError, error, errorMessage;
|
|
2428
2091
|
return _ts_generator(this, function(_state) {
|
|
2429
2092
|
switch(_state.label){
|
|
2430
2093
|
case 0:
|
|
@@ -2456,9 +2119,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2456
2119
|
case 1:
|
|
2457
2120
|
_state.trys.push([
|
|
2458
2121
|
1,
|
|
2459
|
-
|
|
2122
|
+
8,
|
|
2460
2123
|
,
|
|
2461
|
-
|
|
2124
|
+
9
|
|
2462
2125
|
]);
|
|
2463
2126
|
return [
|
|
2464
2127
|
4,
|
|
@@ -2494,7 +2157,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2494
2157
|
4,
|
|
2495
2158
|
6,
|
|
2496
2159
|
,
|
|
2497
|
-
|
|
2160
|
+
7
|
|
2498
2161
|
]);
|
|
2499
2162
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
2500
2163
|
return [
|
|
@@ -2512,55 +2175,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2512
2175
|
this.timing.temporaryFailureUrls.delete(vastTagUrl);
|
|
2513
2176
|
return [
|
|
2514
2177
|
3,
|
|
2515
|
-
|
|
2178
|
+
7
|
|
2516
2179
|
];
|
|
2517
2180
|
case 6:
|
|
2518
2181
|
playError = _state.sent();
|
|
2519
2182
|
if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
|
|
2520
|
-
preloadedFallback = this.preloadPool.getPreloadedAd();
|
|
2521
|
-
if (!preloadedFallback) return [
|
|
2522
|
-
3,
|
|
2523
|
-
10
|
|
2524
|
-
];
|
|
2525
|
-
if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
|
|
2526
|
-
_state.label = 7;
|
|
2527
|
-
case 7:
|
|
2528
|
-
_state.trys.push([
|
|
2529
|
-
7,
|
|
2530
|
-
9,
|
|
2531
|
-
,
|
|
2532
|
-
10
|
|
2533
|
-
]);
|
|
2534
|
-
if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
|
|
2535
|
-
this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
|
|
2536
|
-
throw playError;
|
|
2537
|
-
}
|
|
2538
|
-
this.timing.clearAdFailsafeTimer();
|
|
2539
|
-
this.swapToPreloadedAdPlayer(preloadedFallback.adController);
|
|
2540
|
-
this.timing.consecutiveFailures = 0;
|
|
2541
|
-
fbAp = this.host.getAdPlayer();
|
|
2542
|
-
return [
|
|
2543
|
-
4,
|
|
2544
|
-
fbAp.play()
|
|
2545
|
-
];
|
|
2546
|
-
case 8:
|
|
2547
|
-
_state.sent();
|
|
2548
|
-
this.timing.markAdStarted();
|
|
2549
|
-
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
2550
|
-
this.timing.scheduleAdStopAtBreakBoundary();
|
|
2551
|
-
}
|
|
2552
|
-
fbAp.setAdVolume(getAdAudioVolume(fbAp));
|
|
2553
|
-
return [
|
|
2554
|
-
2
|
|
2555
|
-
];
|
|
2556
|
-
case 9:
|
|
2557
|
-
fallbackError = _state.sent();
|
|
2558
|
-
if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
|
|
2559
|
-
return [
|
|
2560
|
-
3,
|
|
2561
|
-
10
|
|
2562
|
-
];
|
|
2563
|
-
case 10:
|
|
2564
2183
|
if (this.timing.isTemporaryAdError(playError)) {
|
|
2565
2184
|
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
2566
2185
|
if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
|
|
@@ -2573,57 +2192,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2573
2192
|
this.timing.activeAdRequestToken = null;
|
|
2574
2193
|
}
|
|
2575
2194
|
throw playError;
|
|
2576
|
-
case
|
|
2195
|
+
case 7:
|
|
2577
2196
|
return [
|
|
2578
2197
|
3,
|
|
2579
|
-
|
|
2198
|
+
9
|
|
2580
2199
|
];
|
|
2581
|
-
case
|
|
2200
|
+
case 8:
|
|
2582
2201
|
error = _state.sent();
|
|
2583
2202
|
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
2584
2203
|
if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
|
|
2585
|
-
preloadedFallback1 = this.preloadPool.getPreloadedAd();
|
|
2586
|
-
if (!preloadedFallback1) return [
|
|
2587
|
-
3,
|
|
2588
|
-
16
|
|
2589
|
-
];
|
|
2590
|
-
if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
|
|
2591
|
-
_state.label = 13;
|
|
2592
|
-
case 13:
|
|
2593
|
-
_state.trys.push([
|
|
2594
|
-
13,
|
|
2595
|
-
15,
|
|
2596
|
-
,
|
|
2597
|
-
16
|
|
2598
|
-
]);
|
|
2599
|
-
if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
|
|
2600
|
-
this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
|
|
2601
|
-
throw error;
|
|
2602
|
-
}
|
|
2603
|
-
this.timing.clearAdRequestWatchdog();
|
|
2604
|
-
this.timing.clearAdFailsafeTimer();
|
|
2605
|
-
this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
|
|
2606
|
-
this.timing.consecutiveFailures = 0;
|
|
2607
|
-
fbAp1 = this.host.getAdPlayer();
|
|
2608
|
-
return [
|
|
2609
|
-
4,
|
|
2610
|
-
fbAp1.play()
|
|
2611
|
-
];
|
|
2612
|
-
case 14:
|
|
2613
|
-
_state.sent();
|
|
2614
|
-
this.timing.markAdStarted();
|
|
2615
|
-
fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
|
|
2616
|
-
return [
|
|
2617
|
-
2
|
|
2618
|
-
];
|
|
2619
|
-
case 15:
|
|
2620
|
-
fallbackError1 = _state.sent();
|
|
2621
|
-
if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
|
|
2622
|
-
return [
|
|
2623
|
-
3,
|
|
2624
|
-
16
|
|
2625
|
-
];
|
|
2626
|
-
case 16:
|
|
2627
2204
|
if (this.timing.isTemporaryAdError(error)) {
|
|
2628
2205
|
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
2629
2206
|
if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
|
|
@@ -2637,7 +2214,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2637
2214
|
this.timing.activeAdRequestToken = null;
|
|
2638
2215
|
}
|
|
2639
2216
|
throw error;
|
|
2640
|
-
case
|
|
2217
|
+
case 9:
|
|
2641
2218
|
return [
|
|
2642
2219
|
2
|
|
2643
2220
|
];
|
|
@@ -2827,7 +2404,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2827
2404
|
}
|
|
2828
2405
|
this.timing.resetForBreakEnd();
|
|
2829
2406
|
this.stopContinuousFetching();
|
|
2830
|
-
this.preloadPool.stop();
|
|
2831
2407
|
this.clearPendingAdBreak();
|
|
2832
2408
|
if (this.isShowingPlaceholder) {
|
|
2833
2409
|
this.host.getAdPlayer().hidePlaceholder();
|