stormcloud-video-player 0.8.49 → 0.8.51

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/lib/index.cjs CHANGED
@@ -590,6 +590,202 @@ module.exports = __toCommonJS(index_exports);
590
590
  var import_react = __toESM(require("react"), 1);
591
591
  // src/sdk/hlsAdPlayer.ts
592
592
  var import_hls = __toESM(require("hls.js"), 1);
593
+ // src/utils/browserCompat.ts
594
+ function getChromeVersion(ua) {
595
+ var match = ua.match(/Chrome\/(\d+)/);
596
+ return match && match[1] ? parseInt(match[1], 10) : 0;
597
+ }
598
+ function getWebKitVersion(ua) {
599
+ var match = ua.match(/AppleWebKit\/(\d+)/);
600
+ return match && match[1] ? parseInt(match[1], 10) : 0;
601
+ }
602
+ function getPlatform() {
603
+ var _navigator_userAgentData;
604
+ if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
605
+ return navigator.userAgentData.platform;
606
+ }
607
+ var ua = navigator.userAgent;
608
+ if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
609
+ return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
610
+ }
611
+ if (/Win/i.test(ua)) {
612
+ return "Win32";
613
+ }
614
+ if (/Linux/i.test(ua)) {
615
+ return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
616
+ }
617
+ if (/CrOS/i.test(ua)) {
618
+ return "CrOS";
619
+ }
620
+ return navigator.platform || "Unknown";
621
+ }
622
+ function detectBrowser() {
623
+ var ua = navigator.userAgent;
624
+ var platform = getPlatform();
625
+ var name = "Unknown";
626
+ var version = "0";
627
+ var majorVersion = 0;
628
+ var isSmartTV = false;
629
+ var isLegacyTV = false;
630
+ var supportsModernJS2 = true;
631
+ var webOSVersion;
632
+ var tizenVersion;
633
+ var chromeVersionNum;
634
+ var chromeVersion = getChromeVersion(ua);
635
+ var webkitVersion = getWebKitVersion(ua);
636
+ chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
637
+ if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
638
+ name = "LG WebOS";
639
+ isSmartTV = true;
640
+ var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
641
+ if (!match || !match[1]) {
642
+ match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
643
+ }
644
+ if (match && match[1]) {
645
+ version = match[1];
646
+ var parts = version.split(".");
647
+ majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
648
+ webOSVersion = majorVersion;
649
+ } else if (chromeVersion > 0) {
650
+ if (chromeVersion >= 79) {
651
+ webOSVersion = 6;
652
+ version = "6.0";
653
+ majorVersion = 6;
654
+ } else if (chromeVersion >= 68) {
655
+ webOSVersion = 5;
656
+ version = "5.0";
657
+ majorVersion = 5;
658
+ } else if (chromeVersion >= 53) {
659
+ webOSVersion = 4;
660
+ version = "4.0";
661
+ majorVersion = 4;
662
+ } else if (chromeVersion >= 38) {
663
+ webOSVersion = 3;
664
+ version = "3.0";
665
+ majorVersion = 3;
666
+ } else {
667
+ webOSVersion = 2;
668
+ version = "2.0";
669
+ majorVersion = 2;
670
+ }
671
+ } else {
672
+ version = "Unknown";
673
+ webOSVersion = void 0;
674
+ }
675
+ isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
676
+ } else if (/Tizen/i.test(ua)) {
677
+ name = "Samsung Tizen";
678
+ isSmartTV = true;
679
+ var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
680
+ version = match1 && match1[1] ? match1[1] : "Unknown";
681
+ if (version !== "Unknown") {
682
+ var parts1 = version.split(".");
683
+ majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
684
+ tizenVersion = majorVersion;
685
+ }
686
+ isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
687
+ } else if (/SMART-TV|SmartTV/i.test(ua)) {
688
+ name = "Smart TV";
689
+ isSmartTV = true;
690
+ isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
691
+ } else if (/NetCast/i.test(ua)) {
692
+ name = "LG NetCast";
693
+ isSmartTV = true;
694
+ isLegacyTV = true;
695
+ } else if (/BRAVIA/i.test(ua)) {
696
+ name = "Sony BRAVIA";
697
+ isSmartTV = true;
698
+ isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
699
+ } else {
700
+ if (chromeVersion > 0) {
701
+ name = "Chrome";
702
+ version = chromeVersion.toString();
703
+ majorVersion = chromeVersion;
704
+ if (chromeVersion < 50) {
705
+ supportsModernJS2 = false;
706
+ }
707
+ }
708
+ if (webkitVersion > 0 && webkitVersion < 600) {
709
+ supportsModernJS2 = false;
710
+ }
711
+ }
712
+ if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
713
+ supportsModernJS2 = false;
714
+ }
715
+ if (typeof URLSearchParams === "undefined") {
716
+ supportsModernJS2 = false;
717
+ }
718
+ return {
719
+ name: name,
720
+ version: version,
721
+ majorVersion: majorVersion,
722
+ isSmartTV: isSmartTV,
723
+ isLegacyTV: isLegacyTV,
724
+ platform: platform,
725
+ supportsModernJS: supportsModernJS2,
726
+ webOSVersion: webOSVersion,
727
+ tizenVersion: tizenVersion,
728
+ chromeVersion: chromeVersionNum
729
+ };
730
+ }
731
+ function requiresMediaPipelineResetAfterAds() {
732
+ var _browser_tizenVersion;
733
+ var browser = detectBrowser();
734
+ return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
735
+ }
736
+ function getBrowserConfigOverrides() {
737
+ var browser = detectBrowser();
738
+ var overrides = {};
739
+ if (browser.isSmartTV) {
740
+ overrides.allowNativeHls = true;
741
+ overrides.pauseContentDuringAds = true;
742
+ }
743
+ return overrides;
744
+ }
745
+ function supportsModernJS() {
746
+ try {
747
+ return typeof Promise !== "undefined" && typeof Map !== "undefined" && typeof Set !== "undefined" && typeof Array.from !== "undefined" && typeof Object.assign !== "undefined" && typeof Array.prototype.forEach !== "undefined" && typeof String.prototype.includes !== "undefined";
748
+ } catch (e) {
749
+ return false;
750
+ }
751
+ }
752
+ function logBrowserInfo() {
753
+ var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
754
+ if (!debug) return;
755
+ var browser = detectBrowser();
756
+ console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
757
+ browser: "".concat(browser.name, " ").concat(browser.version),
758
+ platform: browser.platform,
759
+ isSmartTV: browser.isSmartTV,
760
+ isLegacyTV: browser.isLegacyTV,
761
+ supportsModernJS: browser.supportsModernJS
762
+ }, browser.webOSVersion !== void 0 ? {
763
+ webOSVersion: browser.webOSVersion
764
+ } : {}, browser.tizenVersion !== void 0 ? {
765
+ tizenVersion: browser.tizenVersion
766
+ } : {}, browser.chromeVersion !== void 0 ? {
767
+ chromeVersion: browser.chromeVersion
768
+ } : {}), {
769
+ userAgent: navigator.userAgent
770
+ }));
771
+ }
772
+ function supportsFeature(feature) {
773
+ switch(feature){
774
+ case "urlsearchparams":
775
+ return typeof URLSearchParams !== "undefined";
776
+ case "textencoder":
777
+ return typeof TextEncoder !== "undefined";
778
+ case "promises":
779
+ return typeof Promise !== "undefined";
780
+ case "fetch":
781
+ return typeof fetch !== "undefined";
782
+ case "crypto":
783
+ return typeof crypto !== "undefined" && typeof crypto.subtle !== "undefined";
784
+ default:
785
+ return false;
786
+ }
787
+ }
788
+ // src/sdk/hlsAdPlayer.ts
593
789
  var MAX_VAST_WRAPPER_DEPTH = 5;
594
790
  function createHlsAdPlayer(contentVideo, options) {
595
791
  var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
@@ -601,6 +797,7 @@ function createHlsAdPlayer(contentVideo, options) {
601
797
  var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
602
798
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
603
799
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
800
+ var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
604
801
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
605
802
  var adHls;
606
803
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -620,6 +817,8 @@ function createHlsAdPlayer(contentVideo, options) {
620
817
  var lastAdProgressTime = 0;
621
818
  var lastAdProgressPosition = 0;
622
819
  var sawDecodedVideoFrame = false;
820
+ var videoFrameCallbackHandle;
821
+ var pendingPlayPromise;
623
822
  var trackingFired = {
624
823
  impression: false,
625
824
  start: false,
@@ -1423,6 +1622,60 @@ function createHlsAdPlayer(contentVideo, options) {
1423
1622
  complete: false
1424
1623
  };
1425
1624
  }
1625
+ function isRvfcSupported(video) {
1626
+ return typeof video.requestVideoFrameCallback === "function";
1627
+ }
1628
+ function settlePendingPlay() {
1629
+ pendingPlayPromise = void 0;
1630
+ }
1631
+ function startAdPlayback(context) {
1632
+ if (!adVideoElement) return;
1633
+ var playPromise = adVideoElement.play();
1634
+ pendingPlayPromise = playPromise;
1635
+ playPromise.catch(function(error) {
1636
+ if (pendingPlayPromise !== playPromise) {
1637
+ return;
1638
+ }
1639
+ console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
1640
+ handleAdError();
1641
+ }).finally(function() {
1642
+ if (pendingPlayPromise === playPromise) {
1643
+ pendingPlayPromise = void 0;
1644
+ }
1645
+ });
1646
+ }
1647
+ function prepareVideoElementForNewSource() {
1648
+ settlePendingPlay();
1649
+ if (adHls) {
1650
+ adHls.destroy();
1651
+ adHls = void 0;
1652
+ }
1653
+ if (!adVideoElement) return;
1654
+ try {
1655
+ adVideoElement.pause();
1656
+ adVideoElement.removeAttribute("src");
1657
+ adVideoElement.load();
1658
+ } catch (error) {
1659
+ console.warn("[HlsAdPlayer] Error preparing ad video for new source:", error);
1660
+ }
1661
+ }
1662
+ function recreateAdVideoElement() {
1663
+ console.log("[HlsAdPlayer] Recreating ad video element (single-decoder platform)");
1664
+ teardownAdEventListeners();
1665
+ prepareVideoElementForNewSource();
1666
+ if (adVideoElement) {
1667
+ try {
1668
+ adVideoElement.remove();
1669
+ } catch (error) {
1670
+ console.warn("[HlsAdPlayer] Error removing ad video element:", error);
1671
+ }
1672
+ }
1673
+ adVideoElement = createAdVideoElement();
1674
+ adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.appendChild(adVideoElement);
1675
+ contentVideo[AD_VIDEO_PROP] = adVideoElement;
1676
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
1677
+ adVideoElement.muted = originalMutedState;
1678
+ }
1426
1679
  function loadCurrentAdMedia() {
1427
1680
  if (!adVideoElement || !currentAd) {
1428
1681
  throw new Error("No ad video element or ad to load");
@@ -1445,10 +1698,7 @@ function createHlsAdPlayer(contentVideo, options) {
1445
1698
  adHls.attachMedia(adVideoElement);
1446
1699
  adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
1447
1700
  console.log("[HlsAdPlayer] HLS manifest parsed, starting playback");
1448
- adVideoElement.play().catch(function(error) {
1449
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1450
- handleAdError();
1451
- });
1701
+ startAdPlayback("HLS ad playback");
1452
1702
  });
1453
1703
  adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
1454
1704
  console.error("[HlsAdPlayer] HLS error:", data);
@@ -1458,10 +1708,7 @@ function createHlsAdPlayer(contentVideo, options) {
1458
1708
  });
1459
1709
  } else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
1460
1710
  adVideoElement.src = mediaFile.url;
1461
- adVideoElement.play().catch(function(error) {
1462
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1463
- handleAdError();
1464
- });
1711
+ startAdPlayback("native HLS ad playback");
1465
1712
  } else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
1466
1713
  if (adHls) {
1467
1714
  adHls.destroy();
@@ -1469,10 +1716,7 @@ function createHlsAdPlayer(contentVideo, options) {
1469
1716
  }
1470
1717
  adVideoElement.src = mediaFile.url;
1471
1718
  adVideoElement.load();
1472
- adVideoElement.play().catch(function(error) {
1473
- console.error("[HlsAdPlayer] Error starting progressive ad playback:", error);
1474
- handleAdError();
1475
- });
1719
+ startAdPlayback("progressive ad playback");
1476
1720
  } else {
1477
1721
  throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
1478
1722
  }
@@ -1489,6 +1733,13 @@ function createHlsAdPlayer(contentVideo, options) {
1489
1733
  trackingFired.impression = true;
1490
1734
  console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
1491
1735
  }
1736
+ clearStallWatchdog();
1737
+ if (requiresMediaPipelineResetAfterAds()) {
1738
+ recreateAdVideoElement();
1739
+ setupAdEventListeners();
1740
+ } else {
1741
+ prepareVideoElementForNewSource();
1742
+ }
1492
1743
  try {
1493
1744
  loadCurrentAdMedia();
1494
1745
  emit("pod_ad_started", {
@@ -1506,6 +1757,7 @@ function createHlsAdPlayer(contentVideo, options) {
1506
1757
  clearInterval(stallWatchdogId);
1507
1758
  stallWatchdogId = void 0;
1508
1759
  }
1760
+ cancelVideoFrameProbe();
1509
1761
  }
1510
1762
  function noteAdProgress() {
1511
1763
  lastAdProgressTime = Date.now();
@@ -1541,6 +1793,39 @@ function createHlsAdPlayer(contentVideo, options) {
1541
1793
  }
1542
1794
  return void 0;
1543
1795
  }
1796
+ function isFrameCounterReliable() {
1797
+ return contentVideo[FRAME_COUNTER_RELIABLE_PROP] === true;
1798
+ }
1799
+ function markFrameCounterReliable() {
1800
+ contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1801
+ }
1802
+ function cancelVideoFrameProbe() {
1803
+ if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1804
+ try {
1805
+ adVideoElement.cancelVideoFrameCallback(videoFrameCallbackHandle);
1806
+ } catch (error) {
1807
+ console.warn("[HlsAdPlayer] Error cancelling video frame callback:", error);
1808
+ }
1809
+ }
1810
+ videoFrameCallbackHandle = void 0;
1811
+ }
1812
+ function startVideoFrameProbe() {
1813
+ cancelVideoFrameProbe();
1814
+ if (!adVideoElement) return;
1815
+ var rvfc = adVideoElement.requestVideoFrameCallback;
1816
+ if (typeof rvfc !== "function") return;
1817
+ var onPresentedFrame = function onPresentedFrame() {
1818
+ videoFrameCallbackHandle = void 0;
1819
+ if (!adPlaying) return;
1820
+ sawDecodedVideoFrame = true;
1821
+ };
1822
+ try {
1823
+ videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
1824
+ } catch (error) {
1825
+ console.warn("[HlsAdPlayer] Error requesting video frame callback:", error);
1826
+ videoFrameCallbackHandle = void 0;
1827
+ }
1828
+ }
1544
1829
  function handleVideoDecodeFailure() {
1545
1830
  console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
1546
1831
  clearStallWatchdog();
@@ -1556,6 +1841,7 @@ function createHlsAdPlayer(contentVideo, options) {
1556
1841
  clearStallWatchdog();
1557
1842
  noteAdProgress();
1558
1843
  sawDecodedVideoFrame = false;
1844
+ startVideoFrameProbe();
1559
1845
  stallWatchdogId = window.setInterval(function() {
1560
1846
  if (!adPlaying || !adVideoElement) {
1561
1847
  return;
@@ -1564,9 +1850,17 @@ function createHlsAdPlayer(contentVideo, options) {
1564
1850
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1565
1851
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1566
1852
  sawDecodedVideoFrame = true;
1567
- } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1568
- handleVideoDecodeFailure();
1569
- return;
1853
+ markFrameCounterReliable();
1854
+ } else if (adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1855
+ var timeAdvancing = adVideoElement.currentTime > lastAdProgressPosition + 0.05;
1856
+ if (isRvfcSupported(adVideoElement) && timeAdvancing) {
1857
+ handleVideoDecodeFailure();
1858
+ return;
1859
+ }
1860
+ if (decodedFrames === 0 && timeAdvancing && isFrameCounterReliable()) {
1861
+ handleVideoDecodeFailure();
1862
+ return;
1863
+ }
1570
1864
  }
1571
1865
  }
1572
1866
  if (adVideoElement.currentTime > lastAdProgressPosition + 0.05) {
@@ -1583,19 +1877,7 @@ function createHlsAdPlayer(contentVideo, options) {
1583
1877
  }, STALL_CHECK_INTERVAL_MS);
1584
1878
  }
1585
1879
  function releaseAdDecoder() {
1586
- if (adHls) {
1587
- adHls.destroy();
1588
- adHls = void 0;
1589
- }
1590
- if (adVideoElement) {
1591
- try {
1592
- adVideoElement.pause();
1593
- adVideoElement.removeAttribute("src");
1594
- adVideoElement.load();
1595
- } catch (error) {
1596
- console.warn("[HlsAdPlayer] Error releasing ad decoder:", error);
1597
- }
1598
- }
1880
+ prepareVideoElementForNewSource();
1599
1881
  if (adContainerEl) {
1600
1882
  adContainerEl.style.display = "none";
1601
1883
  adContainerEl.style.pointerEvents = "none";
@@ -4187,201 +4469,6 @@ function fetchConsentSignals() {
4187
4469
  return signals;
4188
4470
  });
4189
4471
  }
4190
- // src/utils/browserCompat.ts
4191
- function getChromeVersion(ua) {
4192
- var match = ua.match(/Chrome\/(\d+)/);
4193
- return match && match[1] ? parseInt(match[1], 10) : 0;
4194
- }
4195
- function getWebKitVersion(ua) {
4196
- var match = ua.match(/AppleWebKit\/(\d+)/);
4197
- return match && match[1] ? parseInt(match[1], 10) : 0;
4198
- }
4199
- function getPlatform() {
4200
- var _navigator_userAgentData;
4201
- if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
4202
- return navigator.userAgentData.platform;
4203
- }
4204
- var ua = navigator.userAgent;
4205
- if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
4206
- return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
4207
- }
4208
- if (/Win/i.test(ua)) {
4209
- return "Win32";
4210
- }
4211
- if (/Linux/i.test(ua)) {
4212
- return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
4213
- }
4214
- if (/CrOS/i.test(ua)) {
4215
- return "CrOS";
4216
- }
4217
- return navigator.platform || "Unknown";
4218
- }
4219
- function detectBrowser() {
4220
- var ua = navigator.userAgent;
4221
- var platform = getPlatform();
4222
- var name = "Unknown";
4223
- var version = "0";
4224
- var majorVersion = 0;
4225
- var isSmartTV = false;
4226
- var isLegacyTV = false;
4227
- var supportsModernJS2 = true;
4228
- var webOSVersion;
4229
- var tizenVersion;
4230
- var chromeVersionNum;
4231
- var chromeVersion = getChromeVersion(ua);
4232
- var webkitVersion = getWebKitVersion(ua);
4233
- chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
4234
- if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
4235
- name = "LG WebOS";
4236
- isSmartTV = true;
4237
- var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
4238
- if (!match || !match[1]) {
4239
- match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
4240
- }
4241
- if (match && match[1]) {
4242
- version = match[1];
4243
- var parts = version.split(".");
4244
- majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
4245
- webOSVersion = majorVersion;
4246
- } else if (chromeVersion > 0) {
4247
- if (chromeVersion >= 79) {
4248
- webOSVersion = 6;
4249
- version = "6.0";
4250
- majorVersion = 6;
4251
- } else if (chromeVersion >= 68) {
4252
- webOSVersion = 5;
4253
- version = "5.0";
4254
- majorVersion = 5;
4255
- } else if (chromeVersion >= 53) {
4256
- webOSVersion = 4;
4257
- version = "4.0";
4258
- majorVersion = 4;
4259
- } else if (chromeVersion >= 38) {
4260
- webOSVersion = 3;
4261
- version = "3.0";
4262
- majorVersion = 3;
4263
- } else {
4264
- webOSVersion = 2;
4265
- version = "2.0";
4266
- majorVersion = 2;
4267
- }
4268
- } else {
4269
- version = "Unknown";
4270
- webOSVersion = void 0;
4271
- }
4272
- isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
4273
- } else if (/Tizen/i.test(ua)) {
4274
- name = "Samsung Tizen";
4275
- isSmartTV = true;
4276
- var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
4277
- version = match1 && match1[1] ? match1[1] : "Unknown";
4278
- if (version !== "Unknown") {
4279
- var parts1 = version.split(".");
4280
- majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
4281
- tizenVersion = majorVersion;
4282
- }
4283
- isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
4284
- } else if (/SMART-TV|SmartTV/i.test(ua)) {
4285
- name = "Smart TV";
4286
- isSmartTV = true;
4287
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4288
- } else if (/NetCast/i.test(ua)) {
4289
- name = "LG NetCast";
4290
- isSmartTV = true;
4291
- isLegacyTV = true;
4292
- } else if (/BRAVIA/i.test(ua)) {
4293
- name = "Sony BRAVIA";
4294
- isSmartTV = true;
4295
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4296
- } else {
4297
- if (chromeVersion > 0) {
4298
- name = "Chrome";
4299
- version = chromeVersion.toString();
4300
- majorVersion = chromeVersion;
4301
- if (chromeVersion < 50) {
4302
- supportsModernJS2 = false;
4303
- }
4304
- }
4305
- if (webkitVersion > 0 && webkitVersion < 600) {
4306
- supportsModernJS2 = false;
4307
- }
4308
- }
4309
- if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
4310
- supportsModernJS2 = false;
4311
- }
4312
- if (typeof URLSearchParams === "undefined") {
4313
- supportsModernJS2 = false;
4314
- }
4315
- return {
4316
- name: name,
4317
- version: version,
4318
- majorVersion: majorVersion,
4319
- isSmartTV: isSmartTV,
4320
- isLegacyTV: isLegacyTV,
4321
- platform: platform,
4322
- supportsModernJS: supportsModernJS2,
4323
- webOSVersion: webOSVersion,
4324
- tizenVersion: tizenVersion,
4325
- chromeVersion: chromeVersionNum
4326
- };
4327
- }
4328
- function requiresMediaPipelineResetAfterAds() {
4329
- var _browser_tizenVersion;
4330
- var browser = detectBrowser();
4331
- return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
4332
- }
4333
- function getBrowserConfigOverrides() {
4334
- var browser = detectBrowser();
4335
- var overrides = {};
4336
- if (browser.isSmartTV) {
4337
- overrides.allowNativeHls = true;
4338
- overrides.pauseContentDuringAds = true;
4339
- }
4340
- return overrides;
4341
- }
4342
- function supportsModernJS() {
4343
- try {
4344
- return typeof Promise !== "undefined" && typeof Map !== "undefined" && typeof Set !== "undefined" && typeof Array.from !== "undefined" && typeof Object.assign !== "undefined" && typeof Array.prototype.forEach !== "undefined" && typeof String.prototype.includes !== "undefined";
4345
- } catch (e) {
4346
- return false;
4347
- }
4348
- }
4349
- function logBrowserInfo() {
4350
- var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
4351
- if (!debug) return;
4352
- var browser = detectBrowser();
4353
- console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
4354
- browser: "".concat(browser.name, " ").concat(browser.version),
4355
- platform: browser.platform,
4356
- isSmartTV: browser.isSmartTV,
4357
- isLegacyTV: browser.isLegacyTV,
4358
- supportsModernJS: browser.supportsModernJS
4359
- }, browser.webOSVersion !== void 0 ? {
4360
- webOSVersion: browser.webOSVersion
4361
- } : {}, browser.tizenVersion !== void 0 ? {
4362
- tizenVersion: browser.tizenVersion
4363
- } : {}, browser.chromeVersion !== void 0 ? {
4364
- chromeVersion: browser.chromeVersion
4365
- } : {}), {
4366
- userAgent: navigator.userAgent
4367
- }));
4368
- }
4369
- function supportsFeature(feature) {
4370
- switch(feature){
4371
- case "urlsearchparams":
4372
- return typeof URLSearchParams !== "undefined";
4373
- case "textencoder":
4374
- return typeof TextEncoder !== "undefined";
4375
- case "promises":
4376
- return typeof Promise !== "undefined";
4377
- case "fetch":
4378
- return typeof fetch !== "undefined";
4379
- case "crypto":
4380
- return typeof crypto !== "undefined" && typeof crypto.subtle !== "undefined";
4381
- default:
4382
- return false;
4383
- }
4384
- }
4385
4472
  // src/player/Scte35Parser.ts
4386
4473
  function parseCueOutDuration(value) {
4387
4474
  var num = parseFloat(value.trim());
@@ -6453,17 +6540,17 @@ var AdTimingService = /*#__PURE__*/ function() {
6453
6540
  {
6454
6541
  key: "logAdState",
6455
6542
  value: function logAdState(event) {
6456
- var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, adPlayer = arguments.length > 2 ? arguments[2] : void 0, inAdBreak = arguments.length > 3 ? arguments[3] : void 0, showAds = arguments.length > 4 ? arguments[4] : void 0;
6457
- var _ref;
6543
+ var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6458
6544
  if (!this.debug) {
6459
6545
  return;
6460
6546
  }
6547
+ var _this_callbacks_getAdState = this.callbacks.getAdState(), inAdBreak = _this_callbacks_getAdState.inAdBreak, showAds = _this_callbacks_getAdState.showAds, adPlaying = _this_callbacks_getAdState.adPlaying;
6461
6548
  console.log("[StormcloudVideoPlayer][AdState]", _object_spread({
6462
6549
  event: event,
6463
6550
  timestamp: /* @__PURE__ */ new Date().toISOString(),
6464
- showAds: showAds !== null && showAds !== void 0 ? showAds : false,
6465
- adPlaying: (_ref = adPlayer === null || adPlayer === void 0 ? void 0 : adPlayer.isAdPlaying()) !== null && _ref !== void 0 ? _ref : false,
6466
- inAdBreak: inAdBreak !== null && inAdBreak !== void 0 ? inAdBreak : false,
6551
+ showAds: showAds,
6552
+ adPlaying: adPlaying,
6553
+ inAdBreak: inAdBreak,
6467
6554
  activeAdRequestToken: this.activeAdRequestToken
6468
6555
  }, extra));
6469
6556
  }
@@ -8813,6 +8900,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8813
8900
  },
8814
8901
  onFailsafeTimeout: function onFailsafeTimeout() {
8815
8902
  return _this.adBreak.handleAdFailure();
8903
+ },
8904
+ getAdState: function getAdState() {
8905
+ return {
8906
+ inAdBreak: _this.adBreak.inAdBreak,
8907
+ showAds: _this.adBreak.showAds,
8908
+ adPlaying: _this.adPlayer.isAdPlaying()
8909
+ };
8816
8910
  }
8817
8911
  });
8818
8912
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);