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.js
CHANGED
|
@@ -1279,7 +1279,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1279
1279
|
}
|
|
1280
1280
|
function playAd(bids) {
|
|
1281
1281
|
return _async_to_generator(function() {
|
|
1282
|
-
var winner, ad, contentVolume, _contentVideo_parentElement, container, adVolume, mediaFile;
|
|
1282
|
+
var winner, ad, contentVolume, adVolume2, mediaFile2, _contentVideo_parentElement, container, adVolume, mediaFile;
|
|
1283
1283
|
return _ts_generator(this, function(_state) {
|
|
1284
1284
|
switch(_state.label){
|
|
1285
1285
|
case 0:
|
|
@@ -1323,37 +1323,71 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1323
1323
|
trackingFired.impression = true;
|
|
1324
1324
|
contentVolume = contentVideo.volume;
|
|
1325
1325
|
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
1326
|
-
if (singleElementMode)
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1326
|
+
if (!singleElementMode) return [
|
|
1327
|
+
3,
|
|
1328
|
+
3
|
|
1329
|
+
];
|
|
1330
|
+
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1331
|
+
teardownCurrentPlayback();
|
|
1332
|
+
adVideoElement = contentVideo;
|
|
1333
|
+
adHls = void 0;
|
|
1334
|
+
adPlaying = true;
|
|
1335
|
+
setAdPlayingFlag(true);
|
|
1336
|
+
contentVideo.removeAttribute("src");
|
|
1337
|
+
contentVideo.load();
|
|
1338
|
+
if (!continueLiveStreamDuringAds) {
|
|
1339
|
+
contentVideo.pause();
|
|
1340
|
+
}
|
|
1341
|
+
contentVideo.muted = true;
|
|
1342
|
+
contentVideo.volume = 0;
|
|
1343
|
+
return [
|
|
1344
|
+
4,
|
|
1345
|
+
new Promise(function(resolve) {
|
|
1346
|
+
return setTimeout(resolve, 200);
|
|
1347
|
+
})
|
|
1348
|
+
];
|
|
1349
|
+
case 2:
|
|
1350
|
+
_state.sent();
|
|
1351
|
+
if (destroyed || tornDown) return [
|
|
1352
|
+
2
|
|
1353
|
+
];
|
|
1354
|
+
contentVideo.style.visibility = "visible";
|
|
1355
|
+
contentVideo.style.opacity = "1";
|
|
1356
|
+
emit("content_pause");
|
|
1357
|
+
setupAdEventListeners();
|
|
1358
|
+
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
1359
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1360
|
+
adVideoElement.muted = false;
|
|
1361
|
+
mediaFile2 = selectBestMediaFile(ad.mediaFiles);
|
|
1362
|
+
if (debug) console.log("".concat(LOG, " Loading ad from: ").concat(mediaFile2.url));
|
|
1363
|
+
startPlayback(mediaFile2);
|
|
1364
|
+
return [
|
|
1365
|
+
2
|
|
1366
|
+
];
|
|
1367
|
+
case 3:
|
|
1368
|
+
if (!adContainerEl) {
|
|
1369
|
+
;
|
|
1370
|
+
container = document.createElement("div");
|
|
1371
|
+
container.style.position = "absolute";
|
|
1372
|
+
container.style.left = "0";
|
|
1373
|
+
container.style.top = "0";
|
|
1374
|
+
container.style.right = "0";
|
|
1375
|
+
container.style.bottom = "0";
|
|
1376
|
+
container.style.display = "none";
|
|
1377
|
+
container.style.alignItems = "center";
|
|
1378
|
+
container.style.justifyContent = "center";
|
|
1379
|
+
container.style.pointerEvents = "none";
|
|
1380
|
+
container.style.zIndex = "10";
|
|
1381
|
+
container.style.backgroundColor = "#000";
|
|
1382
|
+
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1383
|
+
adContainerEl = container;
|
|
1384
|
+
}
|
|
1385
|
+
if (!adVideoElement) {
|
|
1386
|
+
adVideoElement = createAdVideoElement();
|
|
1387
|
+
adContainerEl.appendChild(adVideoElement);
|
|
1331
1388
|
setupAdEventListeners();
|
|
1332
1389
|
} else {
|
|
1333
|
-
|
|
1334
|
-
;
|
|
1335
|
-
container = document.createElement("div");
|
|
1336
|
-
container.style.position = "absolute";
|
|
1337
|
-
container.style.left = "0";
|
|
1338
|
-
container.style.top = "0";
|
|
1339
|
-
container.style.right = "0";
|
|
1340
|
-
container.style.bottom = "0";
|
|
1341
|
-
container.style.display = "none";
|
|
1342
|
-
container.style.alignItems = "center";
|
|
1343
|
-
container.style.justifyContent = "center";
|
|
1344
|
-
container.style.pointerEvents = "none";
|
|
1345
|
-
container.style.zIndex = "10";
|
|
1346
|
-
container.style.backgroundColor = "#000";
|
|
1347
|
-
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1348
|
-
adContainerEl = container;
|
|
1349
|
-
}
|
|
1350
|
-
if (!adVideoElement) {
|
|
1351
|
-
adVideoElement = createAdVideoElement();
|
|
1352
|
-
adContainerEl.appendChild(adVideoElement);
|
|
1353
|
-
setupAdEventListeners();
|
|
1354
|
-
} else {
|
|
1355
|
-
teardownCurrentPlayback();
|
|
1356
|
-
}
|
|
1390
|
+
teardownCurrentPlayback();
|
|
1357
1391
|
}
|
|
1358
1392
|
if (!continueLiveStreamDuringAds) {
|
|
1359
1393
|
contentVideo.pause();
|
|
@@ -1365,7 +1399,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1365
1399
|
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1366
1400
|
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1367
1401
|
adVideoElement.muted = false;
|
|
1368
|
-
if (
|
|
1402
|
+
if (adContainerEl) {
|
|
1369
1403
|
adContainerEl.style.display = "flex";
|
|
1370
1404
|
adContainerEl.style.pointerEvents = "auto";
|
|
1371
1405
|
}
|
|
@@ -1469,6 +1503,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1469
1503
|
if (debug) console.log("".concat(LOG, " [preload] HLS manifest parsed, token=").concat(token));
|
|
1470
1504
|
});
|
|
1471
1505
|
hls.on(Hls.Events.ERROR, function(_evt, data) {
|
|
1506
|
+
if (!preloadSlots.has(token)) return;
|
|
1472
1507
|
if (data.fatal) {
|
|
1473
1508
|
if (debug) console.warn("".concat(LOG, " [preload] HLS error for token=").concat(token));
|
|
1474
1509
|
preloadSlots.delete(token);
|
|
@@ -1505,113 +1540,146 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1505
1540
|
}
|
|
1506
1541
|
function playPreloaded(token) {
|
|
1507
1542
|
return _async_to_generator(function() {
|
|
1508
|
-
var slot, contentVolume, adVolume2, videoEl, container2, adVolume21, adVolume, container;
|
|
1543
|
+
var slot, contentVolume, adVolume2, videoEl, container2, adVolume21, nonFatalNetworkErrors, adVolume, container;
|
|
1509
1544
|
return _ts_generator(this, function(_state) {
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
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
|
-
|
|
1545
|
+
switch(_state.label){
|
|
1546
|
+
case 0:
|
|
1547
|
+
if (destroyed) return [
|
|
1548
|
+
2,
|
|
1549
|
+
Promise.reject(new Error("Layer has been destroyed"))
|
|
1550
|
+
];
|
|
1551
|
+
slot = preloadSlots.get(token);
|
|
1552
|
+
if (!slot) {
|
|
1553
|
+
if (debug) console.warn("".concat(LOG, " [preload] No slot found for token=").concat(token, ", nothing to play"));
|
|
1554
|
+
return [
|
|
1555
|
+
2
|
|
1556
|
+
];
|
|
1557
|
+
}
|
|
1558
|
+
preloadSlots.delete(token);
|
|
1559
|
+
if (debug) console.log("".concat(LOG, " [preload] Playing preloaded ad, token=").concat(token, ", ready=").concat(slot.ready));
|
|
1560
|
+
contentVolume = contentVideo.volume;
|
|
1561
|
+
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
1562
|
+
sessionId = generateSessionId();
|
|
1563
|
+
currentAd = slot.ad;
|
|
1564
|
+
trackingFired = _object_spread({}, createEmptyTrackingState());
|
|
1565
|
+
fireTrackingPixels2(slot.ad.trackingUrls.impression);
|
|
1566
|
+
trackingFired.impression = true;
|
|
1567
|
+
if (!singleElementMode) return [
|
|
1568
|
+
3,
|
|
1569
|
+
2
|
|
1570
|
+
];
|
|
1571
|
+
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1572
|
+
teardownCurrentPlayback();
|
|
1573
|
+
adVideoElement = contentVideo;
|
|
1574
|
+
adHls = void 0;
|
|
1575
|
+
adPlaying = true;
|
|
1576
|
+
setAdPlayingFlag(true);
|
|
1577
|
+
contentVideo.removeAttribute("src");
|
|
1578
|
+
contentVideo.load();
|
|
1579
|
+
contentVideo.muted = true;
|
|
1580
|
+
contentVideo.volume = 0;
|
|
1581
|
+
return [
|
|
1582
|
+
4,
|
|
1583
|
+
new Promise(function(resolve) {
|
|
1584
|
+
return setTimeout(resolve, 200);
|
|
1585
|
+
})
|
|
1586
|
+
];
|
|
1587
|
+
case 1:
|
|
1588
|
+
_state.sent();
|
|
1589
|
+
if (destroyed || tornDown) return [
|
|
1590
|
+
2
|
|
1591
|
+
];
|
|
1592
|
+
contentVideo.style.visibility = "visible";
|
|
1593
|
+
contentVideo.style.opacity = "1";
|
|
1594
|
+
emit("content_pause");
|
|
1595
|
+
setupAdEventListeners();
|
|
1596
|
+
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
1597
|
+
contentVideo.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1598
|
+
contentVideo.muted = false;
|
|
1599
|
+
if (debug) console.log("".concat(LOG, " [preload] singleElementMode: attaching ad to contentVideo, url=").concat(slot.mediaFile.url));
|
|
1600
|
+
startPlayback(slot.mediaFile);
|
|
1601
|
+
return [
|
|
1602
|
+
2
|
|
1603
|
+
];
|
|
1604
|
+
case 2:
|
|
1605
|
+
if (smartTVMode && !slot.videoEl) {
|
|
1606
|
+
teardownCurrentPlayback();
|
|
1607
|
+
if (adVideoElement) {
|
|
1608
|
+
adVideoElement.remove();
|
|
1609
|
+
adVideoElement = void 0;
|
|
1610
|
+
}
|
|
1611
|
+
videoEl = createAdVideoElement();
|
|
1612
|
+
videoEl.style.visibility = "visible";
|
|
1613
|
+
videoEl.style.pointerEvents = "none";
|
|
1614
|
+
container2 = ensureAdContainer();
|
|
1615
|
+
container2.appendChild(videoEl);
|
|
1616
|
+
adVideoElement = videoEl;
|
|
1617
|
+
setupAdEventListeners();
|
|
1618
|
+
if (!continueLiveStreamDuringAds) {
|
|
1619
|
+
contentVideo.pause();
|
|
1620
|
+
}
|
|
1621
|
+
contentVideo.muted = true;
|
|
1622
|
+
contentVideo.volume = 0;
|
|
1623
|
+
adPlaying = true;
|
|
1624
|
+
setAdPlayingFlag(true);
|
|
1625
|
+
adVolume21 = originalMutedState ? 1 : originalVolume;
|
|
1626
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume21));
|
|
1627
|
+
adVideoElement.muted = false;
|
|
1628
|
+
container2.style.display = "flex";
|
|
1629
|
+
container2.style.pointerEvents = "auto";
|
|
1630
|
+
emit("content_pause");
|
|
1631
|
+
if (debug) console.log("".concat(LOG, " [preload] smartTVMode deferred: creating video element and loading, url=").concat(slot.mediaFile.url));
|
|
1632
|
+
startPlayback(slot.mediaFile);
|
|
1633
|
+
return [
|
|
1634
|
+
2
|
|
1635
|
+
];
|
|
1636
|
+
}
|
|
1637
|
+
teardownCurrentPlayback();
|
|
1638
|
+
if (adVideoElement && adVideoElement !== slot.videoEl) {
|
|
1639
|
+
adVideoElement.remove();
|
|
1640
|
+
}
|
|
1641
|
+
slot.videoEl.style.visibility = "visible";
|
|
1642
|
+
slot.videoEl.style.pointerEvents = "none";
|
|
1643
|
+
adVideoElement = slot.videoEl;
|
|
1644
|
+
adHls = slot.hlsInstance;
|
|
1645
|
+
if (adHls) {
|
|
1646
|
+
nonFatalNetworkErrors = 0;
|
|
1647
|
+
adHls.on(Hls.Events.ERROR, function(_event, data) {
|
|
1648
|
+
if (!adPlaying) return;
|
|
1649
|
+
if (data.fatal) {
|
|
1650
|
+
handleAdError();
|
|
1651
|
+
} else if (data.type === Hls.ErrorTypes.NETWORK_ERROR) {
|
|
1652
|
+
nonFatalNetworkErrors++;
|
|
1653
|
+
if (nonFatalNetworkErrors >= 3) {
|
|
1654
|
+
if (debug) console.warn("".concat(LOG, " [preload] Too many non-fatal HLS network errors during playback, treating as fatal"));
|
|
1655
|
+
handleAdError();
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
setupAdEventListeners();
|
|
1661
|
+
if (!continueLiveStreamDuringAds) {
|
|
1662
|
+
contentVideo.pause();
|
|
1663
|
+
}
|
|
1664
|
+
contentVideo.muted = true;
|
|
1665
|
+
contentVideo.volume = 0;
|
|
1666
|
+
adPlaying = true;
|
|
1667
|
+
setAdPlayingFlag(true);
|
|
1668
|
+
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1669
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1670
|
+
adVideoElement.muted = false;
|
|
1671
|
+
container = ensureAdContainer();
|
|
1672
|
+
container.style.display = "flex";
|
|
1673
|
+
container.style.pointerEvents = "auto";
|
|
1674
|
+
emit("content_pause");
|
|
1675
|
+
adVideoElement.play().catch(function(error) {
|
|
1676
|
+
console.error("".concat(LOG, " [preload] Error playing preloaded ad:"), error);
|
|
1677
|
+
handleAdError();
|
|
1678
|
+
});
|
|
1679
|
+
return [
|
|
1680
|
+
2
|
|
1681
|
+
];
|
|
1588
1682
|
}
|
|
1589
|
-
slot.videoEl.style.visibility = "visible";
|
|
1590
|
-
slot.videoEl.style.pointerEvents = "none";
|
|
1591
|
-
adVideoElement = slot.videoEl;
|
|
1592
|
-
adHls = slot.hlsInstance;
|
|
1593
|
-
setupAdEventListeners();
|
|
1594
|
-
if (!continueLiveStreamDuringAds) {
|
|
1595
|
-
contentVideo.pause();
|
|
1596
|
-
}
|
|
1597
|
-
contentVideo.muted = true;
|
|
1598
|
-
contentVideo.volume = 0;
|
|
1599
|
-
adPlaying = true;
|
|
1600
|
-
setAdPlayingFlag(true);
|
|
1601
|
-
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1602
|
-
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1603
|
-
adVideoElement.muted = false;
|
|
1604
|
-
container = ensureAdContainer();
|
|
1605
|
-
container.style.display = "flex";
|
|
1606
|
-
container.style.pointerEvents = "auto";
|
|
1607
|
-
emit("content_pause");
|
|
1608
|
-
adVideoElement.play().catch(function(error) {
|
|
1609
|
-
console.error("".concat(LOG, " [preload] Error playing preloaded ad:"), error);
|
|
1610
|
-
handleAdError();
|
|
1611
|
-
});
|
|
1612
|
-
return [
|
|
1613
|
-
2
|
|
1614
|
-
];
|
|
1615
1683
|
});
|
|
1616
1684
|
})();
|
|
1617
1685
|
}
|
|
@@ -3895,7 +3963,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3895
3963
|
};
|
|
3896
3964
|
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3897
3965
|
}
|
|
3898
|
-
if (!this.config.disableFiller && !this.video.muted) {
|
|
3966
|
+
if (!this.config.disableFiller && !this.video.muted && !this.adLayer.isAdPlaying()) {
|
|
3899
3967
|
this.video.muted = true;
|
|
3900
3968
|
this.video.volume = 0;
|
|
3901
3969
|
if (this.config.debugAdTiming) {
|
|
@@ -5529,7 +5597,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5529
5597
|
console.log("[StormcloudVideoPlayer] Smart TV: audio state restored on MANIFEST_PARSED after re-attach");
|
|
5530
5598
|
}
|
|
5531
5599
|
hlsRef.startLoad(-1);
|
|
5532
|
-
tryPlay(0);
|
|
5533
5600
|
if (debugEnabled) {
|
|
5534
5601
|
console.log("[StormcloudVideoPlayer] Smart TV: seeking to live edge and resuming playback after re-attach");
|
|
5535
5602
|
}
|