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
|
@@ -1309,7 +1309,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1309
1309
|
}
|
|
1310
1310
|
function playAd(bids) {
|
|
1311
1311
|
return _async_to_generator(function() {
|
|
1312
|
-
var winner, ad, contentVolume, _contentVideo_parentElement, container, adVolume, mediaFile;
|
|
1312
|
+
var winner, ad, contentVolume, adVolume2, mediaFile2, _contentVideo_parentElement, container, adVolume, mediaFile;
|
|
1313
1313
|
return _ts_generator(this, function(_state) {
|
|
1314
1314
|
switch(_state.label){
|
|
1315
1315
|
case 0:
|
|
@@ -1353,37 +1353,71 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1353
1353
|
trackingFired.impression = true;
|
|
1354
1354
|
contentVolume = contentVideo.volume;
|
|
1355
1355
|
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
1356
|
-
if (singleElementMode)
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1356
|
+
if (!singleElementMode) return [
|
|
1357
|
+
3,
|
|
1358
|
+
3
|
|
1359
|
+
];
|
|
1360
|
+
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1361
|
+
teardownCurrentPlayback();
|
|
1362
|
+
adVideoElement = contentVideo;
|
|
1363
|
+
adHls = void 0;
|
|
1364
|
+
adPlaying = true;
|
|
1365
|
+
setAdPlayingFlag(true);
|
|
1366
|
+
contentVideo.removeAttribute("src");
|
|
1367
|
+
contentVideo.load();
|
|
1368
|
+
if (!continueLiveStreamDuringAds) {
|
|
1369
|
+
contentVideo.pause();
|
|
1370
|
+
}
|
|
1371
|
+
contentVideo.muted = true;
|
|
1372
|
+
contentVideo.volume = 0;
|
|
1373
|
+
return [
|
|
1374
|
+
4,
|
|
1375
|
+
new Promise(function(resolve) {
|
|
1376
|
+
return setTimeout(resolve, 200);
|
|
1377
|
+
})
|
|
1378
|
+
];
|
|
1379
|
+
case 2:
|
|
1380
|
+
_state.sent();
|
|
1381
|
+
if (destroyed || tornDown) return [
|
|
1382
|
+
2
|
|
1383
|
+
];
|
|
1384
|
+
contentVideo.style.visibility = "visible";
|
|
1385
|
+
contentVideo.style.opacity = "1";
|
|
1386
|
+
emit("content_pause");
|
|
1387
|
+
setupAdEventListeners();
|
|
1388
|
+
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
1389
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1390
|
+
adVideoElement.muted = false;
|
|
1391
|
+
mediaFile2 = selectBestMediaFile(ad.mediaFiles);
|
|
1392
|
+
if (debug) console.log("".concat(LOG, " Loading ad from: ").concat(mediaFile2.url));
|
|
1393
|
+
startPlayback(mediaFile2);
|
|
1394
|
+
return [
|
|
1395
|
+
2
|
|
1396
|
+
];
|
|
1397
|
+
case 3:
|
|
1398
|
+
if (!adContainerEl) {
|
|
1399
|
+
;
|
|
1400
|
+
container = document.createElement("div");
|
|
1401
|
+
container.style.position = "absolute";
|
|
1402
|
+
container.style.left = "0";
|
|
1403
|
+
container.style.top = "0";
|
|
1404
|
+
container.style.right = "0";
|
|
1405
|
+
container.style.bottom = "0";
|
|
1406
|
+
container.style.display = "none";
|
|
1407
|
+
container.style.alignItems = "center";
|
|
1408
|
+
container.style.justifyContent = "center";
|
|
1409
|
+
container.style.pointerEvents = "none";
|
|
1410
|
+
container.style.zIndex = "10";
|
|
1411
|
+
container.style.backgroundColor = "#000";
|
|
1412
|
+
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1413
|
+
adContainerEl = container;
|
|
1414
|
+
}
|
|
1415
|
+
if (!adVideoElement) {
|
|
1416
|
+
adVideoElement = createAdVideoElement();
|
|
1417
|
+
adContainerEl.appendChild(adVideoElement);
|
|
1361
1418
|
setupAdEventListeners();
|
|
1362
1419
|
} else {
|
|
1363
|
-
|
|
1364
|
-
;
|
|
1365
|
-
container = document.createElement("div");
|
|
1366
|
-
container.style.position = "absolute";
|
|
1367
|
-
container.style.left = "0";
|
|
1368
|
-
container.style.top = "0";
|
|
1369
|
-
container.style.right = "0";
|
|
1370
|
-
container.style.bottom = "0";
|
|
1371
|
-
container.style.display = "none";
|
|
1372
|
-
container.style.alignItems = "center";
|
|
1373
|
-
container.style.justifyContent = "center";
|
|
1374
|
-
container.style.pointerEvents = "none";
|
|
1375
|
-
container.style.zIndex = "10";
|
|
1376
|
-
container.style.backgroundColor = "#000";
|
|
1377
|
-
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1378
|
-
adContainerEl = container;
|
|
1379
|
-
}
|
|
1380
|
-
if (!adVideoElement) {
|
|
1381
|
-
adVideoElement = createAdVideoElement();
|
|
1382
|
-
adContainerEl.appendChild(adVideoElement);
|
|
1383
|
-
setupAdEventListeners();
|
|
1384
|
-
} else {
|
|
1385
|
-
teardownCurrentPlayback();
|
|
1386
|
-
}
|
|
1420
|
+
teardownCurrentPlayback();
|
|
1387
1421
|
}
|
|
1388
1422
|
if (!continueLiveStreamDuringAds) {
|
|
1389
1423
|
contentVideo.pause();
|
|
@@ -1395,7 +1429,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1395
1429
|
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1396
1430
|
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1397
1431
|
adVideoElement.muted = false;
|
|
1398
|
-
if (
|
|
1432
|
+
if (adContainerEl) {
|
|
1399
1433
|
adContainerEl.style.display = "flex";
|
|
1400
1434
|
adContainerEl.style.pointerEvents = "auto";
|
|
1401
1435
|
}
|
|
@@ -1499,6 +1533,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1499
1533
|
if (debug) console.log("".concat(LOG, " [preload] HLS manifest parsed, token=").concat(token));
|
|
1500
1534
|
});
|
|
1501
1535
|
hls.on(import_hls.default.Events.ERROR, function(_evt, data) {
|
|
1536
|
+
if (!preloadSlots.has(token)) return;
|
|
1502
1537
|
if (data.fatal) {
|
|
1503
1538
|
if (debug) console.warn("".concat(LOG, " [preload] HLS error for token=").concat(token));
|
|
1504
1539
|
preloadSlots.delete(token);
|
|
@@ -1535,113 +1570,146 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1535
1570
|
}
|
|
1536
1571
|
function playPreloaded(token) {
|
|
1537
1572
|
return _async_to_generator(function() {
|
|
1538
|
-
var slot, contentVolume, adVolume2, videoEl, container2, adVolume21, adVolume, container;
|
|
1573
|
+
var slot, contentVolume, adVolume2, videoEl, container2, adVolume21, nonFatalNetworkErrors, adVolume, container;
|
|
1539
1574
|
return _ts_generator(this, function(_state) {
|
|
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
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1575
|
+
switch(_state.label){
|
|
1576
|
+
case 0:
|
|
1577
|
+
if (destroyed) return [
|
|
1578
|
+
2,
|
|
1579
|
+
Promise.reject(new Error("Layer has been destroyed"))
|
|
1580
|
+
];
|
|
1581
|
+
slot = preloadSlots.get(token);
|
|
1582
|
+
if (!slot) {
|
|
1583
|
+
if (debug) console.warn("".concat(LOG, " [preload] No slot found for token=").concat(token, ", nothing to play"));
|
|
1584
|
+
return [
|
|
1585
|
+
2
|
|
1586
|
+
];
|
|
1587
|
+
}
|
|
1588
|
+
preloadSlots.delete(token);
|
|
1589
|
+
if (debug) console.log("".concat(LOG, " [preload] Playing preloaded ad, token=").concat(token, ", ready=").concat(slot.ready));
|
|
1590
|
+
contentVolume = contentVideo.volume;
|
|
1591
|
+
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
1592
|
+
sessionId = generateSessionId();
|
|
1593
|
+
currentAd = slot.ad;
|
|
1594
|
+
trackingFired = _object_spread({}, createEmptyTrackingState());
|
|
1595
|
+
fireTrackingPixels2(slot.ad.trackingUrls.impression);
|
|
1596
|
+
trackingFired.impression = true;
|
|
1597
|
+
if (!singleElementMode) return [
|
|
1598
|
+
3,
|
|
1599
|
+
2
|
|
1600
|
+
];
|
|
1601
|
+
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1602
|
+
teardownCurrentPlayback();
|
|
1603
|
+
adVideoElement = contentVideo;
|
|
1604
|
+
adHls = void 0;
|
|
1605
|
+
adPlaying = true;
|
|
1606
|
+
setAdPlayingFlag(true);
|
|
1607
|
+
contentVideo.removeAttribute("src");
|
|
1608
|
+
contentVideo.load();
|
|
1609
|
+
contentVideo.muted = true;
|
|
1610
|
+
contentVideo.volume = 0;
|
|
1611
|
+
return [
|
|
1612
|
+
4,
|
|
1613
|
+
new Promise(function(resolve) {
|
|
1614
|
+
return setTimeout(resolve, 200);
|
|
1615
|
+
})
|
|
1616
|
+
];
|
|
1617
|
+
case 1:
|
|
1618
|
+
_state.sent();
|
|
1619
|
+
if (destroyed || tornDown) return [
|
|
1620
|
+
2
|
|
1621
|
+
];
|
|
1622
|
+
contentVideo.style.visibility = "visible";
|
|
1623
|
+
contentVideo.style.opacity = "1";
|
|
1624
|
+
emit("content_pause");
|
|
1625
|
+
setupAdEventListeners();
|
|
1626
|
+
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
1627
|
+
contentVideo.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1628
|
+
contentVideo.muted = false;
|
|
1629
|
+
if (debug) console.log("".concat(LOG, " [preload] singleElementMode: attaching ad to contentVideo, url=").concat(slot.mediaFile.url));
|
|
1630
|
+
startPlayback(slot.mediaFile);
|
|
1631
|
+
return [
|
|
1632
|
+
2
|
|
1633
|
+
];
|
|
1634
|
+
case 2:
|
|
1635
|
+
if (smartTVMode && !slot.videoEl) {
|
|
1636
|
+
teardownCurrentPlayback();
|
|
1637
|
+
if (adVideoElement) {
|
|
1638
|
+
adVideoElement.remove();
|
|
1639
|
+
adVideoElement = void 0;
|
|
1640
|
+
}
|
|
1641
|
+
videoEl = createAdVideoElement();
|
|
1642
|
+
videoEl.style.visibility = "visible";
|
|
1643
|
+
videoEl.style.pointerEvents = "none";
|
|
1644
|
+
container2 = ensureAdContainer();
|
|
1645
|
+
container2.appendChild(videoEl);
|
|
1646
|
+
adVideoElement = videoEl;
|
|
1647
|
+
setupAdEventListeners();
|
|
1648
|
+
if (!continueLiveStreamDuringAds) {
|
|
1649
|
+
contentVideo.pause();
|
|
1650
|
+
}
|
|
1651
|
+
contentVideo.muted = true;
|
|
1652
|
+
contentVideo.volume = 0;
|
|
1653
|
+
adPlaying = true;
|
|
1654
|
+
setAdPlayingFlag(true);
|
|
1655
|
+
adVolume21 = originalMutedState ? 1 : originalVolume;
|
|
1656
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume21));
|
|
1657
|
+
adVideoElement.muted = false;
|
|
1658
|
+
container2.style.display = "flex";
|
|
1659
|
+
container2.style.pointerEvents = "auto";
|
|
1660
|
+
emit("content_pause");
|
|
1661
|
+
if (debug) console.log("".concat(LOG, " [preload] smartTVMode deferred: creating video element and loading, url=").concat(slot.mediaFile.url));
|
|
1662
|
+
startPlayback(slot.mediaFile);
|
|
1663
|
+
return [
|
|
1664
|
+
2
|
|
1665
|
+
];
|
|
1666
|
+
}
|
|
1667
|
+
teardownCurrentPlayback();
|
|
1668
|
+
if (adVideoElement && adVideoElement !== slot.videoEl) {
|
|
1669
|
+
adVideoElement.remove();
|
|
1670
|
+
}
|
|
1671
|
+
slot.videoEl.style.visibility = "visible";
|
|
1672
|
+
slot.videoEl.style.pointerEvents = "none";
|
|
1673
|
+
adVideoElement = slot.videoEl;
|
|
1674
|
+
adHls = slot.hlsInstance;
|
|
1675
|
+
if (adHls) {
|
|
1676
|
+
nonFatalNetworkErrors = 0;
|
|
1677
|
+
adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
|
|
1678
|
+
if (!adPlaying) return;
|
|
1679
|
+
if (data.fatal) {
|
|
1680
|
+
handleAdError();
|
|
1681
|
+
} else if (data.type === import_hls.default.ErrorTypes.NETWORK_ERROR) {
|
|
1682
|
+
nonFatalNetworkErrors++;
|
|
1683
|
+
if (nonFatalNetworkErrors >= 3) {
|
|
1684
|
+
if (debug) console.warn("".concat(LOG, " [preload] Too many non-fatal HLS network errors during playback, treating as fatal"));
|
|
1685
|
+
handleAdError();
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1690
|
+
setupAdEventListeners();
|
|
1691
|
+
if (!continueLiveStreamDuringAds) {
|
|
1692
|
+
contentVideo.pause();
|
|
1693
|
+
}
|
|
1694
|
+
contentVideo.muted = true;
|
|
1695
|
+
contentVideo.volume = 0;
|
|
1696
|
+
adPlaying = true;
|
|
1697
|
+
setAdPlayingFlag(true);
|
|
1698
|
+
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1699
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1700
|
+
adVideoElement.muted = false;
|
|
1701
|
+
container = ensureAdContainer();
|
|
1702
|
+
container.style.display = "flex";
|
|
1703
|
+
container.style.pointerEvents = "auto";
|
|
1704
|
+
emit("content_pause");
|
|
1705
|
+
adVideoElement.play().catch(function(error) {
|
|
1706
|
+
console.error("".concat(LOG, " [preload] Error playing preloaded ad:"), error);
|
|
1707
|
+
handleAdError();
|
|
1708
|
+
});
|
|
1709
|
+
return [
|
|
1710
|
+
2
|
|
1711
|
+
];
|
|
1626
1712
|
}
|
|
1627
|
-
contentVideo.muted = true;
|
|
1628
|
-
contentVideo.volume = 0;
|
|
1629
|
-
adPlaying = true;
|
|
1630
|
-
setAdPlayingFlag(true);
|
|
1631
|
-
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1632
|
-
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1633
|
-
adVideoElement.muted = false;
|
|
1634
|
-
container = ensureAdContainer();
|
|
1635
|
-
container.style.display = "flex";
|
|
1636
|
-
container.style.pointerEvents = "auto";
|
|
1637
|
-
emit("content_pause");
|
|
1638
|
-
adVideoElement.play().catch(function(error) {
|
|
1639
|
-
console.error("".concat(LOG, " [preload] Error playing preloaded ad:"), error);
|
|
1640
|
-
handleAdError();
|
|
1641
|
-
});
|
|
1642
|
-
return [
|
|
1643
|
-
2
|
|
1644
|
-
];
|
|
1645
1713
|
});
|
|
1646
1714
|
})();
|
|
1647
1715
|
}
|
|
@@ -3897,7 +3965,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3897
3965
|
};
|
|
3898
3966
|
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3899
3967
|
}
|
|
3900
|
-
if (!this.config.disableFiller && !this.video.muted) {
|
|
3968
|
+
if (!this.config.disableFiller && !this.video.muted && !this.adLayer.isAdPlaying()) {
|
|
3901
3969
|
this.video.muted = true;
|
|
3902
3970
|
this.video.volume = 0;
|
|
3903
3971
|
if (this.config.debugAdTiming) {
|
|
@@ -5531,7 +5599,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5531
5599
|
console.log("[StormcloudVideoPlayer] Smart TV: audio state restored on MANIFEST_PARSED after re-attach");
|
|
5532
5600
|
}
|
|
5533
5601
|
hlsRef.startLoad(-1);
|
|
5534
|
-
tryPlay(0);
|
|
5535
5602
|
if (debugEnabled) {
|
|
5536
5603
|
console.log("[StormcloudVideoPlayer] Smart TV: seeking to live edge and resuming playback after re-attach");
|
|
5537
5604
|
}
|