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
|
@@ -1257,7 +1257,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1257
1257
|
}
|
|
1258
1258
|
function playAd(bids) {
|
|
1259
1259
|
return _async_to_generator(function() {
|
|
1260
|
-
var winner, ad, contentVolume, _contentVideo_parentElement, container, adVolume, mediaFile;
|
|
1260
|
+
var winner, ad, contentVolume, adVolume2, mediaFile2, _contentVideo_parentElement, container, adVolume, mediaFile;
|
|
1261
1261
|
return _ts_generator(this, function(_state) {
|
|
1262
1262
|
switch(_state.label){
|
|
1263
1263
|
case 0:
|
|
@@ -1301,37 +1301,71 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1301
1301
|
trackingFired.impression = true;
|
|
1302
1302
|
contentVolume = contentVideo.volume;
|
|
1303
1303
|
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
1304
|
-
if (singleElementMode)
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1304
|
+
if (!singleElementMode) return [
|
|
1305
|
+
3,
|
|
1306
|
+
3
|
|
1307
|
+
];
|
|
1308
|
+
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1309
|
+
teardownCurrentPlayback();
|
|
1310
|
+
adVideoElement = contentVideo;
|
|
1311
|
+
adHls = void 0;
|
|
1312
|
+
adPlaying = true;
|
|
1313
|
+
setAdPlayingFlag(true);
|
|
1314
|
+
contentVideo.removeAttribute("src");
|
|
1315
|
+
contentVideo.load();
|
|
1316
|
+
if (!continueLiveStreamDuringAds) {
|
|
1317
|
+
contentVideo.pause();
|
|
1318
|
+
}
|
|
1319
|
+
contentVideo.muted = true;
|
|
1320
|
+
contentVideo.volume = 0;
|
|
1321
|
+
return [
|
|
1322
|
+
4,
|
|
1323
|
+
new Promise(function(resolve) {
|
|
1324
|
+
return setTimeout(resolve, 200);
|
|
1325
|
+
})
|
|
1326
|
+
];
|
|
1327
|
+
case 2:
|
|
1328
|
+
_state.sent();
|
|
1329
|
+
if (destroyed || tornDown) return [
|
|
1330
|
+
2
|
|
1331
|
+
];
|
|
1332
|
+
contentVideo.style.visibility = "visible";
|
|
1333
|
+
contentVideo.style.opacity = "1";
|
|
1334
|
+
emit("content_pause");
|
|
1335
|
+
setupAdEventListeners();
|
|
1336
|
+
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
1337
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1338
|
+
adVideoElement.muted = false;
|
|
1339
|
+
mediaFile2 = selectBestMediaFile(ad.mediaFiles);
|
|
1340
|
+
if (debug) console.log("".concat(LOG, " Loading ad from: ").concat(mediaFile2.url));
|
|
1341
|
+
startPlayback(mediaFile2);
|
|
1342
|
+
return [
|
|
1343
|
+
2
|
|
1344
|
+
];
|
|
1345
|
+
case 3:
|
|
1346
|
+
if (!adContainerEl) {
|
|
1347
|
+
;
|
|
1348
|
+
container = document.createElement("div");
|
|
1349
|
+
container.style.position = "absolute";
|
|
1350
|
+
container.style.left = "0";
|
|
1351
|
+
container.style.top = "0";
|
|
1352
|
+
container.style.right = "0";
|
|
1353
|
+
container.style.bottom = "0";
|
|
1354
|
+
container.style.display = "none";
|
|
1355
|
+
container.style.alignItems = "center";
|
|
1356
|
+
container.style.justifyContent = "center";
|
|
1357
|
+
container.style.pointerEvents = "none";
|
|
1358
|
+
container.style.zIndex = "10";
|
|
1359
|
+
container.style.backgroundColor = "#000";
|
|
1360
|
+
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1361
|
+
adContainerEl = container;
|
|
1362
|
+
}
|
|
1363
|
+
if (!adVideoElement) {
|
|
1364
|
+
adVideoElement = createAdVideoElement();
|
|
1365
|
+
adContainerEl.appendChild(adVideoElement);
|
|
1309
1366
|
setupAdEventListeners();
|
|
1310
1367
|
} else {
|
|
1311
|
-
|
|
1312
|
-
;
|
|
1313
|
-
container = document.createElement("div");
|
|
1314
|
-
container.style.position = "absolute";
|
|
1315
|
-
container.style.left = "0";
|
|
1316
|
-
container.style.top = "0";
|
|
1317
|
-
container.style.right = "0";
|
|
1318
|
-
container.style.bottom = "0";
|
|
1319
|
-
container.style.display = "none";
|
|
1320
|
-
container.style.alignItems = "center";
|
|
1321
|
-
container.style.justifyContent = "center";
|
|
1322
|
-
container.style.pointerEvents = "none";
|
|
1323
|
-
container.style.zIndex = "10";
|
|
1324
|
-
container.style.backgroundColor = "#000";
|
|
1325
|
-
(_contentVideo_parentElement = contentVideo.parentElement) === null || _contentVideo_parentElement === void 0 ? void 0 : _contentVideo_parentElement.appendChild(container);
|
|
1326
|
-
adContainerEl = container;
|
|
1327
|
-
}
|
|
1328
|
-
if (!adVideoElement) {
|
|
1329
|
-
adVideoElement = createAdVideoElement();
|
|
1330
|
-
adContainerEl.appendChild(adVideoElement);
|
|
1331
|
-
setupAdEventListeners();
|
|
1332
|
-
} else {
|
|
1333
|
-
teardownCurrentPlayback();
|
|
1334
|
-
}
|
|
1368
|
+
teardownCurrentPlayback();
|
|
1335
1369
|
}
|
|
1336
1370
|
if (!continueLiveStreamDuringAds) {
|
|
1337
1371
|
contentVideo.pause();
|
|
@@ -1343,7 +1377,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1343
1377
|
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1344
1378
|
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1345
1379
|
adVideoElement.muted = false;
|
|
1346
|
-
if (
|
|
1380
|
+
if (adContainerEl) {
|
|
1347
1381
|
adContainerEl.style.display = "flex";
|
|
1348
1382
|
adContainerEl.style.pointerEvents = "auto";
|
|
1349
1383
|
}
|
|
@@ -1447,6 +1481,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1447
1481
|
if (debug) console.log("".concat(LOG, " [preload] HLS manifest parsed, token=").concat(token));
|
|
1448
1482
|
});
|
|
1449
1483
|
hls.on(import_hls.default.Events.ERROR, function(_evt, data) {
|
|
1484
|
+
if (!preloadSlots.has(token)) return;
|
|
1450
1485
|
if (data.fatal) {
|
|
1451
1486
|
if (debug) console.warn("".concat(LOG, " [preload] HLS error for token=").concat(token));
|
|
1452
1487
|
preloadSlots.delete(token);
|
|
@@ -1483,113 +1518,146 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1483
1518
|
}
|
|
1484
1519
|
function playPreloaded(token) {
|
|
1485
1520
|
return _async_to_generator(function() {
|
|
1486
|
-
var slot, contentVolume, adVolume2, videoEl, container2, adVolume21, adVolume, container;
|
|
1521
|
+
var slot, contentVolume, adVolume2, videoEl, container2, adVolume21, nonFatalNetworkErrors, adVolume, container;
|
|
1487
1522
|
return _ts_generator(this, function(_state) {
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
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
|
-
|
|
1523
|
+
switch(_state.label){
|
|
1524
|
+
case 0:
|
|
1525
|
+
if (destroyed) return [
|
|
1526
|
+
2,
|
|
1527
|
+
Promise.reject(new Error("Layer has been destroyed"))
|
|
1528
|
+
];
|
|
1529
|
+
slot = preloadSlots.get(token);
|
|
1530
|
+
if (!slot) {
|
|
1531
|
+
if (debug) console.warn("".concat(LOG, " [preload] No slot found for token=").concat(token, ", nothing to play"));
|
|
1532
|
+
return [
|
|
1533
|
+
2
|
|
1534
|
+
];
|
|
1535
|
+
}
|
|
1536
|
+
preloadSlots.delete(token);
|
|
1537
|
+
if (debug) console.log("".concat(LOG, " [preload] Playing preloaded ad, token=").concat(token, ", ready=").concat(slot.ready));
|
|
1538
|
+
contentVolume = contentVideo.volume;
|
|
1539
|
+
originalVolume = Math.max(0, Math.min(1, contentVolume || originalVolume));
|
|
1540
|
+
sessionId = generateSessionId();
|
|
1541
|
+
currentAd = slot.ad;
|
|
1542
|
+
trackingFired = _object_spread({}, createEmptyTrackingState());
|
|
1543
|
+
fireTrackingPixels2(slot.ad.trackingUrls.impression);
|
|
1544
|
+
trackingFired.impression = true;
|
|
1545
|
+
if (!singleElementMode) return [
|
|
1546
|
+
3,
|
|
1547
|
+
2
|
|
1548
|
+
];
|
|
1549
|
+
mainHlsInstance === null || mainHlsInstance === void 0 ? void 0 : mainHlsInstance.detachMedia();
|
|
1550
|
+
teardownCurrentPlayback();
|
|
1551
|
+
adVideoElement = contentVideo;
|
|
1552
|
+
adHls = void 0;
|
|
1553
|
+
adPlaying = true;
|
|
1554
|
+
setAdPlayingFlag(true);
|
|
1555
|
+
contentVideo.removeAttribute("src");
|
|
1556
|
+
contentVideo.load();
|
|
1557
|
+
contentVideo.muted = true;
|
|
1558
|
+
contentVideo.volume = 0;
|
|
1559
|
+
return [
|
|
1560
|
+
4,
|
|
1561
|
+
new Promise(function(resolve) {
|
|
1562
|
+
return setTimeout(resolve, 200);
|
|
1563
|
+
})
|
|
1564
|
+
];
|
|
1565
|
+
case 1:
|
|
1566
|
+
_state.sent();
|
|
1567
|
+
if (destroyed || tornDown) return [
|
|
1568
|
+
2
|
|
1569
|
+
];
|
|
1570
|
+
contentVideo.style.visibility = "visible";
|
|
1571
|
+
contentVideo.style.opacity = "1";
|
|
1572
|
+
emit("content_pause");
|
|
1573
|
+
setupAdEventListeners();
|
|
1574
|
+
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
1575
|
+
contentVideo.volume = Math.max(0, Math.min(1, adVolume2));
|
|
1576
|
+
contentVideo.muted = false;
|
|
1577
|
+
if (debug) console.log("".concat(LOG, " [preload] singleElementMode: attaching ad to contentVideo, url=").concat(slot.mediaFile.url));
|
|
1578
|
+
startPlayback(slot.mediaFile);
|
|
1579
|
+
return [
|
|
1580
|
+
2
|
|
1581
|
+
];
|
|
1582
|
+
case 2:
|
|
1583
|
+
if (smartTVMode && !slot.videoEl) {
|
|
1584
|
+
teardownCurrentPlayback();
|
|
1585
|
+
if (adVideoElement) {
|
|
1586
|
+
adVideoElement.remove();
|
|
1587
|
+
adVideoElement = void 0;
|
|
1588
|
+
}
|
|
1589
|
+
videoEl = createAdVideoElement();
|
|
1590
|
+
videoEl.style.visibility = "visible";
|
|
1591
|
+
videoEl.style.pointerEvents = "none";
|
|
1592
|
+
container2 = ensureAdContainer();
|
|
1593
|
+
container2.appendChild(videoEl);
|
|
1594
|
+
adVideoElement = videoEl;
|
|
1595
|
+
setupAdEventListeners();
|
|
1596
|
+
if (!continueLiveStreamDuringAds) {
|
|
1597
|
+
contentVideo.pause();
|
|
1598
|
+
}
|
|
1599
|
+
contentVideo.muted = true;
|
|
1600
|
+
contentVideo.volume = 0;
|
|
1601
|
+
adPlaying = true;
|
|
1602
|
+
setAdPlayingFlag(true);
|
|
1603
|
+
adVolume21 = originalMutedState ? 1 : originalVolume;
|
|
1604
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume21));
|
|
1605
|
+
adVideoElement.muted = false;
|
|
1606
|
+
container2.style.display = "flex";
|
|
1607
|
+
container2.style.pointerEvents = "auto";
|
|
1608
|
+
emit("content_pause");
|
|
1609
|
+
if (debug) console.log("".concat(LOG, " [preload] smartTVMode deferred: creating video element and loading, url=").concat(slot.mediaFile.url));
|
|
1610
|
+
startPlayback(slot.mediaFile);
|
|
1611
|
+
return [
|
|
1612
|
+
2
|
|
1613
|
+
];
|
|
1614
|
+
}
|
|
1615
|
+
teardownCurrentPlayback();
|
|
1616
|
+
if (adVideoElement && adVideoElement !== slot.videoEl) {
|
|
1617
|
+
adVideoElement.remove();
|
|
1618
|
+
}
|
|
1619
|
+
slot.videoEl.style.visibility = "visible";
|
|
1620
|
+
slot.videoEl.style.pointerEvents = "none";
|
|
1621
|
+
adVideoElement = slot.videoEl;
|
|
1622
|
+
adHls = slot.hlsInstance;
|
|
1623
|
+
if (adHls) {
|
|
1624
|
+
nonFatalNetworkErrors = 0;
|
|
1625
|
+
adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
|
|
1626
|
+
if (!adPlaying) return;
|
|
1627
|
+
if (data.fatal) {
|
|
1628
|
+
handleAdError();
|
|
1629
|
+
} else if (data.type === import_hls.default.ErrorTypes.NETWORK_ERROR) {
|
|
1630
|
+
nonFatalNetworkErrors++;
|
|
1631
|
+
if (nonFatalNetworkErrors >= 3) {
|
|
1632
|
+
if (debug) console.warn("".concat(LOG, " [preload] Too many non-fatal HLS network errors during playback, treating as fatal"));
|
|
1633
|
+
handleAdError();
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
setupAdEventListeners();
|
|
1639
|
+
if (!continueLiveStreamDuringAds) {
|
|
1640
|
+
contentVideo.pause();
|
|
1641
|
+
}
|
|
1642
|
+
contentVideo.muted = true;
|
|
1643
|
+
contentVideo.volume = 0;
|
|
1644
|
+
adPlaying = true;
|
|
1645
|
+
setAdPlayingFlag(true);
|
|
1646
|
+
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1647
|
+
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1648
|
+
adVideoElement.muted = false;
|
|
1649
|
+
container = ensureAdContainer();
|
|
1650
|
+
container.style.display = "flex";
|
|
1651
|
+
container.style.pointerEvents = "auto";
|
|
1652
|
+
emit("content_pause");
|
|
1653
|
+
adVideoElement.play().catch(function(error) {
|
|
1654
|
+
console.error("".concat(LOG, " [preload] Error playing preloaded ad:"), error);
|
|
1655
|
+
handleAdError();
|
|
1656
|
+
});
|
|
1657
|
+
return [
|
|
1658
|
+
2
|
|
1659
|
+
];
|
|
1574
1660
|
}
|
|
1575
|
-
contentVideo.muted = true;
|
|
1576
|
-
contentVideo.volume = 0;
|
|
1577
|
-
adPlaying = true;
|
|
1578
|
-
setAdPlayingFlag(true);
|
|
1579
|
-
adVolume = originalMutedState ? 1 : originalVolume;
|
|
1580
|
-
adVideoElement.volume = Math.max(0, Math.min(1, adVolume));
|
|
1581
|
-
adVideoElement.muted = false;
|
|
1582
|
-
container = ensureAdContainer();
|
|
1583
|
-
container.style.display = "flex";
|
|
1584
|
-
container.style.pointerEvents = "auto";
|
|
1585
|
-
emit("content_pause");
|
|
1586
|
-
adVideoElement.play().catch(function(error) {
|
|
1587
|
-
console.error("".concat(LOG, " [preload] Error playing preloaded ad:"), error);
|
|
1588
|
-
handleAdError();
|
|
1589
|
-
});
|
|
1590
|
-
return [
|
|
1591
|
-
2
|
|
1592
|
-
];
|
|
1593
1661
|
});
|
|
1594
1662
|
})();
|
|
1595
1663
|
}
|
|
@@ -3845,7 +3913,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3845
3913
|
};
|
|
3846
3914
|
this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
|
|
3847
3915
|
}
|
|
3848
|
-
if (!this.config.disableFiller && !this.video.muted) {
|
|
3916
|
+
if (!this.config.disableFiller && !this.video.muted && !this.adLayer.isAdPlaying()) {
|
|
3849
3917
|
this.video.muted = true;
|
|
3850
3918
|
this.video.volume = 0;
|
|
3851
3919
|
if (this.config.debugAdTiming) {
|
|
@@ -5479,7 +5547,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5479
5547
|
console.log("[StormcloudVideoPlayer] Smart TV: audio state restored on MANIFEST_PARSED after re-attach");
|
|
5480
5548
|
}
|
|
5481
5549
|
hlsRef.startLoad(-1);
|
|
5482
|
-
tryPlay(0);
|
|
5483
5550
|
if (debugEnabled) {
|
|
5484
5551
|
console.log("[StormcloudVideoPlayer] Smart TV: seeking to live edge and resuming playback after re-attach");
|
|
5485
5552
|
}
|