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/StormcloudPlayer.cjs
CHANGED
|
@@ -750,6 +750,7 @@ function parseProgressOffset(offset) {
|
|
|
750
750
|
} : void 0;
|
|
751
751
|
}
|
|
752
752
|
var MAX_VAST_WRAPPER_DEPTH = 5;
|
|
753
|
+
var VAST_REQUEST_TIMEOUT_MS = 5e3;
|
|
753
754
|
var BEACON_TIMEOUT_MS = 3e4;
|
|
754
755
|
var inFlightBeacons = /* @__PURE__ */ new Set();
|
|
755
756
|
var VAST_ERROR_MEDIA_DISPLAY = 405;
|
|
@@ -1308,70 +1309,104 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1308
1309
|
function fetchVastXml(vastTagUrl) {
|
|
1309
1310
|
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
1310
1311
|
return _async_to_generator(function() {
|
|
1311
|
-
var requestVast, response, error;
|
|
1312
|
+
var controller, timeoutId, requestVast, response, error, error1;
|
|
1312
1313
|
return _ts_generator(this, function(_state) {
|
|
1313
1314
|
switch(_state.label){
|
|
1314
1315
|
case 0:
|
|
1316
|
+
controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1317
|
+
timeoutId = controller ? setTimeout(function() {
|
|
1318
|
+
return controller.abort();
|
|
1319
|
+
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
1315
1320
|
requestVast = function requestVast(creds) {
|
|
1316
|
-
return fetch(vastTagUrl, {
|
|
1321
|
+
return fetch(vastTagUrl, _object_spread({
|
|
1317
1322
|
mode: "cors",
|
|
1318
1323
|
credentials: creds,
|
|
1319
1324
|
headers: {
|
|
1320
1325
|
"Accept": "application/xml, text/xml, */*"
|
|
1321
1326
|
},
|
|
1322
1327
|
referrerPolicy: "no-referrer-when-downgrade"
|
|
1323
|
-
}
|
|
1328
|
+
}, controller ? {
|
|
1329
|
+
signal: controller.signal
|
|
1330
|
+
} : {}));
|
|
1324
1331
|
};
|
|
1325
1332
|
_state.label = 1;
|
|
1326
1333
|
case 1:
|
|
1327
1334
|
_state.trys.push([
|
|
1328
1335
|
1,
|
|
1329
|
-
|
|
1336
|
+
10,
|
|
1337
|
+
11,
|
|
1338
|
+
12
|
|
1339
|
+
]);
|
|
1340
|
+
_state.label = 2;
|
|
1341
|
+
case 2:
|
|
1342
|
+
_state.trys.push([
|
|
1343
|
+
2,
|
|
1344
|
+
4,
|
|
1330
1345
|
,
|
|
1331
|
-
|
|
1346
|
+
8
|
|
1332
1347
|
]);
|
|
1333
1348
|
return [
|
|
1334
1349
|
4,
|
|
1335
1350
|
requestVast(credentials)
|
|
1336
1351
|
];
|
|
1337
|
-
case
|
|
1352
|
+
case 3:
|
|
1338
1353
|
response = _state.sent();
|
|
1339
1354
|
return [
|
|
1340
1355
|
3,
|
|
1341
|
-
|
|
1356
|
+
8
|
|
1342
1357
|
];
|
|
1343
|
-
case
|
|
1358
|
+
case 4:
|
|
1344
1359
|
error = _state.sent();
|
|
1345
|
-
if (!(credentials !== "omit")) return [
|
|
1360
|
+
if (!(credentials !== "omit" && !(controller === null || controller === void 0 ? void 0 : controller.signal.aborted))) return [
|
|
1346
1361
|
3,
|
|
1347
|
-
|
|
1362
|
+
6
|
|
1348
1363
|
];
|
|
1349
1364
|
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
1350
1365
|
return [
|
|
1351
1366
|
4,
|
|
1352
1367
|
requestVast("omit")
|
|
1353
1368
|
];
|
|
1354
|
-
case
|
|
1369
|
+
case 5:
|
|
1355
1370
|
response = _state.sent();
|
|
1356
1371
|
return [
|
|
1357
1372
|
3,
|
|
1358
|
-
|
|
1373
|
+
7
|
|
1359
1374
|
];
|
|
1360
|
-
case 5:
|
|
1361
|
-
throw error;
|
|
1362
1375
|
case 6:
|
|
1376
|
+
throw error;
|
|
1377
|
+
case 7:
|
|
1363
1378
|
return [
|
|
1364
1379
|
3,
|
|
1365
|
-
|
|
1380
|
+
8
|
|
1366
1381
|
];
|
|
1367
|
-
case
|
|
1382
|
+
case 8:
|
|
1368
1383
|
if (!response.ok) {
|
|
1369
1384
|
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
1370
1385
|
}
|
|
1371
1386
|
return [
|
|
1372
|
-
|
|
1387
|
+
4,
|
|
1373
1388
|
response.text()
|
|
1374
1389
|
];
|
|
1390
|
+
case 9:
|
|
1391
|
+
return [
|
|
1392
|
+
2,
|
|
1393
|
+
_state.sent()
|
|
1394
|
+
];
|
|
1395
|
+
case 10:
|
|
1396
|
+
error1 = _state.sent();
|
|
1397
|
+
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1398
|
+
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1399
|
+
}
|
|
1400
|
+
throw error1;
|
|
1401
|
+
case 11:
|
|
1402
|
+
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1403
|
+
return [
|
|
1404
|
+
7
|
|
1405
|
+
];
|
|
1406
|
+
case 12:
|
|
1407
|
+
return [
|
|
1408
|
+
2
|
|
1409
|
+
];
|
|
1375
1410
|
}
|
|
1376
1411
|
});
|
|
1377
1412
|
})();
|
|
@@ -1457,7 +1492,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1457
1492
|
}
|
|
1458
1493
|
function fetchAndParsePod(vastTagUrl) {
|
|
1459
1494
|
return _async_to_generator(function() {
|
|
1460
|
-
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements, _root_getAttribute1, _empty_errorUrls, empty, _empty_errorCode, resolveAd, podElements, buffet, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step,
|
|
1495
|
+
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;
|
|
1461
1496
|
return _ts_generator(this, function(_state) {
|
|
1462
1497
|
switch(_state.label){
|
|
1463
1498
|
case 0:
|
|
@@ -1538,6 +1573,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1538
1573
|
buffet = adElements.filter(function(el) {
|
|
1539
1574
|
return getAdSequence(el) === void 0;
|
|
1540
1575
|
});
|
|
1576
|
+
resolveAll = function resolveAll(elements) {
|
|
1577
|
+
return Promise.all(elements.map(function(el) {
|
|
1578
|
+
return resolveAd(el).catch(function() {
|
|
1579
|
+
return null;
|
|
1580
|
+
});
|
|
1581
|
+
}));
|
|
1582
|
+
};
|
|
1541
1583
|
ads = [];
|
|
1542
1584
|
if (!(podElements.length === 0)) return [
|
|
1543
1585
|
3,
|
|
@@ -1552,27 +1594,26 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1552
1594
|
8,
|
|
1553
1595
|
9
|
|
1554
1596
|
]);
|
|
1555
|
-
|
|
1556
|
-
|
|
1597
|
+
return [
|
|
1598
|
+
4,
|
|
1599
|
+
resolveAll(buffet)
|
|
1600
|
+
];
|
|
1557
1601
|
case 3:
|
|
1602
|
+
_iterator = _state.sent()[Symbol.iterator]();
|
|
1603
|
+
_state.label = 4;
|
|
1604
|
+
case 4:
|
|
1558
1605
|
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
1559
1606
|
3,
|
|
1560
1607
|
6
|
|
1561
1608
|
];
|
|
1562
|
-
|
|
1563
|
-
return [
|
|
1564
|
-
4,
|
|
1565
|
-
resolveAd(adElement)
|
|
1566
|
-
];
|
|
1567
|
-
case 4:
|
|
1568
|
-
ad = _state.sent();
|
|
1609
|
+
ad = _step.value;
|
|
1569
1610
|
if (ad) ads.push(ad);
|
|
1570
1611
|
_state.label = 5;
|
|
1571
1612
|
case 5:
|
|
1572
1613
|
_iteratorNormalCompletion = true;
|
|
1573
1614
|
return [
|
|
1574
1615
|
3,
|
|
1575
|
-
|
|
1616
|
+
4
|
|
1576
1617
|
];
|
|
1577
1618
|
case 6:
|
|
1578
1619
|
return [
|
|
@@ -1615,20 +1656,19 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1615
1656
|
20,
|
|
1616
1657
|
21
|
|
1617
1658
|
]);
|
|
1618
|
-
|
|
1619
|
-
|
|
1659
|
+
return [
|
|
1660
|
+
4,
|
|
1661
|
+
resolveAll(podElements)
|
|
1662
|
+
];
|
|
1620
1663
|
case 12:
|
|
1664
|
+
_iterator1 = _state.sent()[Symbol.iterator]();
|
|
1665
|
+
_state.label = 13;
|
|
1666
|
+
case 13:
|
|
1621
1667
|
if (!!(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done)) return [
|
|
1622
1668
|
3,
|
|
1623
1669
|
18
|
|
1624
1670
|
];
|
|
1625
|
-
|
|
1626
|
-
return [
|
|
1627
|
-
4,
|
|
1628
|
-
resolveAd(adElement1)
|
|
1629
|
-
];
|
|
1630
|
-
case 13:
|
|
1631
|
-
ad1 = _state.sent();
|
|
1671
|
+
ad1 = _step1.value;
|
|
1632
1672
|
_state.label = 14;
|
|
1633
1673
|
case 14:
|
|
1634
1674
|
if (!(!ad1 && buffet.length > 0)) return [
|
|
@@ -1637,7 +1677,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1637
1677
|
];
|
|
1638
1678
|
return [
|
|
1639
1679
|
4,
|
|
1640
|
-
resolveAd(buffet.shift())
|
|
1680
|
+
resolveAd(buffet.shift()).catch(function() {
|
|
1681
|
+
return null;
|
|
1682
|
+
})
|
|
1641
1683
|
];
|
|
1642
1684
|
case 15:
|
|
1643
1685
|
ad1 = _state.sent();
|
|
@@ -1652,7 +1694,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1652
1694
|
_iteratorNormalCompletion1 = true;
|
|
1653
1695
|
return [
|
|
1654
1696
|
3,
|
|
1655
|
-
|
|
1697
|
+
13
|
|
1656
1698
|
];
|
|
1657
1699
|
case 18:
|
|
1658
1700
|
return [
|
|
@@ -8125,12 +8167,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8125
8167
|
adPlayer.on("ad_interaction", function(event) {
|
|
8126
8168
|
if (event) _this.host.onAdInteraction(event);
|
|
8127
8169
|
});
|
|
8128
|
-
adPlayer.on("
|
|
8129
|
-
sendAdImpressionTracking(_this.host.config.licenseKey, {
|
|
8170
|
+
adPlayer.on("ad_impression", function() {
|
|
8171
|
+
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
8130
8172
|
source: "hls",
|
|
8131
|
-
adIndex: _this.timing.currentAdIndex
|
|
8173
|
+
adIndex: _this.timing.currentAdIndex
|
|
8174
|
+
}, _this.currentVastUrl ? {
|
|
8175
|
+
adUrl: _this.currentVastUrl
|
|
8176
|
+
} : {}), {
|
|
8132
8177
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8133
|
-
}, _this.analyticsContext).catch(function() {});
|
|
8178
|
+
}), _this.analyticsContext).catch(function() {});
|
|
8179
|
+
});
|
|
8180
|
+
adPlayer.on("all_ads_completed", function() {
|
|
8134
8181
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
8135
8182
|
var remaining = _this.timing.getRemainingAdMs();
|
|
8136
8183
|
_this.timing.consecutiveFailures = 0;
|
|
@@ -8188,11 +8235,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8188
8235
|
}
|
|
8189
8236
|
});
|
|
8190
8237
|
adPlayer.on("content_resume", function() {
|
|
8191
|
-
sendAdImpressionTracking(_this.host.config.licenseKey, {
|
|
8192
|
-
source: "hls",
|
|
8193
|
-
adIndex: _this.timing.currentAdIndex,
|
|
8194
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8195
|
-
}, _this.analyticsContext).catch(function() {});
|
|
8196
8238
|
if (!_this.host.video.muted) {
|
|
8197
8239
|
_this.host.video.muted = true;
|
|
8198
8240
|
if (_this.debug) {
|
|
@@ -8388,7 +8430,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8388
8430
|
adPlayer = this.host.getAdPlayer();
|
|
8389
8431
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8390
8432
|
this.timing.activeAdRequestToken = requestToken;
|
|
8391
|
-
this.
|
|
8433
|
+
this.currentVastUrl = podUrl;
|
|
8392
8434
|
_state.label = 1;
|
|
8393
8435
|
case 1:
|
|
8394
8436
|
_state.trys.push([
|
|
@@ -8403,6 +8445,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8403
8445
|
];
|
|
8404
8446
|
case 2:
|
|
8405
8447
|
_state.sent();
|
|
8448
|
+
this.timing.startAdRequestWatchdog(requestToken);
|
|
8406
8449
|
this.timing.lastAdRequestTime = Date.now();
|
|
8407
8450
|
return [
|
|
8408
8451
|
4,
|
|
@@ -8891,13 +8934,33 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8891
8934
|
}
|
|
8892
8935
|
},
|
|
8893
8936
|
{
|
|
8894
|
-
|
|
8895
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
8937
|
+
// ───────────────────────────────────────────────────────────────
|
|
8896
8938
|
// Single ad playback
|
|
8897
8939
|
// ───────────────────────────────────────────────────────────────
|
|
8898
|
-
|
|
8940
|
+
key: "withCurrentPodBudget",
|
|
8941
|
+
value: function withCurrentPodBudget(vastTagUrl) {
|
|
8942
|
+
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
8943
|
+
if (!(remaining > 0)) return vastTagUrl;
|
|
8944
|
+
try {
|
|
8945
|
+
var url = new URL(vastTagUrl);
|
|
8946
|
+
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
8947
|
+
var maxMs = Math.round(remaining);
|
|
8948
|
+
url.searchParams.set("pmxd", String(maxMs));
|
|
8949
|
+
var minMs = Number(url.searchParams.get("pmnd"));
|
|
8950
|
+
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
8951
|
+
url.searchParams.set("pmnd", String(maxMs));
|
|
8952
|
+
}
|
|
8953
|
+
return url.toString();
|
|
8954
|
+
} catch (unused) {
|
|
8955
|
+
return vastTagUrl;
|
|
8956
|
+
}
|
|
8957
|
+
}
|
|
8958
|
+
},
|
|
8959
|
+
{
|
|
8960
|
+
key: "playSingleAd",
|
|
8961
|
+
value: function playSingleAd(vastTagUrl) {
|
|
8899
8962
|
return _async_to_generator(function() {
|
|
8900
|
-
var adPlayer, requestToken, ap, playError, error, errorMessage;
|
|
8963
|
+
var adPlayer, requestToken, ap, requestUrl, playError, error, errorMessage;
|
|
8901
8964
|
return _ts_generator(this, function(_state) {
|
|
8902
8965
|
switch(_state.label){
|
|
8903
8966
|
case 0:
|
|
@@ -8924,7 +8987,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8924
8987
|
this.recreateAdController();
|
|
8925
8988
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8926
8989
|
this.timing.activeAdRequestToken = requestToken;
|
|
8927
|
-
this.timing.startAdRequestWatchdog(requestToken);
|
|
8928
8990
|
_state.label = 1;
|
|
8929
8991
|
case 1:
|
|
8930
8992
|
_state.trys.push([
|
|
@@ -8939,17 +9001,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8939
9001
|
];
|
|
8940
9002
|
case 2:
|
|
8941
9003
|
_state.sent();
|
|
9004
|
+
this.timing.startAdRequestWatchdog(requestToken);
|
|
8942
9005
|
this.timing.lastAdRequestTime = Date.now();
|
|
8943
9006
|
ap = this.host.getAdPlayer();
|
|
9007
|
+
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9008
|
+
this.currentVastUrl = requestUrl;
|
|
8944
9009
|
return [
|
|
8945
9010
|
4,
|
|
8946
|
-
ap.requestAds(
|
|
9011
|
+
ap.requestAds(requestUrl)
|
|
8947
9012
|
];
|
|
8948
9013
|
case 3:
|
|
8949
9014
|
_state.sent();
|
|
8950
9015
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
8951
9016
|
source: "hls",
|
|
8952
|
-
vastUrl:
|
|
9017
|
+
vastUrl: requestUrl,
|
|
8953
9018
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8954
9019
|
}, this.analyticsContext).catch(function() {});
|
|
8955
9020
|
this.timing.clearAdRequestWatchdog();
|