stormcloud-video-player 0.8.63 → 0.8.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/StormcloudPlayer.cjs +121 -56
- package/lib/StormcloudPlayer.cjs.map +1 -1
- package/lib/index.cjs +121 -56
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +121 -56
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +63 -17
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +2 -0
- package/lib/player/StormcloudVideoPlayer.cjs +121 -56
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +121 -56
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +121 -56
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +81 -39
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +121 -56
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -933,6 +933,7 @@ function parseProgressOffset(offset) {
|
|
|
933
933
|
} : void 0;
|
|
934
934
|
}
|
|
935
935
|
var MAX_VAST_WRAPPER_DEPTH = 5;
|
|
936
|
+
var VAST_REQUEST_TIMEOUT_MS = 5e3;
|
|
936
937
|
var BEACON_TIMEOUT_MS = 3e4;
|
|
937
938
|
var inFlightBeacons = /* @__PURE__ */ new Set();
|
|
938
939
|
var VAST_ERROR_MEDIA_DISPLAY = 405;
|
|
@@ -1491,70 +1492,104 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1491
1492
|
function fetchVastXml(vastTagUrl) {
|
|
1492
1493
|
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
1493
1494
|
return _async_to_generator(function() {
|
|
1494
|
-
var requestVast, response, error;
|
|
1495
|
+
var controller, timeoutId, requestVast, response, error, error1;
|
|
1495
1496
|
return _ts_generator(this, function(_state) {
|
|
1496
1497
|
switch(_state.label){
|
|
1497
1498
|
case 0:
|
|
1499
|
+
controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1500
|
+
timeoutId = controller ? setTimeout(function() {
|
|
1501
|
+
return controller.abort();
|
|
1502
|
+
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
1498
1503
|
requestVast = function requestVast(creds) {
|
|
1499
|
-
return fetch(vastTagUrl, {
|
|
1504
|
+
return fetch(vastTagUrl, _object_spread({
|
|
1500
1505
|
mode: "cors",
|
|
1501
1506
|
credentials: creds,
|
|
1502
1507
|
headers: {
|
|
1503
1508
|
"Accept": "application/xml, text/xml, */*"
|
|
1504
1509
|
},
|
|
1505
1510
|
referrerPolicy: "no-referrer-when-downgrade"
|
|
1506
|
-
}
|
|
1511
|
+
}, controller ? {
|
|
1512
|
+
signal: controller.signal
|
|
1513
|
+
} : {}));
|
|
1507
1514
|
};
|
|
1508
1515
|
_state.label = 1;
|
|
1509
1516
|
case 1:
|
|
1510
1517
|
_state.trys.push([
|
|
1511
1518
|
1,
|
|
1512
|
-
|
|
1519
|
+
10,
|
|
1520
|
+
11,
|
|
1521
|
+
12
|
|
1522
|
+
]);
|
|
1523
|
+
_state.label = 2;
|
|
1524
|
+
case 2:
|
|
1525
|
+
_state.trys.push([
|
|
1526
|
+
2,
|
|
1527
|
+
4,
|
|
1513
1528
|
,
|
|
1514
|
-
|
|
1529
|
+
8
|
|
1515
1530
|
]);
|
|
1516
1531
|
return [
|
|
1517
1532
|
4,
|
|
1518
1533
|
requestVast(credentials)
|
|
1519
1534
|
];
|
|
1520
|
-
case
|
|
1535
|
+
case 3:
|
|
1521
1536
|
response = _state.sent();
|
|
1522
1537
|
return [
|
|
1523
1538
|
3,
|
|
1524
|
-
|
|
1539
|
+
8
|
|
1525
1540
|
];
|
|
1526
|
-
case
|
|
1541
|
+
case 4:
|
|
1527
1542
|
error = _state.sent();
|
|
1528
|
-
if (!(credentials !== "omit")) return [
|
|
1543
|
+
if (!(credentials !== "omit" && !(controller === null || controller === void 0 ? void 0 : controller.signal.aborted))) return [
|
|
1529
1544
|
3,
|
|
1530
|
-
|
|
1545
|
+
6
|
|
1531
1546
|
];
|
|
1532
1547
|
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
1533
1548
|
return [
|
|
1534
1549
|
4,
|
|
1535
1550
|
requestVast("omit")
|
|
1536
1551
|
];
|
|
1537
|
-
case
|
|
1552
|
+
case 5:
|
|
1538
1553
|
response = _state.sent();
|
|
1539
1554
|
return [
|
|
1540
1555
|
3,
|
|
1541
|
-
|
|
1556
|
+
7
|
|
1542
1557
|
];
|
|
1543
|
-
case 5:
|
|
1544
|
-
throw error;
|
|
1545
1558
|
case 6:
|
|
1559
|
+
throw error;
|
|
1560
|
+
case 7:
|
|
1546
1561
|
return [
|
|
1547
1562
|
3,
|
|
1548
|
-
|
|
1563
|
+
8
|
|
1549
1564
|
];
|
|
1550
|
-
case
|
|
1565
|
+
case 8:
|
|
1551
1566
|
if (!response.ok) {
|
|
1552
1567
|
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
1553
1568
|
}
|
|
1554
1569
|
return [
|
|
1555
|
-
|
|
1570
|
+
4,
|
|
1556
1571
|
response.text()
|
|
1557
1572
|
];
|
|
1573
|
+
case 9:
|
|
1574
|
+
return [
|
|
1575
|
+
2,
|
|
1576
|
+
_state.sent()
|
|
1577
|
+
];
|
|
1578
|
+
case 10:
|
|
1579
|
+
error1 = _state.sent();
|
|
1580
|
+
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1581
|
+
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1582
|
+
}
|
|
1583
|
+
throw error1;
|
|
1584
|
+
case 11:
|
|
1585
|
+
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1586
|
+
return [
|
|
1587
|
+
7
|
|
1588
|
+
];
|
|
1589
|
+
case 12:
|
|
1590
|
+
return [
|
|
1591
|
+
2
|
|
1592
|
+
];
|
|
1558
1593
|
}
|
|
1559
1594
|
});
|
|
1560
1595
|
})();
|
|
@@ -1640,7 +1675,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1640
1675
|
}
|
|
1641
1676
|
function fetchAndParsePod(vastTagUrl) {
|
|
1642
1677
|
return _async_to_generator(function() {
|
|
1643
|
-
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements, _root_getAttribute1, _empty_errorUrls, empty, _empty_errorCode, resolveAd, podElements, buffet, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step,
|
|
1678
|
+
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements, _root_getAttribute1, _empty_errorUrls, empty, _empty_errorCode, resolveAd, podElements, buffet, resolveAll, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, ad, err, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, ad1, err;
|
|
1644
1679
|
return _ts_generator(this, function(_state) {
|
|
1645
1680
|
switch(_state.label){
|
|
1646
1681
|
case 0:
|
|
@@ -1721,6 +1756,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1721
1756
|
buffet = adElements.filter(function(el) {
|
|
1722
1757
|
return getAdSequence(el) === void 0;
|
|
1723
1758
|
});
|
|
1759
|
+
resolveAll = function resolveAll(elements) {
|
|
1760
|
+
return Promise.all(elements.map(function(el) {
|
|
1761
|
+
return resolveAd(el).catch(function() {
|
|
1762
|
+
return null;
|
|
1763
|
+
});
|
|
1764
|
+
}));
|
|
1765
|
+
};
|
|
1724
1766
|
ads = [];
|
|
1725
1767
|
if (!(podElements.length === 0)) return [
|
|
1726
1768
|
3,
|
|
@@ -1735,27 +1777,26 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1735
1777
|
8,
|
|
1736
1778
|
9
|
|
1737
1779
|
]);
|
|
1738
|
-
|
|
1739
|
-
|
|
1780
|
+
return [
|
|
1781
|
+
4,
|
|
1782
|
+
resolveAll(buffet)
|
|
1783
|
+
];
|
|
1740
1784
|
case 3:
|
|
1785
|
+
_iterator = _state.sent()[Symbol.iterator]();
|
|
1786
|
+
_state.label = 4;
|
|
1787
|
+
case 4:
|
|
1741
1788
|
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
1742
1789
|
3,
|
|
1743
1790
|
6
|
|
1744
1791
|
];
|
|
1745
|
-
|
|
1746
|
-
return [
|
|
1747
|
-
4,
|
|
1748
|
-
resolveAd(adElement)
|
|
1749
|
-
];
|
|
1750
|
-
case 4:
|
|
1751
|
-
ad = _state.sent();
|
|
1792
|
+
ad = _step.value;
|
|
1752
1793
|
if (ad) ads.push(ad);
|
|
1753
1794
|
_state.label = 5;
|
|
1754
1795
|
case 5:
|
|
1755
1796
|
_iteratorNormalCompletion = true;
|
|
1756
1797
|
return [
|
|
1757
1798
|
3,
|
|
1758
|
-
|
|
1799
|
+
4
|
|
1759
1800
|
];
|
|
1760
1801
|
case 6:
|
|
1761
1802
|
return [
|
|
@@ -1798,20 +1839,19 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1798
1839
|
20,
|
|
1799
1840
|
21
|
|
1800
1841
|
]);
|
|
1801
|
-
|
|
1802
|
-
|
|
1842
|
+
return [
|
|
1843
|
+
4,
|
|
1844
|
+
resolveAll(podElements)
|
|
1845
|
+
];
|
|
1803
1846
|
case 12:
|
|
1847
|
+
_iterator1 = _state.sent()[Symbol.iterator]();
|
|
1848
|
+
_state.label = 13;
|
|
1849
|
+
case 13:
|
|
1804
1850
|
if (!!(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done)) return [
|
|
1805
1851
|
3,
|
|
1806
1852
|
18
|
|
1807
1853
|
];
|
|
1808
|
-
|
|
1809
|
-
return [
|
|
1810
|
-
4,
|
|
1811
|
-
resolveAd(adElement1)
|
|
1812
|
-
];
|
|
1813
|
-
case 13:
|
|
1814
|
-
ad1 = _state.sent();
|
|
1854
|
+
ad1 = _step1.value;
|
|
1815
1855
|
_state.label = 14;
|
|
1816
1856
|
case 14:
|
|
1817
1857
|
if (!(!ad1 && buffet.length > 0)) return [
|
|
@@ -1820,7 +1860,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1820
1860
|
];
|
|
1821
1861
|
return [
|
|
1822
1862
|
4,
|
|
1823
|
-
resolveAd(buffet.shift())
|
|
1863
|
+
resolveAd(buffet.shift()).catch(function() {
|
|
1864
|
+
return null;
|
|
1865
|
+
})
|
|
1824
1866
|
];
|
|
1825
1867
|
case 15:
|
|
1826
1868
|
ad1 = _state.sent();
|
|
@@ -1835,7 +1877,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1835
1877
|
_iteratorNormalCompletion1 = true;
|
|
1836
1878
|
return [
|
|
1837
1879
|
3,
|
|
1838
|
-
|
|
1880
|
+
13
|
|
1839
1881
|
];
|
|
1840
1882
|
case 18:
|
|
1841
1883
|
return [
|
|
@@ -8314,12 +8356,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8314
8356
|
adPlayer.on("ad_interaction", function(event) {
|
|
8315
8357
|
if (event) _this.host.onAdInteraction(event);
|
|
8316
8358
|
});
|
|
8317
|
-
adPlayer.on("
|
|
8318
|
-
sendAdImpressionTracking(_this.host.config.licenseKey, {
|
|
8359
|
+
adPlayer.on("ad_impression", function() {
|
|
8360
|
+
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
8319
8361
|
source: "hls",
|
|
8320
|
-
adIndex: _this.timing.currentAdIndex
|
|
8362
|
+
adIndex: _this.timing.currentAdIndex
|
|
8363
|
+
}, _this.currentVastUrl ? {
|
|
8364
|
+
adUrl: _this.currentVastUrl
|
|
8365
|
+
} : {}), {
|
|
8321
8366
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8322
|
-
}, _this.analyticsContext).catch(function() {});
|
|
8367
|
+
}), _this.analyticsContext).catch(function() {});
|
|
8368
|
+
});
|
|
8369
|
+
adPlayer.on("all_ads_completed", function() {
|
|
8323
8370
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
8324
8371
|
var remaining = _this.timing.getRemainingAdMs();
|
|
8325
8372
|
_this.timing.consecutiveFailures = 0;
|
|
@@ -8377,11 +8424,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8377
8424
|
}
|
|
8378
8425
|
});
|
|
8379
8426
|
adPlayer.on("content_resume", function() {
|
|
8380
|
-
sendAdImpressionTracking(_this.host.config.licenseKey, {
|
|
8381
|
-
source: "hls",
|
|
8382
|
-
adIndex: _this.timing.currentAdIndex,
|
|
8383
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8384
|
-
}, _this.analyticsContext).catch(function() {});
|
|
8385
8427
|
if (!_this.host.video.muted) {
|
|
8386
8428
|
_this.host.video.muted = true;
|
|
8387
8429
|
if (_this.debug) {
|
|
@@ -8577,7 +8619,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8577
8619
|
adPlayer = this.host.getAdPlayer();
|
|
8578
8620
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8579
8621
|
this.timing.activeAdRequestToken = requestToken;
|
|
8580
|
-
this.
|
|
8622
|
+
this.currentVastUrl = podUrl;
|
|
8581
8623
|
_state.label = 1;
|
|
8582
8624
|
case 1:
|
|
8583
8625
|
_state.trys.push([
|
|
@@ -8592,6 +8634,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8592
8634
|
];
|
|
8593
8635
|
case 2:
|
|
8594
8636
|
_state.sent();
|
|
8637
|
+
this.timing.startAdRequestWatchdog(requestToken);
|
|
8595
8638
|
this.timing.lastAdRequestTime = Date.now();
|
|
8596
8639
|
return [
|
|
8597
8640
|
4,
|
|
@@ -9080,13 +9123,33 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9080
9123
|
}
|
|
9081
9124
|
},
|
|
9082
9125
|
{
|
|
9083
|
-
|
|
9084
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
9126
|
+
// ───────────────────────────────────────────────────────────────
|
|
9085
9127
|
// Single ad playback
|
|
9086
9128
|
// ───────────────────────────────────────────────────────────────
|
|
9087
|
-
|
|
9129
|
+
key: "withCurrentPodBudget",
|
|
9130
|
+
value: function withCurrentPodBudget(vastTagUrl) {
|
|
9131
|
+
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
9132
|
+
if (!(remaining > 0)) return vastTagUrl;
|
|
9133
|
+
try {
|
|
9134
|
+
var url = new URL(vastTagUrl);
|
|
9135
|
+
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
9136
|
+
var maxMs = Math.round(remaining);
|
|
9137
|
+
url.searchParams.set("pmxd", String(maxMs));
|
|
9138
|
+
var minMs = Number(url.searchParams.get("pmnd"));
|
|
9139
|
+
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
9140
|
+
url.searchParams.set("pmnd", String(maxMs));
|
|
9141
|
+
}
|
|
9142
|
+
return url.toString();
|
|
9143
|
+
} catch (unused) {
|
|
9144
|
+
return vastTagUrl;
|
|
9145
|
+
}
|
|
9146
|
+
}
|
|
9147
|
+
},
|
|
9148
|
+
{
|
|
9149
|
+
key: "playSingleAd",
|
|
9150
|
+
value: function playSingleAd(vastTagUrl) {
|
|
9088
9151
|
return _async_to_generator(function() {
|
|
9089
|
-
var adPlayer, requestToken, ap, playError, error, errorMessage;
|
|
9152
|
+
var adPlayer, requestToken, ap, requestUrl, playError, error, errorMessage;
|
|
9090
9153
|
return _ts_generator(this, function(_state) {
|
|
9091
9154
|
switch(_state.label){
|
|
9092
9155
|
case 0:
|
|
@@ -9113,7 +9176,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9113
9176
|
this.recreateAdController();
|
|
9114
9177
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
9115
9178
|
this.timing.activeAdRequestToken = requestToken;
|
|
9116
|
-
this.timing.startAdRequestWatchdog(requestToken);
|
|
9117
9179
|
_state.label = 1;
|
|
9118
9180
|
case 1:
|
|
9119
9181
|
_state.trys.push([
|
|
@@ -9128,17 +9190,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
9128
9190
|
];
|
|
9129
9191
|
case 2:
|
|
9130
9192
|
_state.sent();
|
|
9193
|
+
this.timing.startAdRequestWatchdog(requestToken);
|
|
9131
9194
|
this.timing.lastAdRequestTime = Date.now();
|
|
9132
9195
|
ap = this.host.getAdPlayer();
|
|
9196
|
+
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9197
|
+
this.currentVastUrl = requestUrl;
|
|
9133
9198
|
return [
|
|
9134
9199
|
4,
|
|
9135
|
-
ap.requestAds(
|
|
9200
|
+
ap.requestAds(requestUrl)
|
|
9136
9201
|
];
|
|
9137
9202
|
case 3:
|
|
9138
9203
|
_state.sent();
|
|
9139
9204
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
9140
9205
|
source: "hls",
|
|
9141
|
-
vastUrl:
|
|
9206
|
+
vastUrl: requestUrl,
|
|
9142
9207
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
9143
9208
|
}, this.analyticsContext).catch(function() {});
|
|
9144
9209
|
this.timing.clearAdRequestWatchdog();
|