stormcloud-video-player 0.6.2 → 0.6.3
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/index.cjs +205 -138
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +205 -138
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +205 -138
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +205 -138
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +205 -138
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/vastAdLayer.cjs +204 -136
- package/lib/sdk/vastAdLayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +205 -138
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -1295,7 +1295,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1295
1295
|
}
|
|
1296
1296
|
function playAd(bids) {
|
|
1297
1297
|
return _async_to_generator(function() {
|
|
1298
|
-
var winner, ad, contentVolume, _contentVideo_parentElement, container, adVolume, mediaFile;
|
|
1298
|
+
var winner, ad, contentVolume, adVolume2, mediaFile2, _contentVideo_parentElement, container, adVolume, mediaFile;
|
|
1299
1299
|
return _ts_generator(this, function(_state) {
|
|
1300
1300
|
switch(_state.label){
|
|
1301
1301
|
case 0:
|
|
@@ -1339,37 +1339,71 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1339
1339
|
trackingFired.impression = true;
|
|
1340
1340
|
contentVolume = contentVideo.volume;
|
|
1341
1341
|
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
1342
|
-
if (singleElementMode)
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1342
|
+
if (!singleElementMode) return [
|
|
1343
|
+
3,
|
|
1344
|
+
3
|
|
1345
|
+
];
|
|
1346
|
+
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1347
|
+
teardownCurrentPlayback();
|
|
1348
|
+
adVideoElement = contentVideo;
|
|
1349
|
+
adHls = void 0;
|
|
1350
|
+
adPlaying = true;
|
|
1351
|
+
setAdPlayingFlag(true);
|
|
1352
|
+
contentVideo.removeAttribute("src");
|
|
1353
|
+
contentVideo.load();
|
|
1354
|
+
if (!continueLiveStreamDuringAds) {
|
|
1355
|
+
contentVideo.pause();
|
|
1356
|
+
}
|
|
1357
|
+
contentVideo.muted = true;
|
|
1358
|
+
contentVideo.volume = 0;
|
|
1359
|
+
return [
|
|
1360
|
+
4,
|
|
1361
|
+
new Promise(function(resolve) {
|
|
1362
|
+
return setTimeout(resolve, 200);
|
|
1363
|
+
})
|
|
1364
|
+
];
|
|
1365
|
+
case 2:
|
|
1366
|
+
_state.sent();
|
|
1367
|
+
if (destroyed || tornDown) return [
|
|
1368
|
+
2
|
|
1369
|
+
];
|
|
1370
|
+
contentVideo.style.visibility = "visible";
|
|
1371
|
+
contentVideo.style.opacity = "1";
|
|
1372
|
+
emit("content_pause");
|
|
1373
|
+
setupAdEventListeners();
|
|
1374
|
+
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
1375
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1376
|
+
adVideoElement.muted = false;
|
|
1377
|
+
mediaFile2 = selectBestMediaFile(ad.mediaFiles);
|
|
1378
|
+
if (debug) console.log("".concat(LOG, " Loading ad from: ").concat(mediaFile2.url));
|
|
1379
|
+
startPlayback(mediaFile2);
|
|
1380
|
+
return [
|
|
1381
|
+
2
|
|
1382
|
+
];
|
|
1383
|
+
case 3:
|
|
1384
|
+
if (!adContainerEl) {
|
|
1385
|
+
;
|
|
1386
|
+
container = document.createElement("div");
|
|
1387
|
+
container.style.position = "absolute";
|
|
1388
|
+
container.style.left = "0";
|
|
1389
|
+
container.style.top = "0";
|
|
1390
|
+
container.style.right = "0";
|
|
1391
|
+
container.style.bottom = "0";
|
|
1392
|
+
container.style.display = "none";
|
|
1393
|
+
container.style.alignItems = "center";
|
|
1394
|
+
container.style.justifyContent = "center";
|
|
1395
|
+
container.style.pointerEvents = "none";
|
|
1396
|
+
container.style.zIndex = "10";
|
|
1397
|
+
container.style.backgroundColor = "#000";
|
|
1398
|
+
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1399
|
+
adContainerEl = container;
|
|
1400
|
+
}
|
|
1401
|
+
if (!adVideoElement) {
|
|
1402
|
+
adVideoElement = createAdVideoElement();
|
|
1403
|
+
adContainerEl.appendChild(adVideoElement);
|
|
1347
1404
|
setupAdEventListeners();
|
|
1348
1405
|
} else {
|
|
1349
|
-
|
|
1350
|
-
;
|
|
1351
|
-
container = document.createElement("div");
|
|
1352
|
-
container.style.position = "absolute";
|
|
1353
|
-
container.style.left = "0";
|
|
1354
|
-
container.style.top = "0";
|
|
1355
|
-
container.style.right = "0";
|
|
1356
|
-
container.style.bottom = "0";
|
|
1357
|
-
container.style.display = "none";
|
|
1358
|
-
container.style.alignItems = "center";
|
|
1359
|
-
container.style.justifyContent = "center";
|
|
1360
|
-
container.style.pointerEvents = "none";
|
|
1361
|
-
container.style.zIndex = "10";
|
|
1362
|
-
container.style.backgroundColor = "#000";
|
|
1363
|
-
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1364
|
-
adContainerEl = container;
|
|
1365
|
-
}
|
|
1366
|
-
if (!adVideoElement) {
|
|
1367
|
-
adVideoElement = createAdVideoElement();
|
|
1368
|
-
adContainerEl.appendChild(adVideoElement);
|
|
1369
|
-
setupAdEventListeners();
|
|
1370
|
-
} else {
|
|
1371
|
-
teardownCurrentPlayback();
|
|
1372
|
-
}
|
|
1406
|
+
teardownCurrentPlayback();
|
|
1373
1407
|
}
|
|
1374
1408
|
if (!continueLiveStreamDuringAds) {
|
|
1375
1409
|
contentVideo.pause();
|
|
@@ -1381,7 +1415,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1381
1415
|
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1382
1416
|
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1383
1417
|
adVideoElement.muted = false;
|
|
1384
|
-
if (
|
|
1418
|
+
if (adContainerEl) {
|
|
1385
1419
|
adContainerEl.style.display = "flex";
|
|
1386
1420
|
adContainerEl.style.pointerEvents = "auto";
|
|
1387
1421
|
}
|
|
@@ -1485,6 +1519,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1485
1519
|
if (debug) console.log("".concat(LOG, " [preload] HLS manifest parsed, token=").concat(token));
|
|
1486
1520
|
});
|
|
1487
1521
|
hls.on(import_hls.default.Events.ERROR, function(_evt, data) {
|
|
1522
|
+
if (!preloadSlots.has(token)) return;
|
|
1488
1523
|
if (data.fatal) {
|
|
1489
1524
|
if (debug) console.warn("".concat(LOG, " [preload] HLS error for token=").concat(token));
|
|
1490
1525
|
preloadSlots.delete(token);
|
|
@@ -1521,113 +1556,146 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1521
1556
|
}
|
|
1522
1557
|
function playPreloaded(token) {
|
|
1523
1558
|
return _async_to_generator(function() {
|
|
1524
|
-
var slot, contentVolume, adVolume2, videoEl, container2, adVolume21, adVolume, container;
|
|
1559
|
+
var slot, contentVolume, adVolume2, videoEl, container2, adVolume21, nonFatalNetworkErrors, adVolume, container;
|
|
1525
1560
|
return _ts_generator(this, function(_state) {
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1561
|
+
switch(_state.label){
|
|
1562
|
+
case 0:
|
|
1563
|
+
if (destroyed) return [
|
|
1564
|
+
2,
|
|
1565
|
+
Promise.reject(new Error("Layer has been destroyed"))
|
|
1566
|
+
];
|
|
1567
|
+
slot = preloadSlots.get(token);
|
|
1568
|
+
if (!slot) {
|
|
1569
|
+
if (debug) console.warn("".concat(LOG, " [preload] No slot found for token=").concat(token, ", nothing to play"));
|
|
1570
|
+
return [
|
|
1571
|
+
2
|
|
1572
|
+
];
|
|
1573
|
+
}
|
|
1574
|
+
preloadSlots.delete(token);
|
|
1575
|
+
if (debug) console.log("".concat(LOG, " [preload] Playing preloaded ad, token=").concat(token, ", ready=").concat(slot.ready));
|
|
1576
|
+
contentVolume = contentVideo.volume;
|
|
1577
|
+
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
1578
|
+
sessionId = generateSessionId();
|
|
1579
|
+
currentAd = slot.ad;
|
|
1580
|
+
trackingFired = _object_spread({}, createEmptyTrackingState());
|
|
1581
|
+
fireTrackingPixels2(slot.ad.trackingUrls.impression);
|
|
1582
|
+
trackingFired.impression = true;
|
|
1583
|
+
if (!singleElementMode) return [
|
|
1584
|
+
3,
|
|
1585
|
+
2
|
|
1586
|
+
];
|
|
1587
|
+
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1588
|
+
teardownCurrentPlayback();
|
|
1589
|
+
adVideoElement = contentVideo;
|
|
1590
|
+
adHls = void 0;
|
|
1591
|
+
adPlaying = true;
|
|
1592
|
+
setAdPlayingFlag(true);
|
|
1593
|
+
contentVideo.removeAttribute("src");
|
|
1594
|
+
contentVideo.load();
|
|
1595
|
+
contentVideo.muted = true;
|
|
1596
|
+
contentVideo.volume = 0;
|
|
1597
|
+
return [
|
|
1598
|
+
4,
|
|
1599
|
+
new Promise(function(resolve) {
|
|
1600
|
+
return setTimeout(resolve, 200);
|
|
1601
|
+
})
|
|
1602
|
+
];
|
|
1603
|
+
case 1:
|
|
1604
|
+
_state.sent();
|
|
1605
|
+
if (destroyed || tornDown) return [
|
|
1606
|
+
2
|
|
1607
|
+
];
|
|
1608
|
+
contentVideo.style.visibility = "visible";
|
|
1609
|
+
contentVideo.style.opacity = "1";
|
|
1610
|
+
emit("content_pause");
|
|
1611
|
+
setupAdEventListeners();
|
|
1612
|
+
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
1613
|
+
contentVideo.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1614
|
+
contentVideo.muted = false;
|
|
1615
|
+
if (debug) console.log("".concat(LOG, " [preload] singleElementMode: attaching ad to contentVideo, url=").concat(slot.mediaFile.url));
|
|
1616
|
+
startPlayback(slot.mediaFile);
|
|
1617
|
+
return [
|
|
1618
|
+
2
|
|
1619
|
+
];
|
|
1620
|
+
case 2:
|
|
1621
|
+
if (smartTVMode && !slot.videoEl) {
|
|
1622
|
+
teardownCurrentPlayback();
|
|
1623
|
+
if (adVideoElement) {
|
|
1624
|
+
adVideoElement.remove();
|
|
1625
|
+
adVideoElement = void 0;
|
|
1626
|
+
}
|
|
1627
|
+
videoEl = createAdVideoElement();
|
|
1628
|
+
videoEl.style.visibility = "visible";
|
|
1629
|
+
videoEl.style.pointerEvents = "none";
|
|
1630
|
+
container2 = ensureAdContainer();
|
|
1631
|
+
container2.appendChild(videoEl);
|
|
1632
|
+
adVideoElement = videoEl;
|
|
1633
|
+
setupAdEventListeners();
|
|
1634
|
+
if (!continueLiveStreamDuringAds) {
|
|
1635
|
+
contentVideo.pause();
|
|
1636
|
+
}
|
|
1637
|
+
contentVideo.muted = true;
|
|
1638
|
+
contentVideo.volume = 0;
|
|
1639
|
+
adPlaying = true;
|
|
1640
|
+
setAdPlayingFlag(true);
|
|
1641
|
+
adVolume21 = originalMutedState ? 1 : originalVolume;
|
|
1642
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume21));
|
|
1643
|
+
adVideoElement.muted = false;
|
|
1644
|
+
container2.style.display = "flex";
|
|
1645
|
+
container2.style.pointerEvents = "auto";
|
|
1646
|
+
emit("content_pause");
|
|
1647
|
+
if (debug) console.log("".concat(LOG, " [preload] smartTVMode deferred: creating video element and loading, url=").concat(slot.mediaFile.url));
|
|
1648
|
+
startPlayback(slot.mediaFile);
|
|
1649
|
+
return [
|
|
1650
|
+
2
|
|
1651
|
+
];
|
|
1652
|
+
}
|
|
1653
|
+
teardownCurrentPlayback();
|
|
1654
|
+
if (adVideoElement && adVideoElement !== slot.videoEl) {
|
|
1655
|
+
adVideoElement.remove();
|
|
1656
|
+
}
|
|
1657
|
+
slot.videoEl.style.visibility = "visible";
|
|
1658
|
+
slot.videoEl.style.pointerEvents = "none";
|
|
1659
|
+
adVideoElement = slot.videoEl;
|
|
1660
|
+
adHls = slot.hlsInstance;
|
|
1661
|
+
if (adHls) {
|
|
1662
|
+
nonFatalNetworkErrors = 0;
|
|
1663
|
+
adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
|
|
1664
|
+
if (!adPlaying) return;
|
|
1665
|
+
if (data.fatal) {
|
|
1666
|
+
handleAdError();
|
|
1667
|
+
} else if (data.type === import_hls.default.ErrorTypes.NETWORK_ERROR) {
|
|
1668
|
+
nonFatalNetworkErrors++;
|
|
1669
|
+
if (nonFatalNetworkErrors >= 3) {
|
|
1670
|
+
if (debug) console.warn("".concat(LOG, " [preload] Too many non-fatal HLS network errors during playback, treating as fatal"));
|
|
1671
|
+
handleAdError();
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
setupAdEventListeners();
|
|
1677
|
+
if (!continueLiveStreamDuringAds) {
|
|
1678
|
+
contentVideo.pause();
|
|
1679
|
+
}
|
|
1680
|
+
contentVideo.muted = true;
|
|
1681
|
+
contentVideo.volume = 0;
|
|
1682
|
+
adPlaying = true;
|
|
1683
|
+
setAdPlayingFlag(true);
|
|
1684
|
+
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1685
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1686
|
+
adVideoElement.muted = false;
|
|
1687
|
+
container = ensureAdContainer();
|
|
1688
|
+
container.style.display = "flex";
|
|
1689
|
+
container.style.pointerEvents = "auto";
|
|
1690
|
+
emit("content_pause");
|
|
1691
|
+
adVideoElement.play().catch(function(error) {
|
|
1692
|
+
console.error("".concat(LOG, " [preload] Error playing preloaded ad:"), error);
|
|
1693
|
+
handleAdError();
|
|
1694
|
+
});
|
|
1695
|
+
return [
|
|
1696
|
+
2
|
|
1697
|
+
];
|
|
1612
1698
|
}
|
|
1613
|
-
contentVideo.muted = true;
|
|
1614
|
-
contentVideo.volume = 0;
|
|
1615
|
-
adPlaying = true;
|
|
1616
|
-
setAdPlayingFlag(true);
|
|
1617
|
-
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1618
|
-
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1619
|
-
adVideoElement.muted = false;
|
|
1620
|
-
container = ensureAdContainer();
|
|
1621
|
-
container.style.display = "flex";
|
|
1622
|
-
container.style.pointerEvents = "auto";
|
|
1623
|
-
emit("content_pause");
|
|
1624
|
-
adVideoElement.play().catch(function(error) {
|
|
1625
|
-
console.error("".concat(LOG, " [preload] Error playing preloaded ad:"), error);
|
|
1626
|
-
handleAdError();
|
|
1627
|
-
});
|
|
1628
|
-
return [
|
|
1629
|
-
2
|
|
1630
|
-
];
|
|
1631
1699
|
});
|
|
1632
1700
|
})();
|
|
1633
1701
|
}
|
|
@@ -3883,7 +3951,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3883
3951
|
};
|
|
3884
3952
|
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3885
3953
|
}
|
|
3886
|
-
if (!this.config.disableFiller && !this.video.muted) {
|
|
3954
|
+
if (!this.config.disableFiller && !this.video.muted && !this.adLayer.isAdPlaying()) {
|
|
3887
3955
|
this.video.muted = true;
|
|
3888
3956
|
this.video.volume = 0;
|
|
3889
3957
|
if (this.config.debugAdTiming) {
|
|
@@ -5517,7 +5585,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5517
5585
|
console.log("[StormcloudVideoPlayer] Smart TV: audio state restored on MANIFEST_PARSED after re-attach");
|
|
5518
5586
|
}
|
|
5519
5587
|
hlsRef.startLoad(-1);
|
|
5520
|
-
tryPlay(0);
|
|
5521
5588
|
if (debugEnabled) {
|
|
5522
5589
|
console.log("[StormcloudVideoPlayer] Smart TV: seeking to live edge and resuming playback after re-attach");
|
|
5523
5590
|
}
|