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/index.cjs
CHANGED
|
@@ -1439,7 +1439,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1439
1439
|
}
|
|
1440
1440
|
function playAd(bids) {
|
|
1441
1441
|
return _async_to_generator(function() {
|
|
1442
|
-
var winner, ad, contentVolume, _contentVideo_parentElement, container, adVolume, mediaFile;
|
|
1442
|
+
var winner, ad, contentVolume, adVolume2, mediaFile2, _contentVideo_parentElement, container, adVolume, mediaFile;
|
|
1443
1443
|
return _ts_generator(this, function(_state) {
|
|
1444
1444
|
switch(_state.label){
|
|
1445
1445
|
case 0:
|
|
@@ -1483,37 +1483,71 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1483
1483
|
trackingFired.impression = true;
|
|
1484
1484
|
contentVolume = contentVideo.volume;
|
|
1485
1485
|
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
1486
|
-
if (singleElementMode)
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1486
|
+
if (!singleElementMode) return [
|
|
1487
|
+
3,
|
|
1488
|
+
3
|
|
1489
|
+
];
|
|
1490
|
+
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1491
|
+
teardownCurrentPlayback();
|
|
1492
|
+
adVideoElement = contentVideo;
|
|
1493
|
+
adHls = void 0;
|
|
1494
|
+
adPlaying = true;
|
|
1495
|
+
setAdPlayingFlag(true);
|
|
1496
|
+
contentVideo.removeAttribute("src");
|
|
1497
|
+
contentVideo.load();
|
|
1498
|
+
if (!continueLiveStreamDuringAds) {
|
|
1499
|
+
contentVideo.pause();
|
|
1500
|
+
}
|
|
1501
|
+
contentVideo.muted = true;
|
|
1502
|
+
contentVideo.volume = 0;
|
|
1503
|
+
return [
|
|
1504
|
+
4,
|
|
1505
|
+
new Promise(function(resolve) {
|
|
1506
|
+
return setTimeout(resolve, 200);
|
|
1507
|
+
})
|
|
1508
|
+
];
|
|
1509
|
+
case 2:
|
|
1510
|
+
_state.sent();
|
|
1511
|
+
if (destroyed || tornDown) return [
|
|
1512
|
+
2
|
|
1513
|
+
];
|
|
1514
|
+
contentVideo.style.visibility = "visible";
|
|
1515
|
+
contentVideo.style.opacity = "1";
|
|
1516
|
+
emit("content_pause");
|
|
1517
|
+
setupAdEventListeners();
|
|
1518
|
+
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
1519
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1520
|
+
adVideoElement.muted = false;
|
|
1521
|
+
mediaFile2 = selectBestMediaFile(ad.mediaFiles);
|
|
1522
|
+
if (debug) console.log("".concat(LOG, " Loading ad from: ").concat(mediaFile2.url));
|
|
1523
|
+
startPlayback(mediaFile2);
|
|
1524
|
+
return [
|
|
1525
|
+
2
|
|
1526
|
+
];
|
|
1527
|
+
case 3:
|
|
1528
|
+
if (!adContainerEl) {
|
|
1529
|
+
;
|
|
1530
|
+
container = document.createElement("div");
|
|
1531
|
+
container.style.position = "absolute";
|
|
1532
|
+
container.style.left = "0";
|
|
1533
|
+
container.style.top = "0";
|
|
1534
|
+
container.style.right = "0";
|
|
1535
|
+
container.style.bottom = "0";
|
|
1536
|
+
container.style.display = "none";
|
|
1537
|
+
container.style.alignItems = "center";
|
|
1538
|
+
container.style.justifyContent = "center";
|
|
1539
|
+
container.style.pointerEvents = "none";
|
|
1540
|
+
container.style.zIndex = "10";
|
|
1541
|
+
container.style.backgroundColor = "#000";
|
|
1542
|
+
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1543
|
+
adContainerEl = container;
|
|
1544
|
+
}
|
|
1545
|
+
if (!adVideoElement) {
|
|
1546
|
+
adVideoElement = createAdVideoElement();
|
|
1547
|
+
adContainerEl.appendChild(adVideoElement);
|
|
1491
1548
|
setupAdEventListeners();
|
|
1492
1549
|
} else {
|
|
1493
|
-
|
|
1494
|
-
;
|
|
1495
|
-
container = document.createElement("div");
|
|
1496
|
-
container.style.position = "absolute";
|
|
1497
|
-
container.style.left = "0";
|
|
1498
|
-
container.style.top = "0";
|
|
1499
|
-
container.style.right = "0";
|
|
1500
|
-
container.style.bottom = "0";
|
|
1501
|
-
container.style.display = "none";
|
|
1502
|
-
container.style.alignItems = "center";
|
|
1503
|
-
container.style.justifyContent = "center";
|
|
1504
|
-
container.style.pointerEvents = "none";
|
|
1505
|
-
container.style.zIndex = "10";
|
|
1506
|
-
container.style.backgroundColor = "#000";
|
|
1507
|
-
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1508
|
-
adContainerEl = container;
|
|
1509
|
-
}
|
|
1510
|
-
if (!adVideoElement) {
|
|
1511
|
-
adVideoElement = createAdVideoElement();
|
|
1512
|
-
adContainerEl.appendChild(adVideoElement);
|
|
1513
|
-
setupAdEventListeners();
|
|
1514
|
-
} else {
|
|
1515
|
-
teardownCurrentPlayback();
|
|
1516
|
-
}
|
|
1550
|
+
teardownCurrentPlayback();
|
|
1517
1551
|
}
|
|
1518
1552
|
if (!continueLiveStreamDuringAds) {
|
|
1519
1553
|
contentVideo.pause();
|
|
@@ -1525,7 +1559,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1525
1559
|
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1526
1560
|
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1527
1561
|
adVideoElement.muted = false;
|
|
1528
|
-
if (
|
|
1562
|
+
if (adContainerEl) {
|
|
1529
1563
|
adContainerEl.style.display = "flex";
|
|
1530
1564
|
adContainerEl.style.pointerEvents = "auto";
|
|
1531
1565
|
}
|
|
@@ -1629,6 +1663,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1629
1663
|
if (debug) console.log("".concat(LOG, " [preload] HLS manifest parsed, token=").concat(token));
|
|
1630
1664
|
});
|
|
1631
1665
|
hls.on(import_hls.default.Events.ERROR, function(_evt, data) {
|
|
1666
|
+
if (!preloadSlots.has(token)) return;
|
|
1632
1667
|
if (data.fatal) {
|
|
1633
1668
|
if (debug) console.warn("".concat(LOG, " [preload] HLS error for token=").concat(token));
|
|
1634
1669
|
preloadSlots.delete(token);
|
|
@@ -1665,113 +1700,146 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1665
1700
|
}
|
|
1666
1701
|
function playPreloaded(token) {
|
|
1667
1702
|
return _async_to_generator(function() {
|
|
1668
|
-
var slot, contentVolume, adVolume2, videoEl, container2, adVolume21, adVolume, container;
|
|
1703
|
+
var slot, contentVolume, adVolume2, videoEl, container2, adVolume21, nonFatalNetworkErrors, adVolume, container;
|
|
1669
1704
|
return _ts_generator(this, function(_state) {
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1705
|
+
switch(_state.label){
|
|
1706
|
+
case 0:
|
|
1707
|
+
if (destroyed) return [
|
|
1708
|
+
2,
|
|
1709
|
+
Promise.reject(new Error("Layer has been destroyed"))
|
|
1710
|
+
];
|
|
1711
|
+
slot = preloadSlots.get(token);
|
|
1712
|
+
if (!slot) {
|
|
1713
|
+
if (debug) console.warn("".concat(LOG, " [preload] No slot found for token=").concat(token, ", nothing to play"));
|
|
1714
|
+
return [
|
|
1715
|
+
2
|
|
1716
|
+
];
|
|
1717
|
+
}
|
|
1718
|
+
preloadSlots.delete(token);
|
|
1719
|
+
if (debug) console.log("".concat(LOG, " [preload] Playing preloaded ad, token=").concat(token, ", ready=").concat(slot.ready));
|
|
1720
|
+
contentVolume = contentVideo.volume;
|
|
1721
|
+
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
1722
|
+
sessionId = generateSessionId();
|
|
1723
|
+
currentAd = slot.ad;
|
|
1724
|
+
trackingFired = _object_spread({}, createEmptyTrackingState());
|
|
1725
|
+
fireTrackingPixels2(slot.ad.trackingUrls.impression);
|
|
1726
|
+
trackingFired.impression = true;
|
|
1727
|
+
if (!singleElementMode) return [
|
|
1728
|
+
3,
|
|
1729
|
+
2
|
|
1730
|
+
];
|
|
1731
|
+
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1732
|
+
teardownCurrentPlayback();
|
|
1733
|
+
adVideoElement = contentVideo;
|
|
1734
|
+
adHls = void 0;
|
|
1735
|
+
adPlaying = true;
|
|
1736
|
+
setAdPlayingFlag(true);
|
|
1737
|
+
contentVideo.removeAttribute("src");
|
|
1738
|
+
contentVideo.load();
|
|
1739
|
+
contentVideo.muted = true;
|
|
1740
|
+
contentVideo.volume = 0;
|
|
1741
|
+
return [
|
|
1742
|
+
4,
|
|
1743
|
+
new Promise(function(resolve) {
|
|
1744
|
+
return setTimeout(resolve, 200);
|
|
1745
|
+
})
|
|
1746
|
+
];
|
|
1747
|
+
case 1:
|
|
1748
|
+
_state.sent();
|
|
1749
|
+
if (destroyed || tornDown) return [
|
|
1750
|
+
2
|
|
1751
|
+
];
|
|
1752
|
+
contentVideo.style.visibility = "visible";
|
|
1753
|
+
contentVideo.style.opacity = "1";
|
|
1754
|
+
emit("content_pause");
|
|
1755
|
+
setupAdEventListeners();
|
|
1756
|
+
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
1757
|
+
contentVideo.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1758
|
+
contentVideo.muted = false;
|
|
1759
|
+
if (debug) console.log("".concat(LOG, " [preload] singleElementMode: attaching ad to contentVideo, url=").concat(slot.mediaFile.url));
|
|
1760
|
+
startPlayback(slot.mediaFile);
|
|
1761
|
+
return [
|
|
1762
|
+
2
|
|
1763
|
+
];
|
|
1764
|
+
case 2:
|
|
1765
|
+
if (smartTVMode && !slot.videoEl) {
|
|
1766
|
+
teardownCurrentPlayback();
|
|
1767
|
+
if (adVideoElement) {
|
|
1768
|
+
adVideoElement.remove();
|
|
1769
|
+
adVideoElement = void 0;
|
|
1770
|
+
}
|
|
1771
|
+
videoEl = createAdVideoElement();
|
|
1772
|
+
videoEl.style.visibility = "visible";
|
|
1773
|
+
videoEl.style.pointerEvents = "none";
|
|
1774
|
+
container2 = ensureAdContainer();
|
|
1775
|
+
container2.appendChild(videoEl);
|
|
1776
|
+
adVideoElement = videoEl;
|
|
1777
|
+
setupAdEventListeners();
|
|
1778
|
+
if (!continueLiveStreamDuringAds) {
|
|
1779
|
+
contentVideo.pause();
|
|
1780
|
+
}
|
|
1781
|
+
contentVideo.muted = true;
|
|
1782
|
+
contentVideo.volume = 0;
|
|
1783
|
+
adPlaying = true;
|
|
1784
|
+
setAdPlayingFlag(true);
|
|
1785
|
+
adVolume21 = originalMutedState ? 1 : originalVolume;
|
|
1786
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume21));
|
|
1787
|
+
adVideoElement.muted = false;
|
|
1788
|
+
container2.style.display = "flex";
|
|
1789
|
+
container2.style.pointerEvents = "auto";
|
|
1790
|
+
emit("content_pause");
|
|
1791
|
+
if (debug) console.log("".concat(LOG, " [preload] smartTVMode deferred: creating video element and loading, url=").concat(slot.mediaFile.url));
|
|
1792
|
+
startPlayback(slot.mediaFile);
|
|
1793
|
+
return [
|
|
1794
|
+
2
|
|
1795
|
+
];
|
|
1796
|
+
}
|
|
1797
|
+
teardownCurrentPlayback();
|
|
1798
|
+
if (adVideoElement && adVideoElement !== slot.videoEl) {
|
|
1799
|
+
adVideoElement.remove();
|
|
1800
|
+
}
|
|
1801
|
+
slot.videoEl.style.visibility = "visible";
|
|
1802
|
+
slot.videoEl.style.pointerEvents = "none";
|
|
1803
|
+
adVideoElement = slot.videoEl;
|
|
1804
|
+
adHls = slot.hlsInstance;
|
|
1805
|
+
if (adHls) {
|
|
1806
|
+
nonFatalNetworkErrors = 0;
|
|
1807
|
+
adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
|
|
1808
|
+
if (!adPlaying) return;
|
|
1809
|
+
if (data.fatal) {
|
|
1810
|
+
handleAdError();
|
|
1811
|
+
} else if (data.type === import_hls.default.ErrorTypes.NETWORK_ERROR) {
|
|
1812
|
+
nonFatalNetworkErrors++;
|
|
1813
|
+
if (nonFatalNetworkErrors >= 3) {
|
|
1814
|
+
if (debug) console.warn("".concat(LOG, " [preload] Too many non-fatal HLS network errors during playback, treating as fatal"));
|
|
1815
|
+
handleAdError();
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
setupAdEventListeners();
|
|
1821
|
+
if (!continueLiveStreamDuringAds) {
|
|
1822
|
+
contentVideo.pause();
|
|
1823
|
+
}
|
|
1824
|
+
contentVideo.muted = true;
|
|
1825
|
+
contentVideo.volume = 0;
|
|
1826
|
+
adPlaying = true;
|
|
1827
|
+
setAdPlayingFlag(true);
|
|
1828
|
+
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1829
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1830
|
+
adVideoElement.muted = false;
|
|
1831
|
+
container = ensureAdContainer();
|
|
1832
|
+
container.style.display = "flex";
|
|
1833
|
+
container.style.pointerEvents = "auto";
|
|
1834
|
+
emit("content_pause");
|
|
1835
|
+
adVideoElement.play().catch(function(error) {
|
|
1836
|
+
console.error("".concat(LOG, " [preload] Error playing preloaded ad:"), error);
|
|
1837
|
+
handleAdError();
|
|
1838
|
+
});
|
|
1839
|
+
return [
|
|
1840
|
+
2
|
|
1841
|
+
];
|
|
1748
1842
|
}
|
|
1749
|
-
slot.videoEl.style.visibility = "visible";
|
|
1750
|
-
slot.videoEl.style.pointerEvents = "none";
|
|
1751
|
-
adVideoElement = slot.videoEl;
|
|
1752
|
-
adHls = slot.hlsInstance;
|
|
1753
|
-
setupAdEventListeners();
|
|
1754
|
-
if (!continueLiveStreamDuringAds) {
|
|
1755
|
-
contentVideo.pause();
|
|
1756
|
-
}
|
|
1757
|
-
contentVideo.muted = true;
|
|
1758
|
-
contentVideo.volume = 0;
|
|
1759
|
-
adPlaying = true;
|
|
1760
|
-
setAdPlayingFlag(true);
|
|
1761
|
-
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1762
|
-
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1763
|
-
adVideoElement.muted = false;
|
|
1764
|
-
container = ensureAdContainer();
|
|
1765
|
-
container.style.display = "flex";
|
|
1766
|
-
container.style.pointerEvents = "auto";
|
|
1767
|
-
emit("content_pause");
|
|
1768
|
-
adVideoElement.play().catch(function(error) {
|
|
1769
|
-
console.error("".concat(LOG, " [preload] Error playing preloaded ad:"), error);
|
|
1770
|
-
handleAdError();
|
|
1771
|
-
});
|
|
1772
|
-
return [
|
|
1773
|
-
2
|
|
1774
|
-
];
|
|
1775
1843
|
});
|
|
1776
1844
|
})();
|
|
1777
1845
|
}
|
|
@@ -4052,7 +4120,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4052
4120
|
};
|
|
4053
4121
|
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
4054
4122
|
}
|
|
4055
|
-
if (!this.config.disableFiller && !this.video.muted) {
|
|
4123
|
+
if (!this.config.disableFiller && !this.video.muted && !this.adLayer.isAdPlaying()) {
|
|
4056
4124
|
this.video.muted = true;
|
|
4057
4125
|
this.video.volume = 0;
|
|
4058
4126
|
if (this.config.debugAdTiming) {
|
|
@@ -5686,7 +5754,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5686
5754
|
console.log("[StormcloudVideoPlayer] Smart TV: audio state restored on MANIFEST_PARSED after re-attach");
|
|
5687
5755
|
}
|
|
5688
5756
|
hlsRef.startLoad(-1);
|
|
5689
|
-
tryPlay(0);
|
|
5690
5757
|
if (debugEnabled) {
|
|
5691
5758
|
console.log("[StormcloudVideoPlayer] Smart TV: seeking to live edge and resuming playback after re-attach");
|
|
5692
5759
|
}
|