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
|
@@ -737,6 +737,7 @@ function parseProgressOffset(offset) {
|
|
|
737
737
|
} : void 0;
|
|
738
738
|
}
|
|
739
739
|
var MAX_VAST_WRAPPER_DEPTH = 5;
|
|
740
|
+
var VAST_REQUEST_TIMEOUT_MS = 5e3;
|
|
740
741
|
var BEACON_TIMEOUT_MS = 3e4;
|
|
741
742
|
var inFlightBeacons = /* @__PURE__ */ new Set();
|
|
742
743
|
var VAST_ERROR_MEDIA_DISPLAY = 405;
|
|
@@ -1295,70 +1296,104 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1295
1296
|
function fetchVastXml(vastTagUrl) {
|
|
1296
1297
|
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
1297
1298
|
return _async_to_generator(function() {
|
|
1298
|
-
var requestVast, response, error;
|
|
1299
|
+
var controller, timeoutId, requestVast, response, error, error1;
|
|
1299
1300
|
return _ts_generator(this, function(_state) {
|
|
1300
1301
|
switch(_state.label){
|
|
1301
1302
|
case 0:
|
|
1303
|
+
controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1304
|
+
timeoutId = controller ? setTimeout(function() {
|
|
1305
|
+
return controller.abort();
|
|
1306
|
+
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
1302
1307
|
requestVast = function requestVast(creds) {
|
|
1303
|
-
return fetch(vastTagUrl, {
|
|
1308
|
+
return fetch(vastTagUrl, _object_spread({
|
|
1304
1309
|
mode: "cors",
|
|
1305
1310
|
credentials: creds,
|
|
1306
1311
|
headers: {
|
|
1307
1312
|
"Accept": "application/xml, text/xml, */*"
|
|
1308
1313
|
},
|
|
1309
1314
|
referrerPolicy: "no-referrer-when-downgrade"
|
|
1310
|
-
}
|
|
1315
|
+
}, controller ? {
|
|
1316
|
+
signal: controller.signal
|
|
1317
|
+
} : {}));
|
|
1311
1318
|
};
|
|
1312
1319
|
_state.label = 1;
|
|
1313
1320
|
case 1:
|
|
1314
1321
|
_state.trys.push([
|
|
1315
1322
|
1,
|
|
1316
|
-
|
|
1323
|
+
10,
|
|
1324
|
+
11,
|
|
1325
|
+
12
|
|
1326
|
+
]);
|
|
1327
|
+
_state.label = 2;
|
|
1328
|
+
case 2:
|
|
1329
|
+
_state.trys.push([
|
|
1330
|
+
2,
|
|
1331
|
+
4,
|
|
1317
1332
|
,
|
|
1318
|
-
|
|
1333
|
+
8
|
|
1319
1334
|
]);
|
|
1320
1335
|
return [
|
|
1321
1336
|
4,
|
|
1322
1337
|
requestVast(credentials)
|
|
1323
1338
|
];
|
|
1324
|
-
case
|
|
1339
|
+
case 3:
|
|
1325
1340
|
response = _state.sent();
|
|
1326
1341
|
return [
|
|
1327
1342
|
3,
|
|
1328
|
-
|
|
1343
|
+
8
|
|
1329
1344
|
];
|
|
1330
|
-
case
|
|
1345
|
+
case 4:
|
|
1331
1346
|
error = _state.sent();
|
|
1332
|
-
if (!(credentials !== "omit")) return [
|
|
1347
|
+
if (!(credentials !== "omit" && !(controller === null || controller === void 0 ? void 0 : controller.signal.aborted))) return [
|
|
1333
1348
|
3,
|
|
1334
|
-
|
|
1349
|
+
6
|
|
1335
1350
|
];
|
|
1336
1351
|
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
1337
1352
|
return [
|
|
1338
1353
|
4,
|
|
1339
1354
|
requestVast("omit")
|
|
1340
1355
|
];
|
|
1341
|
-
case
|
|
1356
|
+
case 5:
|
|
1342
1357
|
response = _state.sent();
|
|
1343
1358
|
return [
|
|
1344
1359
|
3,
|
|
1345
|
-
|
|
1360
|
+
7
|
|
1346
1361
|
];
|
|
1347
|
-
case 5:
|
|
1348
|
-
throw error;
|
|
1349
1362
|
case 6:
|
|
1363
|
+
throw error;
|
|
1364
|
+
case 7:
|
|
1350
1365
|
return [
|
|
1351
1366
|
3,
|
|
1352
|
-
|
|
1367
|
+
8
|
|
1353
1368
|
];
|
|
1354
|
-
case
|
|
1369
|
+
case 8:
|
|
1355
1370
|
if (!response.ok) {
|
|
1356
1371
|
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
1357
1372
|
}
|
|
1358
1373
|
return [
|
|
1359
|
-
|
|
1374
|
+
4,
|
|
1360
1375
|
response.text()
|
|
1361
1376
|
];
|
|
1377
|
+
case 9:
|
|
1378
|
+
return [
|
|
1379
|
+
2,
|
|
1380
|
+
_state.sent()
|
|
1381
|
+
];
|
|
1382
|
+
case 10:
|
|
1383
|
+
error1 = _state.sent();
|
|
1384
|
+
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1385
|
+
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1386
|
+
}
|
|
1387
|
+
throw error1;
|
|
1388
|
+
case 11:
|
|
1389
|
+
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1390
|
+
return [
|
|
1391
|
+
7
|
|
1392
|
+
];
|
|
1393
|
+
case 12:
|
|
1394
|
+
return [
|
|
1395
|
+
2
|
|
1396
|
+
];
|
|
1362
1397
|
}
|
|
1363
1398
|
});
|
|
1364
1399
|
})();
|
|
@@ -1444,7 +1479,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1444
1479
|
}
|
|
1445
1480
|
function fetchAndParsePod(vastTagUrl) {
|
|
1446
1481
|
return _async_to_generator(function() {
|
|
1447
|
-
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements, _root_getAttribute1, _empty_errorUrls, empty, _empty_errorCode, resolveAd, podElements, buffet, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step,
|
|
1482
|
+
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;
|
|
1448
1483
|
return _ts_generator(this, function(_state) {
|
|
1449
1484
|
switch(_state.label){
|
|
1450
1485
|
case 0:
|
|
@@ -1525,6 +1560,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1525
1560
|
buffet = adElements.filter(function(el) {
|
|
1526
1561
|
return getAdSequence(el) === void 0;
|
|
1527
1562
|
});
|
|
1563
|
+
resolveAll = function resolveAll(elements) {
|
|
1564
|
+
return Promise.all(elements.map(function(el) {
|
|
1565
|
+
return resolveAd(el).catch(function() {
|
|
1566
|
+
return null;
|
|
1567
|
+
});
|
|
1568
|
+
}));
|
|
1569
|
+
};
|
|
1528
1570
|
ads = [];
|
|
1529
1571
|
if (!(podElements.length === 0)) return [
|
|
1530
1572
|
3,
|
|
@@ -1539,27 +1581,26 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1539
1581
|
8,
|
|
1540
1582
|
9
|
|
1541
1583
|
]);
|
|
1542
|
-
|
|
1543
|
-
|
|
1584
|
+
return [
|
|
1585
|
+
4,
|
|
1586
|
+
resolveAll(buffet)
|
|
1587
|
+
];
|
|
1544
1588
|
case 3:
|
|
1589
|
+
_iterator = _state.sent()[Symbol.iterator]();
|
|
1590
|
+
_state.label = 4;
|
|
1591
|
+
case 4:
|
|
1545
1592
|
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
1546
1593
|
3,
|
|
1547
1594
|
6
|
|
1548
1595
|
];
|
|
1549
|
-
|
|
1550
|
-
return [
|
|
1551
|
-
4,
|
|
1552
|
-
resolveAd(adElement)
|
|
1553
|
-
];
|
|
1554
|
-
case 4:
|
|
1555
|
-
ad = _state.sent();
|
|
1596
|
+
ad = _step.value;
|
|
1556
1597
|
if (ad) ads.push(ad);
|
|
1557
1598
|
_state.label = 5;
|
|
1558
1599
|
case 5:
|
|
1559
1600
|
_iteratorNormalCompletion = true;
|
|
1560
1601
|
return [
|
|
1561
1602
|
3,
|
|
1562
|
-
|
|
1603
|
+
4
|
|
1563
1604
|
];
|
|
1564
1605
|
case 6:
|
|
1565
1606
|
return [
|
|
@@ -1602,20 +1643,19 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1602
1643
|
20,
|
|
1603
1644
|
21
|
|
1604
1645
|
]);
|
|
1605
|
-
|
|
1606
|
-
|
|
1646
|
+
return [
|
|
1647
|
+
4,
|
|
1648
|
+
resolveAll(podElements)
|
|
1649
|
+
];
|
|
1607
1650
|
case 12:
|
|
1651
|
+
_iterator1 = _state.sent()[Symbol.iterator]();
|
|
1652
|
+
_state.label = 13;
|
|
1653
|
+
case 13:
|
|
1608
1654
|
if (!!(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done)) return [
|
|
1609
1655
|
3,
|
|
1610
1656
|
18
|
|
1611
1657
|
];
|
|
1612
|
-
|
|
1613
|
-
return [
|
|
1614
|
-
4,
|
|
1615
|
-
resolveAd(adElement1)
|
|
1616
|
-
];
|
|
1617
|
-
case 13:
|
|
1618
|
-
ad1 = _state.sent();
|
|
1658
|
+
ad1 = _step1.value;
|
|
1619
1659
|
_state.label = 14;
|
|
1620
1660
|
case 14:
|
|
1621
1661
|
if (!(!ad1 && buffet.length > 0)) return [
|
|
@@ -1624,7 +1664,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1624
1664
|
];
|
|
1625
1665
|
return [
|
|
1626
1666
|
4,
|
|
1627
|
-
resolveAd(buffet.shift())
|
|
1667
|
+
resolveAd(buffet.shift()).catch(function() {
|
|
1668
|
+
return null;
|
|
1669
|
+
})
|
|
1628
1670
|
];
|
|
1629
1671
|
case 15:
|
|
1630
1672
|
ad1 = _state.sent();
|
|
@@ -1639,7 +1681,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1639
1681
|
_iteratorNormalCompletion1 = true;
|
|
1640
1682
|
return [
|
|
1641
1683
|
3,
|
|
1642
|
-
|
|
1684
|
+
13
|
|
1643
1685
|
];
|
|
1644
1686
|
case 18:
|
|
1645
1687
|
return [
|
|
@@ -8112,12 +8154,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8112
8154
|
adPlayer.on("ad_interaction", function(event) {
|
|
8113
8155
|
if (event) _this.host.onAdInteraction(event);
|
|
8114
8156
|
});
|
|
8115
|
-
adPlayer.on("
|
|
8116
|
-
sendAdImpressionTracking(_this.host.config.licenseKey, {
|
|
8157
|
+
adPlayer.on("ad_impression", function() {
|
|
8158
|
+
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
8117
8159
|
source: "hls",
|
|
8118
|
-
adIndex: _this.timing.currentAdIndex
|
|
8160
|
+
adIndex: _this.timing.currentAdIndex
|
|
8161
|
+
}, _this.currentVastUrl ? {
|
|
8162
|
+
adUrl: _this.currentVastUrl
|
|
8163
|
+
} : {}), {
|
|
8119
8164
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8120
|
-
}, _this.analyticsContext).catch(function() {});
|
|
8165
|
+
}), _this.analyticsContext).catch(function() {});
|
|
8166
|
+
});
|
|
8167
|
+
adPlayer.on("all_ads_completed", function() {
|
|
8121
8168
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
8122
8169
|
var remaining = _this.timing.getRemainingAdMs();
|
|
8123
8170
|
_this.timing.consecutiveFailures = 0;
|
|
@@ -8175,11 +8222,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8175
8222
|
}
|
|
8176
8223
|
});
|
|
8177
8224
|
adPlayer.on("content_resume", function() {
|
|
8178
|
-
sendAdImpressionTracking(_this.host.config.licenseKey, {
|
|
8179
|
-
source: "hls",
|
|
8180
|
-
adIndex: _this.timing.currentAdIndex,
|
|
8181
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8182
|
-
}, _this.analyticsContext).catch(function() {});
|
|
8183
8225
|
if (!_this.host.video.muted) {
|
|
8184
8226
|
_this.host.video.muted = true;
|
|
8185
8227
|
if (_this.debug) {
|
|
@@ -8375,7 +8417,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8375
8417
|
adPlayer = this.host.getAdPlayer();
|
|
8376
8418
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8377
8419
|
this.timing.activeAdRequestToken = requestToken;
|
|
8378
|
-
this.
|
|
8420
|
+
this.currentVastUrl = podUrl;
|
|
8379
8421
|
_state.label = 1;
|
|
8380
8422
|
case 1:
|
|
8381
8423
|
_state.trys.push([
|
|
@@ -8390,6 +8432,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8390
8432
|
];
|
|
8391
8433
|
case 2:
|
|
8392
8434
|
_state.sent();
|
|
8435
|
+
this.timing.startAdRequestWatchdog(requestToken);
|
|
8393
8436
|
this.timing.lastAdRequestTime = Date.now();
|
|
8394
8437
|
return [
|
|
8395
8438
|
4,
|
|
@@ -8878,13 +8921,33 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8878
8921
|
}
|
|
8879
8922
|
},
|
|
8880
8923
|
{
|
|
8881
|
-
|
|
8882
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
8924
|
+
// ───────────────────────────────────────────────────────────────
|
|
8883
8925
|
// Single ad playback
|
|
8884
8926
|
// ───────────────────────────────────────────────────────────────
|
|
8885
|
-
|
|
8927
|
+
key: "withCurrentPodBudget",
|
|
8928
|
+
value: function withCurrentPodBudget(vastTagUrl) {
|
|
8929
|
+
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
8930
|
+
if (!(remaining > 0)) return vastTagUrl;
|
|
8931
|
+
try {
|
|
8932
|
+
var url = new URL(vastTagUrl);
|
|
8933
|
+
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
8934
|
+
var maxMs = Math.round(remaining);
|
|
8935
|
+
url.searchParams.set("pmxd", String(maxMs));
|
|
8936
|
+
var minMs = Number(url.searchParams.get("pmnd"));
|
|
8937
|
+
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
8938
|
+
url.searchParams.set("pmnd", String(maxMs));
|
|
8939
|
+
}
|
|
8940
|
+
return url.toString();
|
|
8941
|
+
} catch (unused) {
|
|
8942
|
+
return vastTagUrl;
|
|
8943
|
+
}
|
|
8944
|
+
}
|
|
8945
|
+
},
|
|
8946
|
+
{
|
|
8947
|
+
key: "playSingleAd",
|
|
8948
|
+
value: function playSingleAd(vastTagUrl) {
|
|
8886
8949
|
return _async_to_generator(function() {
|
|
8887
|
-
var adPlayer, requestToken, ap, playError, error, errorMessage;
|
|
8950
|
+
var adPlayer, requestToken, ap, requestUrl, playError, error, errorMessage;
|
|
8888
8951
|
return _ts_generator(this, function(_state) {
|
|
8889
8952
|
switch(_state.label){
|
|
8890
8953
|
case 0:
|
|
@@ -8911,7 +8974,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8911
8974
|
this.recreateAdController();
|
|
8912
8975
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8913
8976
|
this.timing.activeAdRequestToken = requestToken;
|
|
8914
|
-
this.timing.startAdRequestWatchdog(requestToken);
|
|
8915
8977
|
_state.label = 1;
|
|
8916
8978
|
case 1:
|
|
8917
8979
|
_state.trys.push([
|
|
@@ -8926,17 +8988,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8926
8988
|
];
|
|
8927
8989
|
case 2:
|
|
8928
8990
|
_state.sent();
|
|
8991
|
+
this.timing.startAdRequestWatchdog(requestToken);
|
|
8929
8992
|
this.timing.lastAdRequestTime = Date.now();
|
|
8930
8993
|
ap = this.host.getAdPlayer();
|
|
8994
|
+
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
8995
|
+
this.currentVastUrl = requestUrl;
|
|
8931
8996
|
return [
|
|
8932
8997
|
4,
|
|
8933
|
-
ap.requestAds(
|
|
8998
|
+
ap.requestAds(requestUrl)
|
|
8934
8999
|
];
|
|
8935
9000
|
case 3:
|
|
8936
9001
|
_state.sent();
|
|
8937
9002
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
8938
9003
|
source: "hls",
|
|
8939
|
-
vastUrl:
|
|
9004
|
+
vastUrl: requestUrl,
|
|
8940
9005
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8941
9006
|
}, this.analyticsContext).catch(function() {});
|
|
8942
9007
|
this.timing.clearAdRequestWatchdog();
|