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/players/index.cjs
CHANGED
|
@@ -783,6 +783,7 @@ function parseProgressOffset(offset) {
|
|
|
783
783
|
} : void 0;
|
|
784
784
|
}
|
|
785
785
|
var MAX_VAST_WRAPPER_DEPTH = 5;
|
|
786
|
+
var VAST_REQUEST_TIMEOUT_MS = 5e3;
|
|
786
787
|
var BEACON_TIMEOUT_MS = 3e4;
|
|
787
788
|
var inFlightBeacons = /* @__PURE__ */ new Set();
|
|
788
789
|
var VAST_ERROR_MEDIA_DISPLAY = 405;
|
|
@@ -1341,70 +1342,104 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1341
1342
|
function fetchVastXml(vastTagUrl) {
|
|
1342
1343
|
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
1343
1344
|
return _async_to_generator(function() {
|
|
1344
|
-
var requestVast, response, error;
|
|
1345
|
+
var controller, timeoutId, requestVast, response, error, error1;
|
|
1345
1346
|
return _ts_generator(this, function(_state) {
|
|
1346
1347
|
switch(_state.label){
|
|
1347
1348
|
case 0:
|
|
1349
|
+
controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1350
|
+
timeoutId = controller ? setTimeout(function() {
|
|
1351
|
+
return controller.abort();
|
|
1352
|
+
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
1348
1353
|
requestVast = function requestVast(creds) {
|
|
1349
|
-
return fetch(vastTagUrl, {
|
|
1354
|
+
return fetch(vastTagUrl, _object_spread({
|
|
1350
1355
|
mode: "cors",
|
|
1351
1356
|
credentials: creds,
|
|
1352
1357
|
headers: {
|
|
1353
1358
|
"Accept": "application/xml, text/xml, */*"
|
|
1354
1359
|
},
|
|
1355
1360
|
referrerPolicy: "no-referrer-when-downgrade"
|
|
1356
|
-
}
|
|
1361
|
+
}, controller ? {
|
|
1362
|
+
signal: controller.signal
|
|
1363
|
+
} : {}));
|
|
1357
1364
|
};
|
|
1358
1365
|
_state.label = 1;
|
|
1359
1366
|
case 1:
|
|
1360
1367
|
_state.trys.push([
|
|
1361
1368
|
1,
|
|
1362
|
-
|
|
1369
|
+
10,
|
|
1370
|
+
11,
|
|
1371
|
+
12
|
|
1372
|
+
]);
|
|
1373
|
+
_state.label = 2;
|
|
1374
|
+
case 2:
|
|
1375
|
+
_state.trys.push([
|
|
1376
|
+
2,
|
|
1377
|
+
4,
|
|
1363
1378
|
,
|
|
1364
|
-
|
|
1379
|
+
8
|
|
1365
1380
|
]);
|
|
1366
1381
|
return [
|
|
1367
1382
|
4,
|
|
1368
1383
|
requestVast(credentials)
|
|
1369
1384
|
];
|
|
1370
|
-
case
|
|
1385
|
+
case 3:
|
|
1371
1386
|
response = _state.sent();
|
|
1372
1387
|
return [
|
|
1373
1388
|
3,
|
|
1374
|
-
|
|
1389
|
+
8
|
|
1375
1390
|
];
|
|
1376
|
-
case
|
|
1391
|
+
case 4:
|
|
1377
1392
|
error = _state.sent();
|
|
1378
|
-
if (!(credentials !== "omit")) return [
|
|
1393
|
+
if (!(credentials !== "omit" && !(controller === null || controller === void 0 ? void 0 : controller.signal.aborted))) return [
|
|
1379
1394
|
3,
|
|
1380
|
-
|
|
1395
|
+
6
|
|
1381
1396
|
];
|
|
1382
1397
|
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
1383
1398
|
return [
|
|
1384
1399
|
4,
|
|
1385
1400
|
requestVast("omit")
|
|
1386
1401
|
];
|
|
1387
|
-
case
|
|
1402
|
+
case 5:
|
|
1388
1403
|
response = _state.sent();
|
|
1389
1404
|
return [
|
|
1390
1405
|
3,
|
|
1391
|
-
|
|
1406
|
+
7
|
|
1392
1407
|
];
|
|
1393
|
-
case 5:
|
|
1394
|
-
throw error;
|
|
1395
1408
|
case 6:
|
|
1409
|
+
throw error;
|
|
1410
|
+
case 7:
|
|
1396
1411
|
return [
|
|
1397
1412
|
3,
|
|
1398
|
-
|
|
1413
|
+
8
|
|
1399
1414
|
];
|
|
1400
|
-
case
|
|
1415
|
+
case 8:
|
|
1401
1416
|
if (!response.ok) {
|
|
1402
1417
|
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
1403
1418
|
}
|
|
1404
1419
|
return [
|
|
1405
|
-
|
|
1420
|
+
4,
|
|
1406
1421
|
response.text()
|
|
1407
1422
|
];
|
|
1423
|
+
case 9:
|
|
1424
|
+
return [
|
|
1425
|
+
2,
|
|
1426
|
+
_state.sent()
|
|
1427
|
+
];
|
|
1428
|
+
case 10:
|
|
1429
|
+
error1 = _state.sent();
|
|
1430
|
+
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1431
|
+
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1432
|
+
}
|
|
1433
|
+
throw error1;
|
|
1434
|
+
case 11:
|
|
1435
|
+
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1436
|
+
return [
|
|
1437
|
+
7
|
|
1438
|
+
];
|
|
1439
|
+
case 12:
|
|
1440
|
+
return [
|
|
1441
|
+
2
|
|
1442
|
+
];
|
|
1408
1443
|
}
|
|
1409
1444
|
});
|
|
1410
1445
|
})();
|
|
@@ -1490,7 +1525,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1490
1525
|
}
|
|
1491
1526
|
function fetchAndParsePod(vastTagUrl) {
|
|
1492
1527
|
return _async_to_generator(function() {
|
|
1493
|
-
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements, _root_getAttribute1, _empty_errorUrls, empty, _empty_errorCode, resolveAd, podElements, buffet, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step,
|
|
1528
|
+
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;
|
|
1494
1529
|
return _ts_generator(this, function(_state) {
|
|
1495
1530
|
switch(_state.label){
|
|
1496
1531
|
case 0:
|
|
@@ -1571,6 +1606,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1571
1606
|
buffet = adElements.filter(function(el) {
|
|
1572
1607
|
return getAdSequence(el) === void 0;
|
|
1573
1608
|
});
|
|
1609
|
+
resolveAll = function resolveAll(elements) {
|
|
1610
|
+
return Promise.all(elements.map(function(el) {
|
|
1611
|
+
return resolveAd(el).catch(function() {
|
|
1612
|
+
return null;
|
|
1613
|
+
});
|
|
1614
|
+
}));
|
|
1615
|
+
};
|
|
1574
1616
|
ads = [];
|
|
1575
1617
|
if (!(podElements.length === 0)) return [
|
|
1576
1618
|
3,
|
|
@@ -1585,27 +1627,26 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1585
1627
|
8,
|
|
1586
1628
|
9
|
|
1587
1629
|
]);
|
|
1588
|
-
|
|
1589
|
-
|
|
1630
|
+
return [
|
|
1631
|
+
4,
|
|
1632
|
+
resolveAll(buffet)
|
|
1633
|
+
];
|
|
1590
1634
|
case 3:
|
|
1635
|
+
_iterator = _state.sent()[Symbol.iterator]();
|
|
1636
|
+
_state.label = 4;
|
|
1637
|
+
case 4:
|
|
1591
1638
|
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
1592
1639
|
3,
|
|
1593
1640
|
6
|
|
1594
1641
|
];
|
|
1595
|
-
|
|
1596
|
-
return [
|
|
1597
|
-
4,
|
|
1598
|
-
resolveAd(adElement)
|
|
1599
|
-
];
|
|
1600
|
-
case 4:
|
|
1601
|
-
ad = _state.sent();
|
|
1642
|
+
ad = _step.value;
|
|
1602
1643
|
if (ad) ads.push(ad);
|
|
1603
1644
|
_state.label = 5;
|
|
1604
1645
|
case 5:
|
|
1605
1646
|
_iteratorNormalCompletion = true;
|
|
1606
1647
|
return [
|
|
1607
1648
|
3,
|
|
1608
|
-
|
|
1649
|
+
4
|
|
1609
1650
|
];
|
|
1610
1651
|
case 6:
|
|
1611
1652
|
return [
|
|
@@ -1648,20 +1689,19 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1648
1689
|
20,
|
|
1649
1690
|
21
|
|
1650
1691
|
]);
|
|
1651
|
-
|
|
1652
|
-
|
|
1692
|
+
return [
|
|
1693
|
+
4,
|
|
1694
|
+
resolveAll(podElements)
|
|
1695
|
+
];
|
|
1653
1696
|
case 12:
|
|
1697
|
+
_iterator1 = _state.sent()[Symbol.iterator]();
|
|
1698
|
+
_state.label = 13;
|
|
1699
|
+
case 13:
|
|
1654
1700
|
if (!!(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done)) return [
|
|
1655
1701
|
3,
|
|
1656
1702
|
18
|
|
1657
1703
|
];
|
|
1658
|
-
|
|
1659
|
-
return [
|
|
1660
|
-
4,
|
|
1661
|
-
resolveAd(adElement1)
|
|
1662
|
-
];
|
|
1663
|
-
case 13:
|
|
1664
|
-
ad1 = _state.sent();
|
|
1704
|
+
ad1 = _step1.value;
|
|
1665
1705
|
_state.label = 14;
|
|
1666
1706
|
case 14:
|
|
1667
1707
|
if (!(!ad1 && buffet.length > 0)) return [
|
|
@@ -1670,7 +1710,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1670
1710
|
];
|
|
1671
1711
|
return [
|
|
1672
1712
|
4,
|
|
1673
|
-
resolveAd(buffet.shift())
|
|
1713
|
+
resolveAd(buffet.shift()).catch(function() {
|
|
1714
|
+
return null;
|
|
1715
|
+
})
|
|
1674
1716
|
];
|
|
1675
1717
|
case 15:
|
|
1676
1718
|
ad1 = _state.sent();
|
|
@@ -1685,7 +1727,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1685
1727
|
_iteratorNormalCompletion1 = true;
|
|
1686
1728
|
return [
|
|
1687
1729
|
3,
|
|
1688
|
-
|
|
1730
|
+
13
|
|
1689
1731
|
];
|
|
1690
1732
|
case 18:
|
|
1691
1733
|
return [
|
|
@@ -8158,12 +8200,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8158
8200
|
adPlayer.on("ad_interaction", function(event) {
|
|
8159
8201
|
if (event) _this.host.onAdInteraction(event);
|
|
8160
8202
|
});
|
|
8161
|
-
adPlayer.on("
|
|
8162
|
-
sendAdImpressionTracking(_this.host.config.licenseKey, {
|
|
8203
|
+
adPlayer.on("ad_impression", function() {
|
|
8204
|
+
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
8163
8205
|
source: "hls",
|
|
8164
|
-
adIndex: _this.timing.currentAdIndex
|
|
8206
|
+
adIndex: _this.timing.currentAdIndex
|
|
8207
|
+
}, _this.currentVastUrl ? {
|
|
8208
|
+
adUrl: _this.currentVastUrl
|
|
8209
|
+
} : {}), {
|
|
8165
8210
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8166
|
-
}, _this.analyticsContext).catch(function() {});
|
|
8211
|
+
}), _this.analyticsContext).catch(function() {});
|
|
8212
|
+
});
|
|
8213
|
+
adPlayer.on("all_ads_completed", function() {
|
|
8167
8214
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
8168
8215
|
var remaining = _this.timing.getRemainingAdMs();
|
|
8169
8216
|
_this.timing.consecutiveFailures = 0;
|
|
@@ -8221,11 +8268,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8221
8268
|
}
|
|
8222
8269
|
});
|
|
8223
8270
|
adPlayer.on("content_resume", function() {
|
|
8224
|
-
sendAdImpressionTracking(_this.host.config.licenseKey, {
|
|
8225
|
-
source: "hls",
|
|
8226
|
-
adIndex: _this.timing.currentAdIndex,
|
|
8227
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8228
|
-
}, _this.analyticsContext).catch(function() {});
|
|
8229
8271
|
if (!_this.host.video.muted) {
|
|
8230
8272
|
_this.host.video.muted = true;
|
|
8231
8273
|
if (_this.debug) {
|
|
@@ -8421,7 +8463,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8421
8463
|
adPlayer = this.host.getAdPlayer();
|
|
8422
8464
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8423
8465
|
this.timing.activeAdRequestToken = requestToken;
|
|
8424
|
-
this.
|
|
8466
|
+
this.currentVastUrl = podUrl;
|
|
8425
8467
|
_state.label = 1;
|
|
8426
8468
|
case 1:
|
|
8427
8469
|
_state.trys.push([
|
|
@@ -8436,6 +8478,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8436
8478
|
];
|
|
8437
8479
|
case 2:
|
|
8438
8480
|
_state.sent();
|
|
8481
|
+
this.timing.startAdRequestWatchdog(requestToken);
|
|
8439
8482
|
this.timing.lastAdRequestTime = Date.now();
|
|
8440
8483
|
return [
|
|
8441
8484
|
4,
|
|
@@ -8924,13 +8967,33 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8924
8967
|
}
|
|
8925
8968
|
},
|
|
8926
8969
|
{
|
|
8927
|
-
|
|
8928
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
8970
|
+
// ───────────────────────────────────────────────────────────────
|
|
8929
8971
|
// Single ad playback
|
|
8930
8972
|
// ───────────────────────────────────────────────────────────────
|
|
8931
|
-
|
|
8973
|
+
key: "withCurrentPodBudget",
|
|
8974
|
+
value: function withCurrentPodBudget(vastTagUrl) {
|
|
8975
|
+
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
8976
|
+
if (!(remaining > 0)) return vastTagUrl;
|
|
8977
|
+
try {
|
|
8978
|
+
var url = new URL(vastTagUrl);
|
|
8979
|
+
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
8980
|
+
var maxMs = Math.round(remaining);
|
|
8981
|
+
url.searchParams.set("pmxd", String(maxMs));
|
|
8982
|
+
var minMs = Number(url.searchParams.get("pmnd"));
|
|
8983
|
+
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
8984
|
+
url.searchParams.set("pmnd", String(maxMs));
|
|
8985
|
+
}
|
|
8986
|
+
return url.toString();
|
|
8987
|
+
} catch (unused) {
|
|
8988
|
+
return vastTagUrl;
|
|
8989
|
+
}
|
|
8990
|
+
}
|
|
8991
|
+
},
|
|
8992
|
+
{
|
|
8993
|
+
key: "playSingleAd",
|
|
8994
|
+
value: function playSingleAd(vastTagUrl) {
|
|
8932
8995
|
return _async_to_generator(function() {
|
|
8933
|
-
var adPlayer, requestToken, ap, playError, error, errorMessage;
|
|
8996
|
+
var adPlayer, requestToken, ap, requestUrl, playError, error, errorMessage;
|
|
8934
8997
|
return _ts_generator(this, function(_state) {
|
|
8935
8998
|
switch(_state.label){
|
|
8936
8999
|
case 0:
|
|
@@ -8957,7 +9020,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8957
9020
|
this.recreateAdController();
|
|
8958
9021
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8959
9022
|
this.timing.activeAdRequestToken = requestToken;
|
|
8960
|
-
this.timing.startAdRequestWatchdog(requestToken);
|
|
8961
9023
|
_state.label = 1;
|
|
8962
9024
|
case 1:
|
|
8963
9025
|
_state.trys.push([
|
|
@@ -8972,17 +9034,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8972
9034
|
];
|
|
8973
9035
|
case 2:
|
|
8974
9036
|
_state.sent();
|
|
9037
|
+
this.timing.startAdRequestWatchdog(requestToken);
|
|
8975
9038
|
this.timing.lastAdRequestTime = Date.now();
|
|
8976
9039
|
ap = this.host.getAdPlayer();
|
|
9040
|
+
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9041
|
+
this.currentVastUrl = requestUrl;
|
|
8977
9042
|
return [
|
|
8978
9043
|
4,
|
|
8979
|
-
ap.requestAds(
|
|
9044
|
+
ap.requestAds(requestUrl)
|
|
8980
9045
|
];
|
|
8981
9046
|
case 3:
|
|
8982
9047
|
_state.sent();
|
|
8983
9048
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
8984
9049
|
source: "hls",
|
|
8985
|
-
vastUrl:
|
|
9050
|
+
vastUrl: requestUrl,
|
|
8986
9051
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8987
9052
|
}, this.analyticsContext).catch(function() {});
|
|
8988
9053
|
this.timing.clearAdRequestWatchdog();
|