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
package/lib/players/index.cjs
CHANGED
|
@@ -1345,7 +1345,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1345
1345
|
}
|
|
1346
1346
|
function playAd(bids) {
|
|
1347
1347
|
return _async_to_generator(function() {
|
|
1348
|
-
var winner, ad, contentVolume, _contentVideo_parentElement, container, adVolume, mediaFile;
|
|
1348
|
+
var winner, ad, contentVolume, adVolume2, mediaFile2, _contentVideo_parentElement, container, adVolume, mediaFile;
|
|
1349
1349
|
return _ts_generator(this, function(_state) {
|
|
1350
1350
|
switch(_state.label){
|
|
1351
1351
|
case 0:
|
|
@@ -1389,37 +1389,71 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1389
1389
|
trackingFired.impression = true;
|
|
1390
1390
|
contentVolume = contentVideo.volume;
|
|
1391
1391
|
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
1392
|
-
if (singleElementMode)
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1392
|
+
if (!singleElementMode) return [
|
|
1393
|
+
3,
|
|
1394
|
+
3
|
|
1395
|
+
];
|
|
1396
|
+
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1397
|
+
teardownCurrentPlayback();
|
|
1398
|
+
adVideoElement = contentVideo;
|
|
1399
|
+
adHls = void 0;
|
|
1400
|
+
adPlaying = true;
|
|
1401
|
+
setAdPlayingFlag(true);
|
|
1402
|
+
contentVideo.removeAttribute("src");
|
|
1403
|
+
contentVideo.load();
|
|
1404
|
+
if (!continueLiveStreamDuringAds) {
|
|
1405
|
+
contentVideo.pause();
|
|
1406
|
+
}
|
|
1407
|
+
contentVideo.muted = true;
|
|
1408
|
+
contentVideo.volume = 0;
|
|
1409
|
+
return [
|
|
1410
|
+
4,
|
|
1411
|
+
new Promise(function(resolve) {
|
|
1412
|
+
return setTimeout(resolve, 200);
|
|
1413
|
+
})
|
|
1414
|
+
];
|
|
1415
|
+
case 2:
|
|
1416
|
+
_state.sent();
|
|
1417
|
+
if (destroyed || tornDown) return [
|
|
1418
|
+
2
|
|
1419
|
+
];
|
|
1420
|
+
contentVideo.style.visibility = "visible";
|
|
1421
|
+
contentVideo.style.opacity = "1";
|
|
1422
|
+
emit("content_pause");
|
|
1423
|
+
setupAdEventListeners();
|
|
1424
|
+
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
1425
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1426
|
+
adVideoElement.muted = false;
|
|
1427
|
+
mediaFile2 = selectBestMediaFile(ad.mediaFiles);
|
|
1428
|
+
if (debug) console.log("".concat(LOG, " Loading ad from: ").concat(mediaFile2.url));
|
|
1429
|
+
startPlayback(mediaFile2);
|
|
1430
|
+
return [
|
|
1431
|
+
2
|
|
1432
|
+
];
|
|
1433
|
+
case 3:
|
|
1434
|
+
if (!adContainerEl) {
|
|
1435
|
+
;
|
|
1436
|
+
container = document.createElement("div");
|
|
1437
|
+
container.style.position = "absolute";
|
|
1438
|
+
container.style.left = "0";
|
|
1439
|
+
container.style.top = "0";
|
|
1440
|
+
container.style.right = "0";
|
|
1441
|
+
container.style.bottom = "0";
|
|
1442
|
+
container.style.display = "none";
|
|
1443
|
+
container.style.alignItems = "center";
|
|
1444
|
+
container.style.justifyContent = "center";
|
|
1445
|
+
container.style.pointerEvents = "none";
|
|
1446
|
+
container.style.zIndex = "10";
|
|
1447
|
+
container.style.backgroundColor = "#000";
|
|
1448
|
+
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1449
|
+
adContainerEl = container;
|
|
1450
|
+
}
|
|
1451
|
+
if (!adVideoElement) {
|
|
1452
|
+
adVideoElement = createAdVideoElement();
|
|
1453
|
+
adContainerEl.appendChild(adVideoElement);
|
|
1397
1454
|
setupAdEventListeners();
|
|
1398
1455
|
} else {
|
|
1399
|
-
|
|
1400
|
-
;
|
|
1401
|
-
container = document.createElement("div");
|
|
1402
|
-
container.style.position = "absolute";
|
|
1403
|
-
container.style.left = "0";
|
|
1404
|
-
container.style.top = "0";
|
|
1405
|
-
container.style.right = "0";
|
|
1406
|
-
container.style.bottom = "0";
|
|
1407
|
-
container.style.display = "none";
|
|
1408
|
-
container.style.alignItems = "center";
|
|
1409
|
-
container.style.justifyContent = "center";
|
|
1410
|
-
container.style.pointerEvents = "none";
|
|
1411
|
-
container.style.zIndex = "10";
|
|
1412
|
-
container.style.backgroundColor = "#000";
|
|
1413
|
-
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1414
|
-
adContainerEl = container;
|
|
1415
|
-
}
|
|
1416
|
-
if (!adVideoElement) {
|
|
1417
|
-
adVideoElement = createAdVideoElement();
|
|
1418
|
-
adContainerEl.appendChild(adVideoElement);
|
|
1419
|
-
setupAdEventListeners();
|
|
1420
|
-
} else {
|
|
1421
|
-
teardownCurrentPlayback();
|
|
1422
|
-
}
|
|
1456
|
+
teardownCurrentPlayback();
|
|
1423
1457
|
}
|
|
1424
1458
|
if (!continueLiveStreamDuringAds) {
|
|
1425
1459
|
contentVideo.pause();
|
|
@@ -1431,7 +1465,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1431
1465
|
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1432
1466
|
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1433
1467
|
adVideoElement.muted = false;
|
|
1434
|
-
if (
|
|
1468
|
+
if (adContainerEl) {
|
|
1435
1469
|
adContainerEl.style.display = "flex";
|
|
1436
1470
|
adContainerEl.style.pointerEvents = "auto";
|
|
1437
1471
|
}
|
|
@@ -1535,6 +1569,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1535
1569
|
if (debug) console.log("".concat(LOG, " [preload] HLS manifest parsed, token=").concat(token));
|
|
1536
1570
|
});
|
|
1537
1571
|
hls.on(import_hls.default.Events.ERROR, function(_evt, data) {
|
|
1572
|
+
if (!preloadSlots.has(token)) return;
|
|
1538
1573
|
if (data.fatal) {
|
|
1539
1574
|
if (debug) console.warn("".concat(LOG, " [preload] HLS error for token=").concat(token));
|
|
1540
1575
|
preloadSlots.delete(token);
|
|
@@ -1571,113 +1606,146 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1571
1606
|
}
|
|
1572
1607
|
function playPreloaded(token) {
|
|
1573
1608
|
return _async_to_generator(function() {
|
|
1574
|
-
var slot, contentVolume, adVolume2, videoEl, container2, adVolume21, adVolume, container;
|
|
1609
|
+
var slot, contentVolume, adVolume2, videoEl, container2, adVolume21, nonFatalNetworkErrors, adVolume, container;
|
|
1575
1610
|
return _ts_generator(this, function(_state) {
|
|
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
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1611
|
+
switch(_state.label){
|
|
1612
|
+
case 0:
|
|
1613
|
+
if (destroyed) return [
|
|
1614
|
+
2,
|
|
1615
|
+
Promise.reject(new Error("Layer has been destroyed"))
|
|
1616
|
+
];
|
|
1617
|
+
slot = preloadSlots.get(token);
|
|
1618
|
+
if (!slot) {
|
|
1619
|
+
if (debug) console.warn("".concat(LOG, " [preload] No slot found for token=").concat(token, ", nothing to play"));
|
|
1620
|
+
return [
|
|
1621
|
+
2
|
|
1622
|
+
];
|
|
1623
|
+
}
|
|
1624
|
+
preloadSlots.delete(token);
|
|
1625
|
+
if (debug) console.log("".concat(LOG, " [preload] Playing preloaded ad, token=").concat(token, ", ready=").concat(slot.ready));
|
|
1626
|
+
contentVolume = contentVideo.volume;
|
|
1627
|
+
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
1628
|
+
sessionId = generateSessionId();
|
|
1629
|
+
currentAd = slot.ad;
|
|
1630
|
+
trackingFired = _object_spread({}, createEmptyTrackingState());
|
|
1631
|
+
fireTrackingPixels2(slot.ad.trackingUrls.impression);
|
|
1632
|
+
trackingFired.impression = true;
|
|
1633
|
+
if (!singleElementMode) return [
|
|
1634
|
+
3,
|
|
1635
|
+
2
|
|
1636
|
+
];
|
|
1637
|
+
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1638
|
+
teardownCurrentPlayback();
|
|
1639
|
+
adVideoElement = contentVideo;
|
|
1640
|
+
adHls = void 0;
|
|
1641
|
+
adPlaying = true;
|
|
1642
|
+
setAdPlayingFlag(true);
|
|
1643
|
+
contentVideo.removeAttribute("src");
|
|
1644
|
+
contentVideo.load();
|
|
1645
|
+
contentVideo.muted = true;
|
|
1646
|
+
contentVideo.volume = 0;
|
|
1647
|
+
return [
|
|
1648
|
+
4,
|
|
1649
|
+
new Promise(function(resolve) {
|
|
1650
|
+
return setTimeout(resolve, 200);
|
|
1651
|
+
})
|
|
1652
|
+
];
|
|
1653
|
+
case 1:
|
|
1654
|
+
_state.sent();
|
|
1655
|
+
if (destroyed || tornDown) return [
|
|
1656
|
+
2
|
|
1657
|
+
];
|
|
1658
|
+
contentVideo.style.visibility = "visible";
|
|
1659
|
+
contentVideo.style.opacity = "1";
|
|
1660
|
+
emit("content_pause");
|
|
1661
|
+
setupAdEventListeners();
|
|
1662
|
+
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
1663
|
+
contentVideo.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1664
|
+
contentVideo.muted = false;
|
|
1665
|
+
if (debug) console.log("".concat(LOG, " [preload] singleElementMode: attaching ad to contentVideo, url=").concat(slot.mediaFile.url));
|
|
1666
|
+
startPlayback(slot.mediaFile);
|
|
1667
|
+
return [
|
|
1668
|
+
2
|
|
1669
|
+
];
|
|
1670
|
+
case 2:
|
|
1671
|
+
if (smartTVMode && !slot.videoEl) {
|
|
1672
|
+
teardownCurrentPlayback();
|
|
1673
|
+
if (adVideoElement) {
|
|
1674
|
+
adVideoElement.remove();
|
|
1675
|
+
adVideoElement = void 0;
|
|
1676
|
+
}
|
|
1677
|
+
videoEl = createAdVideoElement();
|
|
1678
|
+
videoEl.style.visibility = "visible";
|
|
1679
|
+
videoEl.style.pointerEvents = "none";
|
|
1680
|
+
container2 = ensureAdContainer();
|
|
1681
|
+
container2.appendChild(videoEl);
|
|
1682
|
+
adVideoElement = videoEl;
|
|
1683
|
+
setupAdEventListeners();
|
|
1684
|
+
if (!continueLiveStreamDuringAds) {
|
|
1685
|
+
contentVideo.pause();
|
|
1686
|
+
}
|
|
1687
|
+
contentVideo.muted = true;
|
|
1688
|
+
contentVideo.volume = 0;
|
|
1689
|
+
adPlaying = true;
|
|
1690
|
+
setAdPlayingFlag(true);
|
|
1691
|
+
adVolume21 = originalMutedState ? 1 : originalVolume;
|
|
1692
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume21));
|
|
1693
|
+
adVideoElement.muted = false;
|
|
1694
|
+
container2.style.display = "flex";
|
|
1695
|
+
container2.style.pointerEvents = "auto";
|
|
1696
|
+
emit("content_pause");
|
|
1697
|
+
if (debug) console.log("".concat(LOG, " [preload] smartTVMode deferred: creating video element and loading, url=").concat(slot.mediaFile.url));
|
|
1698
|
+
startPlayback(slot.mediaFile);
|
|
1699
|
+
return [
|
|
1700
|
+
2
|
|
1701
|
+
];
|
|
1702
|
+
}
|
|
1703
|
+
teardownCurrentPlayback();
|
|
1704
|
+
if (adVideoElement && adVideoElement !== slot.videoEl) {
|
|
1705
|
+
adVideoElement.remove();
|
|
1706
|
+
}
|
|
1707
|
+
slot.videoEl.style.visibility = "visible";
|
|
1708
|
+
slot.videoEl.style.pointerEvents = "none";
|
|
1709
|
+
adVideoElement = slot.videoEl;
|
|
1710
|
+
adHls = slot.hlsInstance;
|
|
1711
|
+
if (adHls) {
|
|
1712
|
+
nonFatalNetworkErrors = 0;
|
|
1713
|
+
adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
|
|
1714
|
+
if (!adPlaying) return;
|
|
1715
|
+
if (data.fatal) {
|
|
1716
|
+
handleAdError();
|
|
1717
|
+
} else if (data.type === import_hls.default.ErrorTypes.NETWORK_ERROR) {
|
|
1718
|
+
nonFatalNetworkErrors++;
|
|
1719
|
+
if (nonFatalNetworkErrors >= 3) {
|
|
1720
|
+
if (debug) console.warn("".concat(LOG, " [preload] Too many non-fatal HLS network errors during playback, treating as fatal"));
|
|
1721
|
+
handleAdError();
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
setupAdEventListeners();
|
|
1727
|
+
if (!continueLiveStreamDuringAds) {
|
|
1728
|
+
contentVideo.pause();
|
|
1729
|
+
}
|
|
1730
|
+
contentVideo.muted = true;
|
|
1731
|
+
contentVideo.volume = 0;
|
|
1732
|
+
adPlaying = true;
|
|
1733
|
+
setAdPlayingFlag(true);
|
|
1734
|
+
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1735
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1736
|
+
adVideoElement.muted = false;
|
|
1737
|
+
container = ensureAdContainer();
|
|
1738
|
+
container.style.display = "flex";
|
|
1739
|
+
container.style.pointerEvents = "auto";
|
|
1740
|
+
emit("content_pause");
|
|
1741
|
+
adVideoElement.play().catch(function(error) {
|
|
1742
|
+
console.error("".concat(LOG, " [preload] Error playing preloaded ad:"), error);
|
|
1743
|
+
handleAdError();
|
|
1744
|
+
});
|
|
1745
|
+
return [
|
|
1746
|
+
2
|
|
1747
|
+
];
|
|
1662
1748
|
}
|
|
1663
|
-
contentVideo.muted = true;
|
|
1664
|
-
contentVideo.volume = 0;
|
|
1665
|
-
adPlaying = true;
|
|
1666
|
-
setAdPlayingFlag(true);
|
|
1667
|
-
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1668
|
-
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1669
|
-
adVideoElement.muted = false;
|
|
1670
|
-
container = ensureAdContainer();
|
|
1671
|
-
container.style.display = "flex";
|
|
1672
|
-
container.style.pointerEvents = "auto";
|
|
1673
|
-
emit("content_pause");
|
|
1674
|
-
adVideoElement.play().catch(function(error) {
|
|
1675
|
-
console.error("".concat(LOG, " [preload] Error playing preloaded ad:"), error);
|
|
1676
|
-
handleAdError();
|
|
1677
|
-
});
|
|
1678
|
-
return [
|
|
1679
|
-
2
|
|
1680
|
-
];
|
|
1681
1749
|
});
|
|
1682
1750
|
})();
|
|
1683
1751
|
}
|
|
@@ -3933,7 +4001,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3933
4001
|
};
|
|
3934
4002
|
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3935
4003
|
}
|
|
3936
|
-
if (!this.config.disableFiller && !this.video.muted) {
|
|
4004
|
+
if (!this.config.disableFiller && !this.video.muted && !this.adLayer.isAdPlaying()) {
|
|
3937
4005
|
this.video.muted = true;
|
|
3938
4006
|
this.video.volume = 0;
|
|
3939
4007
|
if (this.config.debugAdTiming) {
|
|
@@ -5567,7 +5635,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5567
5635
|
console.log("[StormcloudVideoPlayer] Smart TV: audio state restored on MANIFEST_PARSED after re-attach");
|
|
5568
5636
|
}
|
|
5569
5637
|
hlsRef.startLoad(-1);
|
|
5570
|
-
tryPlay(0);
|
|
5571
5638
|
if (debugEnabled) {
|
|
5572
5639
|
console.log("[StormcloudVideoPlayer] Smart TV: seeking to live edge and resuming playback after re-attach");
|
|
5573
5640
|
}
|