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.js
CHANGED
|
@@ -740,6 +740,7 @@ function parseProgressOffset(offset) {
|
|
|
740
740
|
} : void 0;
|
|
741
741
|
}
|
|
742
742
|
var MAX_VAST_WRAPPER_DEPTH = 5;
|
|
743
|
+
var VAST_REQUEST_TIMEOUT_MS = 5e3;
|
|
743
744
|
var BEACON_TIMEOUT_MS = 3e4;
|
|
744
745
|
var inFlightBeacons = /* @__PURE__ */ new Set();
|
|
745
746
|
var VAST_ERROR_MEDIA_DISPLAY = 405;
|
|
@@ -1298,70 +1299,104 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1298
1299
|
function fetchVastXml(vastTagUrl) {
|
|
1299
1300
|
var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include";
|
|
1300
1301
|
return _async_to_generator(function() {
|
|
1301
|
-
var requestVast, response, error;
|
|
1302
|
+
var controller, timeoutId, requestVast, response, error, error1;
|
|
1302
1303
|
return _ts_generator(this, function(_state) {
|
|
1303
1304
|
switch(_state.label){
|
|
1304
1305
|
case 0:
|
|
1306
|
+
controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
1307
|
+
timeoutId = controller ? setTimeout(function() {
|
|
1308
|
+
return controller.abort();
|
|
1309
|
+
}, VAST_REQUEST_TIMEOUT_MS) : void 0;
|
|
1305
1310
|
requestVast = function requestVast(creds) {
|
|
1306
|
-
return fetch(vastTagUrl, {
|
|
1311
|
+
return fetch(vastTagUrl, _object_spread({
|
|
1307
1312
|
mode: "cors",
|
|
1308
1313
|
credentials: creds,
|
|
1309
1314
|
headers: {
|
|
1310
1315
|
"Accept": "application/xml, text/xml, */*"
|
|
1311
1316
|
},
|
|
1312
1317
|
referrerPolicy: "no-referrer-when-downgrade"
|
|
1313
|
-
}
|
|
1318
|
+
}, controller ? {
|
|
1319
|
+
signal: controller.signal
|
|
1320
|
+
} : {}));
|
|
1314
1321
|
};
|
|
1315
1322
|
_state.label = 1;
|
|
1316
1323
|
case 1:
|
|
1317
1324
|
_state.trys.push([
|
|
1318
1325
|
1,
|
|
1319
|
-
|
|
1326
|
+
10,
|
|
1327
|
+
11,
|
|
1328
|
+
12
|
|
1329
|
+
]);
|
|
1330
|
+
_state.label = 2;
|
|
1331
|
+
case 2:
|
|
1332
|
+
_state.trys.push([
|
|
1333
|
+
2,
|
|
1334
|
+
4,
|
|
1320
1335
|
,
|
|
1321
|
-
|
|
1336
|
+
8
|
|
1322
1337
|
]);
|
|
1323
1338
|
return [
|
|
1324
1339
|
4,
|
|
1325
1340
|
requestVast(credentials)
|
|
1326
1341
|
];
|
|
1327
|
-
case
|
|
1342
|
+
case 3:
|
|
1328
1343
|
response = _state.sent();
|
|
1329
1344
|
return [
|
|
1330
1345
|
3,
|
|
1331
|
-
|
|
1346
|
+
8
|
|
1332
1347
|
];
|
|
1333
|
-
case
|
|
1348
|
+
case 4:
|
|
1334
1349
|
error = _state.sent();
|
|
1335
|
-
if (!(credentials !== "omit")) return [
|
|
1350
|
+
if (!(credentials !== "omit" && !(controller === null || controller === void 0 ? void 0 : controller.signal.aborted))) return [
|
|
1336
1351
|
3,
|
|
1337
|
-
|
|
1352
|
+
6
|
|
1338
1353
|
];
|
|
1339
1354
|
console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
|
|
1340
1355
|
return [
|
|
1341
1356
|
4,
|
|
1342
1357
|
requestVast("omit")
|
|
1343
1358
|
];
|
|
1344
|
-
case
|
|
1359
|
+
case 5:
|
|
1345
1360
|
response = _state.sent();
|
|
1346
1361
|
return [
|
|
1347
1362
|
3,
|
|
1348
|
-
|
|
1363
|
+
7
|
|
1349
1364
|
];
|
|
1350
|
-
case 5:
|
|
1351
|
-
throw error;
|
|
1352
1365
|
case 6:
|
|
1366
|
+
throw error;
|
|
1367
|
+
case 7:
|
|
1353
1368
|
return [
|
|
1354
1369
|
3,
|
|
1355
|
-
|
|
1370
|
+
8
|
|
1356
1371
|
];
|
|
1357
|
-
case
|
|
1372
|
+
case 8:
|
|
1358
1373
|
if (!response.ok) {
|
|
1359
1374
|
throw new Error("Failed to fetch VAST: ".concat(response.statusText));
|
|
1360
1375
|
}
|
|
1361
1376
|
return [
|
|
1362
|
-
|
|
1377
|
+
4,
|
|
1363
1378
|
response.text()
|
|
1364
1379
|
];
|
|
1380
|
+
case 9:
|
|
1381
|
+
return [
|
|
1382
|
+
2,
|
|
1383
|
+
_state.sent()
|
|
1384
|
+
];
|
|
1385
|
+
case 10:
|
|
1386
|
+
error1 = _state.sent();
|
|
1387
|
+
if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
|
|
1388
|
+
throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
|
|
1389
|
+
}
|
|
1390
|
+
throw error1;
|
|
1391
|
+
case 11:
|
|
1392
|
+
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1393
|
+
return [
|
|
1394
|
+
7
|
|
1395
|
+
];
|
|
1396
|
+
case 12:
|
|
1397
|
+
return [
|
|
1398
|
+
2
|
|
1399
|
+
];
|
|
1365
1400
|
}
|
|
1366
1401
|
});
|
|
1367
1402
|
})();
|
|
@@ -1447,7 +1482,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1447
1482
|
}
|
|
1448
1483
|
function fetchAndParsePod(vastTagUrl) {
|
|
1449
1484
|
return _async_to_generator(function() {
|
|
1450
|
-
var _root_getAttribute, vastXml, trimmedXml, xmlDoc, root, adElements, _root_getAttribute1, _empty_errorUrls, empty, _empty_errorCode, resolveAd, podElements, buffet, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step,
|
|
1485
|
+
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;
|
|
1451
1486
|
return _ts_generator(this, function(_state) {
|
|
1452
1487
|
switch(_state.label){
|
|
1453
1488
|
case 0:
|
|
@@ -1528,6 +1563,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1528
1563
|
buffet = adElements.filter(function(el) {
|
|
1529
1564
|
return getAdSequence(el) === void 0;
|
|
1530
1565
|
});
|
|
1566
|
+
resolveAll = function resolveAll(elements) {
|
|
1567
|
+
return Promise.all(elements.map(function(el) {
|
|
1568
|
+
return resolveAd(el).catch(function() {
|
|
1569
|
+
return null;
|
|
1570
|
+
});
|
|
1571
|
+
}));
|
|
1572
|
+
};
|
|
1531
1573
|
ads = [];
|
|
1532
1574
|
if (!(podElements.length === 0)) return [
|
|
1533
1575
|
3,
|
|
@@ -1542,27 +1584,26 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1542
1584
|
8,
|
|
1543
1585
|
9
|
|
1544
1586
|
]);
|
|
1545
|
-
|
|
1546
|
-
|
|
1587
|
+
return [
|
|
1588
|
+
4,
|
|
1589
|
+
resolveAll(buffet)
|
|
1590
|
+
];
|
|
1547
1591
|
case 3:
|
|
1592
|
+
_iterator = _state.sent()[Symbol.iterator]();
|
|
1593
|
+
_state.label = 4;
|
|
1594
|
+
case 4:
|
|
1548
1595
|
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
1549
1596
|
3,
|
|
1550
1597
|
6
|
|
1551
1598
|
];
|
|
1552
|
-
|
|
1553
|
-
return [
|
|
1554
|
-
4,
|
|
1555
|
-
resolveAd(adElement)
|
|
1556
|
-
];
|
|
1557
|
-
case 4:
|
|
1558
|
-
ad = _state.sent();
|
|
1599
|
+
ad = _step.value;
|
|
1559
1600
|
if (ad) ads.push(ad);
|
|
1560
1601
|
_state.label = 5;
|
|
1561
1602
|
case 5:
|
|
1562
1603
|
_iteratorNormalCompletion = true;
|
|
1563
1604
|
return [
|
|
1564
1605
|
3,
|
|
1565
|
-
|
|
1606
|
+
4
|
|
1566
1607
|
];
|
|
1567
1608
|
case 6:
|
|
1568
1609
|
return [
|
|
@@ -1605,20 +1646,19 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1605
1646
|
20,
|
|
1606
1647
|
21
|
|
1607
1648
|
]);
|
|
1608
|
-
|
|
1609
|
-
|
|
1649
|
+
return [
|
|
1650
|
+
4,
|
|
1651
|
+
resolveAll(podElements)
|
|
1652
|
+
];
|
|
1610
1653
|
case 12:
|
|
1654
|
+
_iterator1 = _state.sent()[Symbol.iterator]();
|
|
1655
|
+
_state.label = 13;
|
|
1656
|
+
case 13:
|
|
1611
1657
|
if (!!(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done)) return [
|
|
1612
1658
|
3,
|
|
1613
1659
|
18
|
|
1614
1660
|
];
|
|
1615
|
-
|
|
1616
|
-
return [
|
|
1617
|
-
4,
|
|
1618
|
-
resolveAd(adElement1)
|
|
1619
|
-
];
|
|
1620
|
-
case 13:
|
|
1621
|
-
ad1 = _state.sent();
|
|
1661
|
+
ad1 = _step1.value;
|
|
1622
1662
|
_state.label = 14;
|
|
1623
1663
|
case 14:
|
|
1624
1664
|
if (!(!ad1 && buffet.length > 0)) return [
|
|
@@ -1627,7 +1667,9 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1627
1667
|
];
|
|
1628
1668
|
return [
|
|
1629
1669
|
4,
|
|
1630
|
-
resolveAd(buffet.shift())
|
|
1670
|
+
resolveAd(buffet.shift()).catch(function() {
|
|
1671
|
+
return null;
|
|
1672
|
+
})
|
|
1631
1673
|
];
|
|
1632
1674
|
case 15:
|
|
1633
1675
|
ad1 = _state.sent();
|
|
@@ -1642,7 +1684,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1642
1684
|
_iteratorNormalCompletion1 = true;
|
|
1643
1685
|
return [
|
|
1644
1686
|
3,
|
|
1645
|
-
|
|
1687
|
+
13
|
|
1646
1688
|
];
|
|
1647
1689
|
case 18:
|
|
1648
1690
|
return [
|
|
@@ -8130,12 +8172,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8130
8172
|
adPlayer.on("ad_interaction", function(event) {
|
|
8131
8173
|
if (event) _this.host.onAdInteraction(event);
|
|
8132
8174
|
});
|
|
8133
|
-
adPlayer.on("
|
|
8134
|
-
sendAdImpressionTracking(_this.host.config.licenseKey, {
|
|
8175
|
+
adPlayer.on("ad_impression", function() {
|
|
8176
|
+
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
8135
8177
|
source: "hls",
|
|
8136
|
-
adIndex: _this.timing.currentAdIndex
|
|
8178
|
+
adIndex: _this.timing.currentAdIndex
|
|
8179
|
+
}, _this.currentVastUrl ? {
|
|
8180
|
+
adUrl: _this.currentVastUrl
|
|
8181
|
+
} : {}), {
|
|
8137
8182
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8138
|
-
}, _this.analyticsContext).catch(function() {});
|
|
8183
|
+
}), _this.analyticsContext).catch(function() {});
|
|
8184
|
+
});
|
|
8185
|
+
adPlayer.on("all_ads_completed", function() {
|
|
8139
8186
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
8140
8187
|
var remaining = _this.timing.getRemainingAdMs();
|
|
8141
8188
|
_this.timing.consecutiveFailures = 0;
|
|
@@ -8193,11 +8240,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8193
8240
|
}
|
|
8194
8241
|
});
|
|
8195
8242
|
adPlayer.on("content_resume", function() {
|
|
8196
|
-
sendAdImpressionTracking(_this.host.config.licenseKey, {
|
|
8197
|
-
source: "hls",
|
|
8198
|
-
adIndex: _this.timing.currentAdIndex,
|
|
8199
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8200
|
-
}, _this.analyticsContext).catch(function() {});
|
|
8201
8243
|
if (!_this.host.video.muted) {
|
|
8202
8244
|
_this.host.video.muted = true;
|
|
8203
8245
|
if (_this.debug) {
|
|
@@ -8393,7 +8435,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8393
8435
|
adPlayer = this.host.getAdPlayer();
|
|
8394
8436
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8395
8437
|
this.timing.activeAdRequestToken = requestToken;
|
|
8396
|
-
this.
|
|
8438
|
+
this.currentVastUrl = podUrl;
|
|
8397
8439
|
_state.label = 1;
|
|
8398
8440
|
case 1:
|
|
8399
8441
|
_state.trys.push([
|
|
@@ -8408,6 +8450,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8408
8450
|
];
|
|
8409
8451
|
case 2:
|
|
8410
8452
|
_state.sent();
|
|
8453
|
+
this.timing.startAdRequestWatchdog(requestToken);
|
|
8411
8454
|
this.timing.lastAdRequestTime = Date.now();
|
|
8412
8455
|
return [
|
|
8413
8456
|
4,
|
|
@@ -8896,13 +8939,33 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8896
8939
|
}
|
|
8897
8940
|
},
|
|
8898
8941
|
{
|
|
8899
|
-
|
|
8900
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
8942
|
+
// ───────────────────────────────────────────────────────────────
|
|
8901
8943
|
// Single ad playback
|
|
8902
8944
|
// ───────────────────────────────────────────────────────────────
|
|
8903
|
-
|
|
8945
|
+
key: "withCurrentPodBudget",
|
|
8946
|
+
value: function withCurrentPodBudget(vastTagUrl) {
|
|
8947
|
+
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
8948
|
+
if (!(remaining > 0)) return vastTagUrl;
|
|
8949
|
+
try {
|
|
8950
|
+
var url = new URL(vastTagUrl);
|
|
8951
|
+
if (!url.searchParams.has("pmxd")) return vastTagUrl;
|
|
8952
|
+
var maxMs = Math.round(remaining);
|
|
8953
|
+
url.searchParams.set("pmxd", String(maxMs));
|
|
8954
|
+
var minMs = Number(url.searchParams.get("pmnd"));
|
|
8955
|
+
if (Number.isFinite(minMs) && minMs > maxMs) {
|
|
8956
|
+
url.searchParams.set("pmnd", String(maxMs));
|
|
8957
|
+
}
|
|
8958
|
+
return url.toString();
|
|
8959
|
+
} catch (unused) {
|
|
8960
|
+
return vastTagUrl;
|
|
8961
|
+
}
|
|
8962
|
+
}
|
|
8963
|
+
},
|
|
8964
|
+
{
|
|
8965
|
+
key: "playSingleAd",
|
|
8966
|
+
value: function playSingleAd(vastTagUrl) {
|
|
8904
8967
|
return _async_to_generator(function() {
|
|
8905
|
-
var adPlayer, requestToken, ap, playError, error, errorMessage;
|
|
8968
|
+
var adPlayer, requestToken, ap, requestUrl, playError, error, errorMessage;
|
|
8906
8969
|
return _ts_generator(this, function(_state) {
|
|
8907
8970
|
switch(_state.label){
|
|
8908
8971
|
case 0:
|
|
@@ -8929,7 +8992,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8929
8992
|
this.recreateAdController();
|
|
8930
8993
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
8931
8994
|
this.timing.activeAdRequestToken = requestToken;
|
|
8932
|
-
this.timing.startAdRequestWatchdog(requestToken);
|
|
8933
8995
|
_state.label = 1;
|
|
8934
8996
|
case 1:
|
|
8935
8997
|
_state.trys.push([
|
|
@@ -8944,17 +9006,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
8944
9006
|
];
|
|
8945
9007
|
case 2:
|
|
8946
9008
|
_state.sent();
|
|
9009
|
+
this.timing.startAdRequestWatchdog(requestToken);
|
|
8947
9010
|
this.timing.lastAdRequestTime = Date.now();
|
|
8948
9011
|
ap = this.host.getAdPlayer();
|
|
9012
|
+
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
9013
|
+
this.currentVastUrl = requestUrl;
|
|
8949
9014
|
return [
|
|
8950
9015
|
4,
|
|
8951
|
-
ap.requestAds(
|
|
9016
|
+
ap.requestAds(requestUrl)
|
|
8952
9017
|
];
|
|
8953
9018
|
case 3:
|
|
8954
9019
|
_state.sent();
|
|
8955
9020
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
8956
9021
|
source: "hls",
|
|
8957
|
-
vastUrl:
|
|
9022
|
+
vastUrl: requestUrl,
|
|
8958
9023
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
8959
9024
|
}, this.analyticsContext).catch(function() {});
|
|
8960
9025
|
this.timing.clearAdRequestWatchdog();
|