stormcloud-video-player 0.8.50 → 0.8.52

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;
@@ -602,6 +798,7 @@ function createHlsAdPlayer(contentVideo, options) {
602
798
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
603
799
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
604
800
  var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
801
+ var RVFC_RELIABLE_PROP = "__stormcloudRvfcReliable";
605
802
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
606
803
  var adHls;
607
804
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -622,6 +819,7 @@ function createHlsAdPlayer(contentVideo, options) {
622
819
  var lastAdProgressPosition = 0;
623
820
  var sawDecodedVideoFrame = false;
624
821
  var videoFrameCallbackHandle;
822
+ var pendingPlayPromise;
625
823
  var trackingFired = {
626
824
  impression: false,
627
825
  start: false,
@@ -1425,6 +1623,60 @@ function createHlsAdPlayer(contentVideo, options) {
1425
1623
  complete: false
1426
1624
  };
1427
1625
  }
1626
+ function isRvfcSupported(video) {
1627
+ return typeof video.requestVideoFrameCallback === "function";
1628
+ }
1629
+ function settlePendingPlay() {
1630
+ pendingPlayPromise = void 0;
1631
+ }
1632
+ function startAdPlayback(context) {
1633
+ if (!adVideoElement) return;
1634
+ var playPromise = adVideoElement.play();
1635
+ pendingPlayPromise = playPromise;
1636
+ playPromise.catch(function(error) {
1637
+ if (pendingPlayPromise !== playPromise) {
1638
+ return;
1639
+ }
1640
+ console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
1641
+ handleAdError();
1642
+ }).finally(function() {
1643
+ if (pendingPlayPromise === playPromise) {
1644
+ pendingPlayPromise = void 0;
1645
+ }
1646
+ });
1647
+ }
1648
+ function prepareVideoElementForNewSource() {
1649
+ settlePendingPlay();
1650
+ if (adHls) {
1651
+ adHls.destroy();
1652
+ adHls = void 0;
1653
+ }
1654
+ if (!adVideoElement) return;
1655
+ try {
1656
+ adVideoElement.pause();
1657
+ adVideoElement.removeAttribute("src");
1658
+ adVideoElement.load();
1659
+ } catch (error) {
1660
+ console.warn("[HlsAdPlayer] Error preparing ad video for new source:", error);
1661
+ }
1662
+ }
1663
+ function recreateAdVideoElement() {
1664
+ console.log("[HlsAdPlayer] Recreating ad video element (single-decoder platform)");
1665
+ teardownAdEventListeners();
1666
+ prepareVideoElementForNewSource();
1667
+ if (adVideoElement) {
1668
+ try {
1669
+ adVideoElement.remove();
1670
+ } catch (error) {
1671
+ console.warn("[HlsAdPlayer] Error removing ad video element:", error);
1672
+ }
1673
+ }
1674
+ adVideoElement = createAdVideoElement();
1675
+ adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.appendChild(adVideoElement);
1676
+ contentVideo[AD_VIDEO_PROP] = adVideoElement;
1677
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
1678
+ adVideoElement.muted = originalMutedState;
1679
+ }
1428
1680
  function loadCurrentAdMedia() {
1429
1681
  if (!adVideoElement || !currentAd) {
1430
1682
  throw new Error("No ad video element or ad to load");
@@ -1447,10 +1699,7 @@ function createHlsAdPlayer(contentVideo, options) {
1447
1699
  adHls.attachMedia(adVideoElement);
1448
1700
  adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
1449
1701
  console.log("[HlsAdPlayer] HLS manifest parsed, starting playback");
1450
- adVideoElement.play().catch(function(error) {
1451
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1452
- handleAdError();
1453
- });
1702
+ startAdPlayback("HLS ad playback");
1454
1703
  });
1455
1704
  adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
1456
1705
  console.error("[HlsAdPlayer] HLS error:", data);
@@ -1460,10 +1709,7 @@ function createHlsAdPlayer(contentVideo, options) {
1460
1709
  });
1461
1710
  } else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
1462
1711
  adVideoElement.src = mediaFile.url;
1463
- adVideoElement.play().catch(function(error) {
1464
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1465
- handleAdError();
1466
- });
1712
+ startAdPlayback("native HLS ad playback");
1467
1713
  } else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
1468
1714
  if (adHls) {
1469
1715
  adHls.destroy();
@@ -1471,10 +1717,7 @@ function createHlsAdPlayer(contentVideo, options) {
1471
1717
  }
1472
1718
  adVideoElement.src = mediaFile.url;
1473
1719
  adVideoElement.load();
1474
- adVideoElement.play().catch(function(error) {
1475
- console.error("[HlsAdPlayer] Error starting progressive ad playback:", error);
1476
- handleAdError();
1477
- });
1720
+ startAdPlayback("progressive ad playback");
1478
1721
  } else {
1479
1722
  throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
1480
1723
  }
@@ -1491,6 +1734,13 @@ function createHlsAdPlayer(contentVideo, options) {
1491
1734
  trackingFired.impression = true;
1492
1735
  console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
1493
1736
  }
1737
+ clearStallWatchdog();
1738
+ if (requiresMediaPipelineResetAfterAds()) {
1739
+ recreateAdVideoElement();
1740
+ setupAdEventListeners();
1741
+ } else {
1742
+ prepareVideoElementForNewSource();
1743
+ }
1494
1744
  try {
1495
1745
  loadCurrentAdMedia();
1496
1746
  emit("pod_ad_started", {
@@ -1550,6 +1800,12 @@ function createHlsAdPlayer(contentVideo, options) {
1550
1800
  function markFrameCounterReliable() {
1551
1801
  contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1552
1802
  }
1803
+ function isRvfcReliable() {
1804
+ return contentVideo[RVFC_RELIABLE_PROP] === true;
1805
+ }
1806
+ function markRvfcReliable() {
1807
+ contentVideo[RVFC_RELIABLE_PROP] = true;
1808
+ }
1553
1809
  function cancelVideoFrameProbe() {
1554
1810
  if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1555
1811
  try {
@@ -1569,6 +1825,7 @@ function createHlsAdPlayer(contentVideo, options) {
1569
1825
  videoFrameCallbackHandle = void 0;
1570
1826
  if (!adPlaying) return;
1571
1827
  sawDecodedVideoFrame = true;
1828
+ markRvfcReliable();
1572
1829
  };
1573
1830
  try {
1574
1831
  videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
@@ -1593,18 +1850,26 @@ function createHlsAdPlayer(contentVideo, options) {
1593
1850
  noteAdProgress();
1594
1851
  sawDecodedVideoFrame = false;
1595
1852
  startVideoFrameProbe();
1853
+ var blackFrameDetectionEnabled = !requiresMediaPipelineResetAfterAds();
1596
1854
  stallWatchdogId = window.setInterval(function() {
1597
1855
  if (!adPlaying || !adVideoElement) {
1598
1856
  return;
1599
1857
  }
1600
- if (!sawDecodedVideoFrame && !adVideoElement.paused) {
1858
+ if (blackFrameDetectionEnabled && !sawDecodedVideoFrame && !adVideoElement.paused) {
1601
1859
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1602
1860
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1603
1861
  sawDecodedVideoFrame = true;
1604
1862
  markFrameCounterReliable();
1605
- } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S && isFrameCounterReliable()) {
1606
- handleVideoDecodeFailure();
1607
- return;
1863
+ } else if (adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1864
+ var timeAdvancing = adVideoElement.currentTime > lastAdProgressPosition + 0.05;
1865
+ if (isRvfcSupported(adVideoElement) && timeAdvancing && isRvfcReliable()) {
1866
+ handleVideoDecodeFailure();
1867
+ return;
1868
+ }
1869
+ if (decodedFrames === 0 && timeAdvancing && isFrameCounterReliable()) {
1870
+ handleVideoDecodeFailure();
1871
+ return;
1872
+ }
1608
1873
  }
1609
1874
  }
1610
1875
  if (adVideoElement.currentTime > lastAdProgressPosition + 0.05) {
@@ -1621,19 +1886,7 @@ function createHlsAdPlayer(contentVideo, options) {
1621
1886
  }, STALL_CHECK_INTERVAL_MS);
1622
1887
  }
1623
1888
  function releaseAdDecoder() {
1624
- if (adHls) {
1625
- adHls.destroy();
1626
- adHls = void 0;
1627
- }
1628
- if (adVideoElement) {
1629
- try {
1630
- adVideoElement.pause();
1631
- adVideoElement.removeAttribute("src");
1632
- adVideoElement.load();
1633
- } catch (error) {
1634
- console.warn("[HlsAdPlayer] Error releasing ad decoder:", error);
1635
- }
1636
- }
1889
+ prepareVideoElementForNewSource();
1637
1890
  if (adContainerEl) {
1638
1891
  adContainerEl.style.display = "none";
1639
1892
  adContainerEl.style.pointerEvents = "none";
@@ -2010,7 +2263,7 @@ function createHlsAdPlayer(contentVideo, options) {
2010
2263
  }
2011
2264
  },
2012
2265
  hidePlaceholder: function hidePlaceholder() {
2013
- if (adContainerEl) {
2266
+ if (adContainerEl && !adPlaying) {
2014
2267
  adContainerEl.style.display = "none";
2015
2268
  adContainerEl.style.pointerEvents = "none";
2016
2269
  }
@@ -4225,201 +4478,6 @@ function fetchConsentSignals() {
4225
4478
  return signals;
4226
4479
  });
4227
4480
  }
4228
- // src/utils/browserCompat.ts
4229
- function getChromeVersion(ua) {
4230
- var match = ua.match(/Chrome\/(\d+)/);
4231
- return match && match[1] ? parseInt(match[1], 10) : 0;
4232
- }
4233
- function getWebKitVersion(ua) {
4234
- var match = ua.match(/AppleWebKit\/(\d+)/);
4235
- return match && match[1] ? parseInt(match[1], 10) : 0;
4236
- }
4237
- function getPlatform() {
4238
- var _navigator_userAgentData;
4239
- if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
4240
- return navigator.userAgentData.platform;
4241
- }
4242
- var ua = navigator.userAgent;
4243
- if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
4244
- return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
4245
- }
4246
- if (/Win/i.test(ua)) {
4247
- return "Win32";
4248
- }
4249
- if (/Linux/i.test(ua)) {
4250
- return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
4251
- }
4252
- if (/CrOS/i.test(ua)) {
4253
- return "CrOS";
4254
- }
4255
- return navigator.platform || "Unknown";
4256
- }
4257
- function detectBrowser() {
4258
- var ua = navigator.userAgent;
4259
- var platform = getPlatform();
4260
- var name = "Unknown";
4261
- var version = "0";
4262
- var majorVersion = 0;
4263
- var isSmartTV = false;
4264
- var isLegacyTV = false;
4265
- var supportsModernJS2 = true;
4266
- var webOSVersion;
4267
- var tizenVersion;
4268
- var chromeVersionNum;
4269
- var chromeVersion = getChromeVersion(ua);
4270
- var webkitVersion = getWebKitVersion(ua);
4271
- chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
4272
- if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
4273
- name = "LG WebOS";
4274
- isSmartTV = true;
4275
- var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
4276
- if (!match || !match[1]) {
4277
- match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
4278
- }
4279
- if (match && match[1]) {
4280
- version = match[1];
4281
- var parts = version.split(".");
4282
- majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
4283
- webOSVersion = majorVersion;
4284
- } else if (chromeVersion > 0) {
4285
- if (chromeVersion >= 79) {
4286
- webOSVersion = 6;
4287
- version = "6.0";
4288
- majorVersion = 6;
4289
- } else if (chromeVersion >= 68) {
4290
- webOSVersion = 5;
4291
- version = "5.0";
4292
- majorVersion = 5;
4293
- } else if (chromeVersion >= 53) {
4294
- webOSVersion = 4;
4295
- version = "4.0";
4296
- majorVersion = 4;
4297
- } else if (chromeVersion >= 38) {
4298
- webOSVersion = 3;
4299
- version = "3.0";
4300
- majorVersion = 3;
4301
- } else {
4302
- webOSVersion = 2;
4303
- version = "2.0";
4304
- majorVersion = 2;
4305
- }
4306
- } else {
4307
- version = "Unknown";
4308
- webOSVersion = void 0;
4309
- }
4310
- isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
4311
- } else if (/Tizen/i.test(ua)) {
4312
- name = "Samsung Tizen";
4313
- isSmartTV = true;
4314
- var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
4315
- version = match1 && match1[1] ? match1[1] : "Unknown";
4316
- if (version !== "Unknown") {
4317
- var parts1 = version.split(".");
4318
- majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
4319
- tizenVersion = majorVersion;
4320
- }
4321
- isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
4322
- } else if (/SMART-TV|SmartTV/i.test(ua)) {
4323
- name = "Smart TV";
4324
- isSmartTV = true;
4325
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4326
- } else if (/NetCast/i.test(ua)) {
4327
- name = "LG NetCast";
4328
- isSmartTV = true;
4329
- isLegacyTV = true;
4330
- } else if (/BRAVIA/i.test(ua)) {
4331
- name = "Sony BRAVIA";
4332
- isSmartTV = true;
4333
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4334
- } else {
4335
- if (chromeVersion > 0) {
4336
- name = "Chrome";
4337
- version = chromeVersion.toString();
4338
- majorVersion = chromeVersion;
4339
- if (chromeVersion < 50) {
4340
- supportsModernJS2 = false;
4341
- }
4342
- }
4343
- if (webkitVersion > 0 && webkitVersion < 600) {
4344
- supportsModernJS2 = false;
4345
- }
4346
- }
4347
- if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
4348
- supportsModernJS2 = false;
4349
- }
4350
- if (typeof URLSearchParams === "undefined") {
4351
- supportsModernJS2 = false;
4352
- }
4353
- return {
4354
- name: name,
4355
- version: version,
4356
- majorVersion: majorVersion,
4357
- isSmartTV: isSmartTV,
4358
- isLegacyTV: isLegacyTV,
4359
- platform: platform,
4360
- supportsModernJS: supportsModernJS2,
4361
- webOSVersion: webOSVersion,
4362
- tizenVersion: tizenVersion,
4363
- chromeVersion: chromeVersionNum
4364
- };
4365
- }
4366
- function requiresMediaPipelineResetAfterAds() {
4367
- var _browser_tizenVersion;
4368
- var browser = detectBrowser();
4369
- return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
4370
- }
4371
- function getBrowserConfigOverrides() {
4372
- var browser = detectBrowser();
4373
- var overrides = {};
4374
- if (browser.isSmartTV) {
4375
- overrides.allowNativeHls = true;
4376
- overrides.pauseContentDuringAds = true;
4377
- }
4378
- return overrides;
4379
- }
4380
- function supportsModernJS() {
4381
- try {
4382
- 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";
4383
- } catch (e) {
4384
- return false;
4385
- }
4386
- }
4387
- function logBrowserInfo() {
4388
- var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
4389
- if (!debug) return;
4390
- var browser = detectBrowser();
4391
- console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
4392
- browser: "".concat(browser.name, " ").concat(browser.version),
4393
- platform: browser.platform,
4394
- isSmartTV: browser.isSmartTV,
4395
- isLegacyTV: browser.isLegacyTV,
4396
- supportsModernJS: browser.supportsModernJS
4397
- }, browser.webOSVersion !== void 0 ? {
4398
- webOSVersion: browser.webOSVersion
4399
- } : {}, browser.tizenVersion !== void 0 ? {
4400
- tizenVersion: browser.tizenVersion
4401
- } : {}, browser.chromeVersion !== void 0 ? {
4402
- chromeVersion: browser.chromeVersion
4403
- } : {}), {
4404
- userAgent: navigator.userAgent
4405
- }));
4406
- }
4407
- function supportsFeature(feature) {
4408
- switch(feature){
4409
- case "urlsearchparams":
4410
- return typeof URLSearchParams !== "undefined";
4411
- case "textencoder":
4412
- return typeof TextEncoder !== "undefined";
4413
- case "promises":
4414
- return typeof Promise !== "undefined";
4415
- case "fetch":
4416
- return typeof fetch !== "undefined";
4417
- case "crypto":
4418
- return typeof crypto !== "undefined" && typeof crypto.subtle !== "undefined";
4419
- default:
4420
- return false;
4421
- }
4422
- }
4423
4481
  // src/player/Scte35Parser.ts
4424
4482
  function parseCueOutDuration(value) {
4425
4483
  var num = parseFloat(value.trim());