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.
@@ -436,6 +436,179 @@ var canPlay = {
436
436
  var import_react2 = require("react");
437
437
  // src/sdk/hlsAdPlayer.ts
438
438
  var import_hls = __toESM(require("hls.js"), 1);
439
+ // src/utils/browserCompat.ts
440
+ function getChromeVersion(ua) {
441
+ var match = ua.match(/Chrome\/(\d+)/);
442
+ return match && match[1] ? parseInt(match[1], 10) : 0;
443
+ }
444
+ function getWebKitVersion(ua) {
445
+ var match = ua.match(/AppleWebKit\/(\d+)/);
446
+ return match && match[1] ? parseInt(match[1], 10) : 0;
447
+ }
448
+ function getPlatform() {
449
+ var _navigator_userAgentData;
450
+ if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
451
+ return navigator.userAgentData.platform;
452
+ }
453
+ var ua = navigator.userAgent;
454
+ if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
455
+ return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
456
+ }
457
+ if (/Win/i.test(ua)) {
458
+ return "Win32";
459
+ }
460
+ if (/Linux/i.test(ua)) {
461
+ return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
462
+ }
463
+ if (/CrOS/i.test(ua)) {
464
+ return "CrOS";
465
+ }
466
+ return navigator.platform || "Unknown";
467
+ }
468
+ function detectBrowser() {
469
+ var ua = navigator.userAgent;
470
+ var platform = getPlatform();
471
+ var name = "Unknown";
472
+ var version = "0";
473
+ var majorVersion = 0;
474
+ var isSmartTV = false;
475
+ var isLegacyTV = false;
476
+ var supportsModernJS = true;
477
+ var webOSVersion;
478
+ var tizenVersion;
479
+ var chromeVersionNum;
480
+ var chromeVersion = getChromeVersion(ua);
481
+ var webkitVersion = getWebKitVersion(ua);
482
+ chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
483
+ if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
484
+ name = "LG WebOS";
485
+ isSmartTV = true;
486
+ var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
487
+ if (!match || !match[1]) {
488
+ match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
489
+ }
490
+ if (match && match[1]) {
491
+ version = match[1];
492
+ var parts = version.split(".");
493
+ majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
494
+ webOSVersion = majorVersion;
495
+ } else if (chromeVersion > 0) {
496
+ if (chromeVersion >= 79) {
497
+ webOSVersion = 6;
498
+ version = "6.0";
499
+ majorVersion = 6;
500
+ } else if (chromeVersion >= 68) {
501
+ webOSVersion = 5;
502
+ version = "5.0";
503
+ majorVersion = 5;
504
+ } else if (chromeVersion >= 53) {
505
+ webOSVersion = 4;
506
+ version = "4.0";
507
+ majorVersion = 4;
508
+ } else if (chromeVersion >= 38) {
509
+ webOSVersion = 3;
510
+ version = "3.0";
511
+ majorVersion = 3;
512
+ } else {
513
+ webOSVersion = 2;
514
+ version = "2.0";
515
+ majorVersion = 2;
516
+ }
517
+ } else {
518
+ version = "Unknown";
519
+ webOSVersion = void 0;
520
+ }
521
+ isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
522
+ } else if (/Tizen/i.test(ua)) {
523
+ name = "Samsung Tizen";
524
+ isSmartTV = true;
525
+ var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
526
+ version = match1 && match1[1] ? match1[1] : "Unknown";
527
+ if (version !== "Unknown") {
528
+ var parts1 = version.split(".");
529
+ majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
530
+ tizenVersion = majorVersion;
531
+ }
532
+ isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
533
+ } else if (/SMART-TV|SmartTV/i.test(ua)) {
534
+ name = "Smart TV";
535
+ isSmartTV = true;
536
+ isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
537
+ } else if (/NetCast/i.test(ua)) {
538
+ name = "LG NetCast";
539
+ isSmartTV = true;
540
+ isLegacyTV = true;
541
+ } else if (/BRAVIA/i.test(ua)) {
542
+ name = "Sony BRAVIA";
543
+ isSmartTV = true;
544
+ isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
545
+ } else {
546
+ if (chromeVersion > 0) {
547
+ name = "Chrome";
548
+ version = chromeVersion.toString();
549
+ majorVersion = chromeVersion;
550
+ if (chromeVersion < 50) {
551
+ supportsModernJS = false;
552
+ }
553
+ }
554
+ if (webkitVersion > 0 && webkitVersion < 600) {
555
+ supportsModernJS = false;
556
+ }
557
+ }
558
+ if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
559
+ supportsModernJS = false;
560
+ }
561
+ if (typeof URLSearchParams === "undefined") {
562
+ supportsModernJS = false;
563
+ }
564
+ return {
565
+ name: name,
566
+ version: version,
567
+ majorVersion: majorVersion,
568
+ isSmartTV: isSmartTV,
569
+ isLegacyTV: isLegacyTV,
570
+ platform: platform,
571
+ supportsModernJS: supportsModernJS,
572
+ webOSVersion: webOSVersion,
573
+ tizenVersion: tizenVersion,
574
+ chromeVersion: chromeVersionNum
575
+ };
576
+ }
577
+ function requiresMediaPipelineResetAfterAds() {
578
+ var _browser_tizenVersion;
579
+ var browser = detectBrowser();
580
+ return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
581
+ }
582
+ function getBrowserConfigOverrides() {
583
+ var browser = detectBrowser();
584
+ var overrides = {};
585
+ if (browser.isSmartTV) {
586
+ overrides.allowNativeHls = true;
587
+ overrides.pauseContentDuringAds = true;
588
+ }
589
+ return overrides;
590
+ }
591
+ function logBrowserInfo() {
592
+ var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
593
+ if (!debug) return;
594
+ var browser = detectBrowser();
595
+ console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
596
+ browser: "".concat(browser.name, " ").concat(browser.version),
597
+ platform: browser.platform,
598
+ isSmartTV: browser.isSmartTV,
599
+ isLegacyTV: browser.isLegacyTV,
600
+ supportsModernJS: browser.supportsModernJS
601
+ }, browser.webOSVersion !== void 0 ? {
602
+ webOSVersion: browser.webOSVersion
603
+ } : {}, browser.tizenVersion !== void 0 ? {
604
+ tizenVersion: browser.tizenVersion
605
+ } : {}, browser.chromeVersion !== void 0 ? {
606
+ chromeVersion: browser.chromeVersion
607
+ } : {}), {
608
+ userAgent: navigator.userAgent
609
+ }));
610
+ }
611
+ // src/sdk/hlsAdPlayer.ts
439
612
  var MAX_VAST_WRAPPER_DEPTH = 5;
440
613
  function createHlsAdPlayer(contentVideo, options) {
441
614
  var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
@@ -447,6 +620,7 @@ function createHlsAdPlayer(contentVideo, options) {
447
620
  var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
448
621
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
449
622
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
623
+ var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
450
624
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
451
625
  var adHls;
452
626
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -466,6 +640,8 @@ function createHlsAdPlayer(contentVideo, options) {
466
640
  var lastAdProgressTime = 0;
467
641
  var lastAdProgressPosition = 0;
468
642
  var sawDecodedVideoFrame = false;
643
+ var videoFrameCallbackHandle;
644
+ var pendingPlayPromise;
469
645
  var trackingFired = {
470
646
  impression: false,
471
647
  start: false,
@@ -1269,6 +1445,60 @@ function createHlsAdPlayer(contentVideo, options) {
1269
1445
  complete: false
1270
1446
  };
1271
1447
  }
1448
+ function isRvfcSupported(video) {
1449
+ return typeof video.requestVideoFrameCallback === "function";
1450
+ }
1451
+ function settlePendingPlay() {
1452
+ pendingPlayPromise = void 0;
1453
+ }
1454
+ function startAdPlayback(context) {
1455
+ if (!adVideoElement) return;
1456
+ var playPromise = adVideoElement.play();
1457
+ pendingPlayPromise = playPromise;
1458
+ playPromise.catch(function(error) {
1459
+ if (pendingPlayPromise !== playPromise) {
1460
+ return;
1461
+ }
1462
+ console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
1463
+ handleAdError();
1464
+ }).finally(function() {
1465
+ if (pendingPlayPromise === playPromise) {
1466
+ pendingPlayPromise = void 0;
1467
+ }
1468
+ });
1469
+ }
1470
+ function prepareVideoElementForNewSource() {
1471
+ settlePendingPlay();
1472
+ if (adHls) {
1473
+ adHls.destroy();
1474
+ adHls = void 0;
1475
+ }
1476
+ if (!adVideoElement) return;
1477
+ try {
1478
+ adVideoElement.pause();
1479
+ adVideoElement.removeAttribute("src");
1480
+ adVideoElement.load();
1481
+ } catch (error) {
1482
+ console.warn("[HlsAdPlayer] Error preparing ad video for new source:", error);
1483
+ }
1484
+ }
1485
+ function recreateAdVideoElement() {
1486
+ console.log("[HlsAdPlayer] Recreating ad video element (single-decoder platform)");
1487
+ teardownAdEventListeners();
1488
+ prepareVideoElementForNewSource();
1489
+ if (adVideoElement) {
1490
+ try {
1491
+ adVideoElement.remove();
1492
+ } catch (error) {
1493
+ console.warn("[HlsAdPlayer] Error removing ad video element:", error);
1494
+ }
1495
+ }
1496
+ adVideoElement = createAdVideoElement();
1497
+ adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.appendChild(adVideoElement);
1498
+ contentVideo[AD_VIDEO_PROP] = adVideoElement;
1499
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
1500
+ adVideoElement.muted = originalMutedState;
1501
+ }
1272
1502
  function loadCurrentAdMedia() {
1273
1503
  if (!adVideoElement || !currentAd) {
1274
1504
  throw new Error("No ad video element or ad to load");
@@ -1291,10 +1521,7 @@ function createHlsAdPlayer(contentVideo, options) {
1291
1521
  adHls.attachMedia(adVideoElement);
1292
1522
  adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
1293
1523
  console.log("[HlsAdPlayer] HLS manifest parsed, starting playback");
1294
- adVideoElement.play().catch(function(error) {
1295
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1296
- handleAdError();
1297
- });
1524
+ startAdPlayback("HLS ad playback");
1298
1525
  });
1299
1526
  adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
1300
1527
  console.error("[HlsAdPlayer] HLS error:", data);
@@ -1304,10 +1531,7 @@ function createHlsAdPlayer(contentVideo, options) {
1304
1531
  });
1305
1532
  } else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
1306
1533
  adVideoElement.src = mediaFile.url;
1307
- adVideoElement.play().catch(function(error) {
1308
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1309
- handleAdError();
1310
- });
1534
+ startAdPlayback("native HLS ad playback");
1311
1535
  } else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
1312
1536
  if (adHls) {
1313
1537
  adHls.destroy();
@@ -1315,10 +1539,7 @@ function createHlsAdPlayer(contentVideo, options) {
1315
1539
  }
1316
1540
  adVideoElement.src = mediaFile.url;
1317
1541
  adVideoElement.load();
1318
- adVideoElement.play().catch(function(error) {
1319
- console.error("[HlsAdPlayer] Error starting progressive ad playback:", error);
1320
- handleAdError();
1321
- });
1542
+ startAdPlayback("progressive ad playback");
1322
1543
  } else {
1323
1544
  throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
1324
1545
  }
@@ -1335,6 +1556,13 @@ function createHlsAdPlayer(contentVideo, options) {
1335
1556
  trackingFired.impression = true;
1336
1557
  console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
1337
1558
  }
1559
+ clearStallWatchdog();
1560
+ if (requiresMediaPipelineResetAfterAds()) {
1561
+ recreateAdVideoElement();
1562
+ setupAdEventListeners();
1563
+ } else {
1564
+ prepareVideoElementForNewSource();
1565
+ }
1338
1566
  try {
1339
1567
  loadCurrentAdMedia();
1340
1568
  emit("pod_ad_started", {
@@ -1352,6 +1580,7 @@ function createHlsAdPlayer(contentVideo, options) {
1352
1580
  clearInterval(stallWatchdogId);
1353
1581
  stallWatchdogId = void 0;
1354
1582
  }
1583
+ cancelVideoFrameProbe();
1355
1584
  }
1356
1585
  function noteAdProgress() {
1357
1586
  lastAdProgressTime = Date.now();
@@ -1387,6 +1616,39 @@ function createHlsAdPlayer(contentVideo, options) {
1387
1616
  }
1388
1617
  return void 0;
1389
1618
  }
1619
+ function isFrameCounterReliable() {
1620
+ return contentVideo[FRAME_COUNTER_RELIABLE_PROP] === true;
1621
+ }
1622
+ function markFrameCounterReliable() {
1623
+ contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1624
+ }
1625
+ function cancelVideoFrameProbe() {
1626
+ if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1627
+ try {
1628
+ adVideoElement.cancelVideoFrameCallback(videoFrameCallbackHandle);
1629
+ } catch (error) {
1630
+ console.warn("[HlsAdPlayer] Error cancelling video frame callback:", error);
1631
+ }
1632
+ }
1633
+ videoFrameCallbackHandle = void 0;
1634
+ }
1635
+ function startVideoFrameProbe() {
1636
+ cancelVideoFrameProbe();
1637
+ if (!adVideoElement) return;
1638
+ var rvfc = adVideoElement.requestVideoFrameCallback;
1639
+ if (typeof rvfc !== "function") return;
1640
+ var onPresentedFrame = function onPresentedFrame() {
1641
+ videoFrameCallbackHandle = void 0;
1642
+ if (!adPlaying) return;
1643
+ sawDecodedVideoFrame = true;
1644
+ };
1645
+ try {
1646
+ videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
1647
+ } catch (error) {
1648
+ console.warn("[HlsAdPlayer] Error requesting video frame callback:", error);
1649
+ videoFrameCallbackHandle = void 0;
1650
+ }
1651
+ }
1390
1652
  function handleVideoDecodeFailure() {
1391
1653
  console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
1392
1654
  clearStallWatchdog();
@@ -1402,6 +1664,7 @@ function createHlsAdPlayer(contentVideo, options) {
1402
1664
  clearStallWatchdog();
1403
1665
  noteAdProgress();
1404
1666
  sawDecodedVideoFrame = false;
1667
+ startVideoFrameProbe();
1405
1668
  stallWatchdogId = window.setInterval(function() {
1406
1669
  if (!adPlaying || !adVideoElement) {
1407
1670
  return;
@@ -1410,9 +1673,17 @@ function createHlsAdPlayer(contentVideo, options) {
1410
1673
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1411
1674
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1412
1675
  sawDecodedVideoFrame = true;
1413
- } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1414
- handleVideoDecodeFailure();
1415
- return;
1676
+ markFrameCounterReliable();
1677
+ } else if (adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1678
+ var timeAdvancing = adVideoElement.currentTime > lastAdProgressPosition + 0.05;
1679
+ if (isRvfcSupported(adVideoElement) && timeAdvancing) {
1680
+ handleVideoDecodeFailure();
1681
+ return;
1682
+ }
1683
+ if (decodedFrames === 0 && timeAdvancing && isFrameCounterReliable()) {
1684
+ handleVideoDecodeFailure();
1685
+ return;
1686
+ }
1416
1687
  }
1417
1688
  }
1418
1689
  if (adVideoElement.currentTime > lastAdProgressPosition + 0.05) {
@@ -1429,19 +1700,7 @@ function createHlsAdPlayer(contentVideo, options) {
1429
1700
  }, STALL_CHECK_INTERVAL_MS);
1430
1701
  }
1431
1702
  function releaseAdDecoder() {
1432
- if (adHls) {
1433
- adHls.destroy();
1434
- adHls = void 0;
1435
- }
1436
- if (adVideoElement) {
1437
- try {
1438
- adVideoElement.pause();
1439
- adVideoElement.removeAttribute("src");
1440
- adVideoElement.load();
1441
- } catch (error) {
1442
- console.warn("[HlsAdPlayer] Error releasing ad decoder:", error);
1443
- }
1444
- }
1703
+ prepareVideoElementForNewSource();
1445
1704
  if (adContainerEl) {
1446
1705
  adContainerEl.style.display = "none";
1447
1706
  adContainerEl.style.pointerEvents = "none";
@@ -4012,178 +4271,6 @@ function fetchConsentSignals() {
4012
4271
  return signals;
4013
4272
  });
4014
4273
  }
4015
- // src/utils/browserCompat.ts
4016
- function getChromeVersion(ua) {
4017
- var match = ua.match(/Chrome\/(\d+)/);
4018
- return match && match[1] ? parseInt(match[1], 10) : 0;
4019
- }
4020
- function getWebKitVersion(ua) {
4021
- var match = ua.match(/AppleWebKit\/(\d+)/);
4022
- return match && match[1] ? parseInt(match[1], 10) : 0;
4023
- }
4024
- function getPlatform() {
4025
- var _navigator_userAgentData;
4026
- if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
4027
- return navigator.userAgentData.platform;
4028
- }
4029
- var ua = navigator.userAgent;
4030
- if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
4031
- return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
4032
- }
4033
- if (/Win/i.test(ua)) {
4034
- return "Win32";
4035
- }
4036
- if (/Linux/i.test(ua)) {
4037
- return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
4038
- }
4039
- if (/CrOS/i.test(ua)) {
4040
- return "CrOS";
4041
- }
4042
- return navigator.platform || "Unknown";
4043
- }
4044
- function detectBrowser() {
4045
- var ua = navigator.userAgent;
4046
- var platform = getPlatform();
4047
- var name = "Unknown";
4048
- var version = "0";
4049
- var majorVersion = 0;
4050
- var isSmartTV = false;
4051
- var isLegacyTV = false;
4052
- var supportsModernJS = true;
4053
- var webOSVersion;
4054
- var tizenVersion;
4055
- var chromeVersionNum;
4056
- var chromeVersion = getChromeVersion(ua);
4057
- var webkitVersion = getWebKitVersion(ua);
4058
- chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
4059
- if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
4060
- name = "LG WebOS";
4061
- isSmartTV = true;
4062
- var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
4063
- if (!match || !match[1]) {
4064
- match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
4065
- }
4066
- if (match && match[1]) {
4067
- version = match[1];
4068
- var parts = version.split(".");
4069
- majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
4070
- webOSVersion = majorVersion;
4071
- } else if (chromeVersion > 0) {
4072
- if (chromeVersion >= 79) {
4073
- webOSVersion = 6;
4074
- version = "6.0";
4075
- majorVersion = 6;
4076
- } else if (chromeVersion >= 68) {
4077
- webOSVersion = 5;
4078
- version = "5.0";
4079
- majorVersion = 5;
4080
- } else if (chromeVersion >= 53) {
4081
- webOSVersion = 4;
4082
- version = "4.0";
4083
- majorVersion = 4;
4084
- } else if (chromeVersion >= 38) {
4085
- webOSVersion = 3;
4086
- version = "3.0";
4087
- majorVersion = 3;
4088
- } else {
4089
- webOSVersion = 2;
4090
- version = "2.0";
4091
- majorVersion = 2;
4092
- }
4093
- } else {
4094
- version = "Unknown";
4095
- webOSVersion = void 0;
4096
- }
4097
- isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
4098
- } else if (/Tizen/i.test(ua)) {
4099
- name = "Samsung Tizen";
4100
- isSmartTV = true;
4101
- var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
4102
- version = match1 && match1[1] ? match1[1] : "Unknown";
4103
- if (version !== "Unknown") {
4104
- var parts1 = version.split(".");
4105
- majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
4106
- tizenVersion = majorVersion;
4107
- }
4108
- isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
4109
- } else if (/SMART-TV|SmartTV/i.test(ua)) {
4110
- name = "Smart TV";
4111
- isSmartTV = true;
4112
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4113
- } else if (/NetCast/i.test(ua)) {
4114
- name = "LG NetCast";
4115
- isSmartTV = true;
4116
- isLegacyTV = true;
4117
- } else if (/BRAVIA/i.test(ua)) {
4118
- name = "Sony BRAVIA";
4119
- isSmartTV = true;
4120
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4121
- } else {
4122
- if (chromeVersion > 0) {
4123
- name = "Chrome";
4124
- version = chromeVersion.toString();
4125
- majorVersion = chromeVersion;
4126
- if (chromeVersion < 50) {
4127
- supportsModernJS = false;
4128
- }
4129
- }
4130
- if (webkitVersion > 0 && webkitVersion < 600) {
4131
- supportsModernJS = false;
4132
- }
4133
- }
4134
- if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
4135
- supportsModernJS = false;
4136
- }
4137
- if (typeof URLSearchParams === "undefined") {
4138
- supportsModernJS = false;
4139
- }
4140
- return {
4141
- name: name,
4142
- version: version,
4143
- majorVersion: majorVersion,
4144
- isSmartTV: isSmartTV,
4145
- isLegacyTV: isLegacyTV,
4146
- platform: platform,
4147
- supportsModernJS: supportsModernJS,
4148
- webOSVersion: webOSVersion,
4149
- tizenVersion: tizenVersion,
4150
- chromeVersion: chromeVersionNum
4151
- };
4152
- }
4153
- function requiresMediaPipelineResetAfterAds() {
4154
- var _browser_tizenVersion;
4155
- var browser = detectBrowser();
4156
- return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
4157
- }
4158
- function getBrowserConfigOverrides() {
4159
- var browser = detectBrowser();
4160
- var overrides = {};
4161
- if (browser.isSmartTV) {
4162
- overrides.allowNativeHls = true;
4163
- overrides.pauseContentDuringAds = true;
4164
- }
4165
- return overrides;
4166
- }
4167
- function logBrowserInfo() {
4168
- var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
4169
- if (!debug) return;
4170
- var browser = detectBrowser();
4171
- console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
4172
- browser: "".concat(browser.name, " ").concat(browser.version),
4173
- platform: browser.platform,
4174
- isSmartTV: browser.isSmartTV,
4175
- isLegacyTV: browser.isLegacyTV,
4176
- supportsModernJS: browser.supportsModernJS
4177
- }, browser.webOSVersion !== void 0 ? {
4178
- webOSVersion: browser.webOSVersion
4179
- } : {}, browser.tizenVersion !== void 0 ? {
4180
- tizenVersion: browser.tizenVersion
4181
- } : {}, browser.chromeVersion !== void 0 ? {
4182
- chromeVersion: browser.chromeVersion
4183
- } : {}), {
4184
- userAgent: navigator.userAgent
4185
- }));
4186
- }
4187
4274
  // src/player/Scte35Parser.ts
4188
4275
  function parseCueOutDuration(value) {
4189
4276
  var num = parseFloat(value.trim());
@@ -6255,17 +6342,17 @@ var AdTimingService = /*#__PURE__*/ function() {
6255
6342
  {
6256
6343
  key: "logAdState",
6257
6344
  value: function logAdState(event) {
6258
- 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;
6259
- var _ref;
6345
+ var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6260
6346
  if (!this.debug) {
6261
6347
  return;
6262
6348
  }
6349
+ var _this_callbacks_getAdState = this.callbacks.getAdState(), inAdBreak = _this_callbacks_getAdState.inAdBreak, showAds = _this_callbacks_getAdState.showAds, adPlaying = _this_callbacks_getAdState.adPlaying;
6263
6350
  console.log("[StormcloudVideoPlayer][AdState]", _object_spread({
6264
6351
  event: event,
6265
6352
  timestamp: /* @__PURE__ */ new Date().toISOString(),
6266
- showAds: showAds !== null && showAds !== void 0 ? showAds : false,
6267
- adPlaying: (_ref = adPlayer === null || adPlayer === void 0 ? void 0 : adPlayer.isAdPlaying()) !== null && _ref !== void 0 ? _ref : false,
6268
- inAdBreak: inAdBreak !== null && inAdBreak !== void 0 ? inAdBreak : false,
6353
+ showAds: showAds,
6354
+ adPlaying: adPlaying,
6355
+ inAdBreak: inAdBreak,
6269
6356
  activeAdRequestToken: this.activeAdRequestToken
6270
6357
  }, extra));
6271
6358
  }
@@ -8615,6 +8702,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8615
8702
  },
8616
8703
  onFailsafeTimeout: function onFailsafeTimeout() {
8617
8704
  return _this.adBreak.handleAdFailure();
8705
+ },
8706
+ getAdState: function getAdState() {
8707
+ return {
8708
+ inAdBreak: _this.adBreak.inAdBreak,
8709
+ showAds: _this.adBreak.showAds,
8710
+ adPlaying: _this.adPlayer.isAdPlaying()
8711
+ };
8618
8712
  }
8619
8713
  });
8620
8714
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);