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