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.
@@ -400,6 +400,179 @@ module.exports = __toCommonJS(HlsPlayer_exports);
400
400
  var import_react = require("react");
401
401
  // src/sdk/hlsAdPlayer.ts
402
402
  var import_hls = __toESM(require("hls.js"), 1);
403
+ // src/utils/browserCompat.ts
404
+ function getChromeVersion(ua) {
405
+ var match = ua.match(/Chrome\/(\d+)/);
406
+ return match && match[1] ? parseInt(match[1], 10) : 0;
407
+ }
408
+ function getWebKitVersion(ua) {
409
+ var match = ua.match(/AppleWebKit\/(\d+)/);
410
+ return match && match[1] ? parseInt(match[1], 10) : 0;
411
+ }
412
+ function getPlatform() {
413
+ var _navigator_userAgentData;
414
+ if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
415
+ return navigator.userAgentData.platform;
416
+ }
417
+ var ua = navigator.userAgent;
418
+ if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
419
+ return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
420
+ }
421
+ if (/Win/i.test(ua)) {
422
+ return "Win32";
423
+ }
424
+ if (/Linux/i.test(ua)) {
425
+ return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
426
+ }
427
+ if (/CrOS/i.test(ua)) {
428
+ return "CrOS";
429
+ }
430
+ return navigator.platform || "Unknown";
431
+ }
432
+ function detectBrowser() {
433
+ var ua = navigator.userAgent;
434
+ var platform = getPlatform();
435
+ var name = "Unknown";
436
+ var version = "0";
437
+ var majorVersion = 0;
438
+ var isSmartTV = false;
439
+ var isLegacyTV = false;
440
+ var supportsModernJS = true;
441
+ var webOSVersion;
442
+ var tizenVersion;
443
+ var chromeVersionNum;
444
+ var chromeVersion = getChromeVersion(ua);
445
+ var webkitVersion = getWebKitVersion(ua);
446
+ chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
447
+ if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
448
+ name = "LG WebOS";
449
+ isSmartTV = true;
450
+ var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
451
+ if (!match || !match[1]) {
452
+ match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
453
+ }
454
+ if (match && match[1]) {
455
+ version = match[1];
456
+ var parts = version.split(".");
457
+ majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
458
+ webOSVersion = majorVersion;
459
+ } else if (chromeVersion > 0) {
460
+ if (chromeVersion >= 79) {
461
+ webOSVersion = 6;
462
+ version = "6.0";
463
+ majorVersion = 6;
464
+ } else if (chromeVersion >= 68) {
465
+ webOSVersion = 5;
466
+ version = "5.0";
467
+ majorVersion = 5;
468
+ } else if (chromeVersion >= 53) {
469
+ webOSVersion = 4;
470
+ version = "4.0";
471
+ majorVersion = 4;
472
+ } else if (chromeVersion >= 38) {
473
+ webOSVersion = 3;
474
+ version = "3.0";
475
+ majorVersion = 3;
476
+ } else {
477
+ webOSVersion = 2;
478
+ version = "2.0";
479
+ majorVersion = 2;
480
+ }
481
+ } else {
482
+ version = "Unknown";
483
+ webOSVersion = void 0;
484
+ }
485
+ isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
486
+ } else if (/Tizen/i.test(ua)) {
487
+ name = "Samsung Tizen";
488
+ isSmartTV = true;
489
+ var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
490
+ version = match1 && match1[1] ? match1[1] : "Unknown";
491
+ if (version !== "Unknown") {
492
+ var parts1 = version.split(".");
493
+ majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
494
+ tizenVersion = majorVersion;
495
+ }
496
+ isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
497
+ } else if (/SMART-TV|SmartTV/i.test(ua)) {
498
+ name = "Smart TV";
499
+ isSmartTV = true;
500
+ isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
501
+ } else if (/NetCast/i.test(ua)) {
502
+ name = "LG NetCast";
503
+ isSmartTV = true;
504
+ isLegacyTV = true;
505
+ } else if (/BRAVIA/i.test(ua)) {
506
+ name = "Sony BRAVIA";
507
+ isSmartTV = true;
508
+ isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
509
+ } else {
510
+ if (chromeVersion > 0) {
511
+ name = "Chrome";
512
+ version = chromeVersion.toString();
513
+ majorVersion = chromeVersion;
514
+ if (chromeVersion < 50) {
515
+ supportsModernJS = false;
516
+ }
517
+ }
518
+ if (webkitVersion > 0 && webkitVersion < 600) {
519
+ supportsModernJS = false;
520
+ }
521
+ }
522
+ if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
523
+ supportsModernJS = false;
524
+ }
525
+ if (typeof URLSearchParams === "undefined") {
526
+ supportsModernJS = false;
527
+ }
528
+ return {
529
+ name: name,
530
+ version: version,
531
+ majorVersion: majorVersion,
532
+ isSmartTV: isSmartTV,
533
+ isLegacyTV: isLegacyTV,
534
+ platform: platform,
535
+ supportsModernJS: supportsModernJS,
536
+ webOSVersion: webOSVersion,
537
+ tizenVersion: tizenVersion,
538
+ chromeVersion: chromeVersionNum
539
+ };
540
+ }
541
+ function requiresMediaPipelineResetAfterAds() {
542
+ var _browser_tizenVersion;
543
+ var browser = detectBrowser();
544
+ return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
545
+ }
546
+ function getBrowserConfigOverrides() {
547
+ var browser = detectBrowser();
548
+ var overrides = {};
549
+ if (browser.isSmartTV) {
550
+ overrides.allowNativeHls = true;
551
+ overrides.pauseContentDuringAds = true;
552
+ }
553
+ return overrides;
554
+ }
555
+ function logBrowserInfo() {
556
+ var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
557
+ if (!debug) return;
558
+ var browser = detectBrowser();
559
+ console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
560
+ browser: "".concat(browser.name, " ").concat(browser.version),
561
+ platform: browser.platform,
562
+ isSmartTV: browser.isSmartTV,
563
+ isLegacyTV: browser.isLegacyTV,
564
+ supportsModernJS: browser.supportsModernJS
565
+ }, browser.webOSVersion !== void 0 ? {
566
+ webOSVersion: browser.webOSVersion
567
+ } : {}, browser.tizenVersion !== void 0 ? {
568
+ tizenVersion: browser.tizenVersion
569
+ } : {}, browser.chromeVersion !== void 0 ? {
570
+ chromeVersion: browser.chromeVersion
571
+ } : {}), {
572
+ userAgent: navigator.userAgent
573
+ }));
574
+ }
575
+ // src/sdk/hlsAdPlayer.ts
403
576
  var MAX_VAST_WRAPPER_DEPTH = 5;
404
577
  function createHlsAdPlayer(contentVideo, options) {
405
578
  var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
@@ -411,6 +584,7 @@ function createHlsAdPlayer(contentVideo, options) {
411
584
  var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
412
585
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
413
586
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
587
+ var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
414
588
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
415
589
  var adHls;
416
590
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -430,6 +604,8 @@ function createHlsAdPlayer(contentVideo, options) {
430
604
  var lastAdProgressTime = 0;
431
605
  var lastAdProgressPosition = 0;
432
606
  var sawDecodedVideoFrame = false;
607
+ var videoFrameCallbackHandle;
608
+ var pendingPlayPromise;
433
609
  var trackingFired = {
434
610
  impression: false,
435
611
  start: false,
@@ -1233,6 +1409,60 @@ function createHlsAdPlayer(contentVideo, options) {
1233
1409
  complete: false
1234
1410
  };
1235
1411
  }
1412
+ function isRvfcSupported(video) {
1413
+ return typeof video.requestVideoFrameCallback === "function";
1414
+ }
1415
+ function settlePendingPlay() {
1416
+ pendingPlayPromise = void 0;
1417
+ }
1418
+ function startAdPlayback(context) {
1419
+ if (!adVideoElement) return;
1420
+ var playPromise = adVideoElement.play();
1421
+ pendingPlayPromise = playPromise;
1422
+ playPromise.catch(function(error) {
1423
+ if (pendingPlayPromise !== playPromise) {
1424
+ return;
1425
+ }
1426
+ console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
1427
+ handleAdError();
1428
+ }).finally(function() {
1429
+ if (pendingPlayPromise === playPromise) {
1430
+ pendingPlayPromise = void 0;
1431
+ }
1432
+ });
1433
+ }
1434
+ function prepareVideoElementForNewSource() {
1435
+ settlePendingPlay();
1436
+ if (adHls) {
1437
+ adHls.destroy();
1438
+ adHls = void 0;
1439
+ }
1440
+ if (!adVideoElement) return;
1441
+ try {
1442
+ adVideoElement.pause();
1443
+ adVideoElement.removeAttribute("src");
1444
+ adVideoElement.load();
1445
+ } catch (error) {
1446
+ console.warn("[HlsAdPlayer] Error preparing ad video for new source:", error);
1447
+ }
1448
+ }
1449
+ function recreateAdVideoElement() {
1450
+ console.log("[HlsAdPlayer] Recreating ad video element (single-decoder platform)");
1451
+ teardownAdEventListeners();
1452
+ prepareVideoElementForNewSource();
1453
+ if (adVideoElement) {
1454
+ try {
1455
+ adVideoElement.remove();
1456
+ } catch (error) {
1457
+ console.warn("[HlsAdPlayer] Error removing ad video element:", error);
1458
+ }
1459
+ }
1460
+ adVideoElement = createAdVideoElement();
1461
+ adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.appendChild(adVideoElement);
1462
+ contentVideo[AD_VIDEO_PROP] = adVideoElement;
1463
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
1464
+ adVideoElement.muted = originalMutedState;
1465
+ }
1236
1466
  function loadCurrentAdMedia() {
1237
1467
  if (!adVideoElement || !currentAd) {
1238
1468
  throw new Error("No ad video element or ad to load");
@@ -1255,10 +1485,7 @@ function createHlsAdPlayer(contentVideo, options) {
1255
1485
  adHls.attachMedia(adVideoElement);
1256
1486
  adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
1257
1487
  console.log("[HlsAdPlayer] HLS manifest parsed, starting playback");
1258
- adVideoElement.play().catch(function(error) {
1259
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1260
- handleAdError();
1261
- });
1488
+ startAdPlayback("HLS ad playback");
1262
1489
  });
1263
1490
  adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
1264
1491
  console.error("[HlsAdPlayer] HLS error:", data);
@@ -1268,10 +1495,7 @@ function createHlsAdPlayer(contentVideo, options) {
1268
1495
  });
1269
1496
  } else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
1270
1497
  adVideoElement.src = mediaFile.url;
1271
- adVideoElement.play().catch(function(error) {
1272
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1273
- handleAdError();
1274
- });
1498
+ startAdPlayback("native HLS ad playback");
1275
1499
  } else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
1276
1500
  if (adHls) {
1277
1501
  adHls.destroy();
@@ -1279,10 +1503,7 @@ function createHlsAdPlayer(contentVideo, options) {
1279
1503
  }
1280
1504
  adVideoElement.src = mediaFile.url;
1281
1505
  adVideoElement.load();
1282
- adVideoElement.play().catch(function(error) {
1283
- console.error("[HlsAdPlayer] Error starting progressive ad playback:", error);
1284
- handleAdError();
1285
- });
1506
+ startAdPlayback("progressive ad playback");
1286
1507
  } else {
1287
1508
  throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
1288
1509
  }
@@ -1299,6 +1520,13 @@ function createHlsAdPlayer(contentVideo, options) {
1299
1520
  trackingFired.impression = true;
1300
1521
  console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
1301
1522
  }
1523
+ clearStallWatchdog();
1524
+ if (requiresMediaPipelineResetAfterAds()) {
1525
+ recreateAdVideoElement();
1526
+ setupAdEventListeners();
1527
+ } else {
1528
+ prepareVideoElementForNewSource();
1529
+ }
1302
1530
  try {
1303
1531
  loadCurrentAdMedia();
1304
1532
  emit("pod_ad_started", {
@@ -1316,6 +1544,7 @@ function createHlsAdPlayer(contentVideo, options) {
1316
1544
  clearInterval(stallWatchdogId);
1317
1545
  stallWatchdogId = void 0;
1318
1546
  }
1547
+ cancelVideoFrameProbe();
1319
1548
  }
1320
1549
  function noteAdProgress() {
1321
1550
  lastAdProgressTime = Date.now();
@@ -1351,6 +1580,39 @@ function createHlsAdPlayer(contentVideo, options) {
1351
1580
  }
1352
1581
  return void 0;
1353
1582
  }
1583
+ function isFrameCounterReliable() {
1584
+ return contentVideo[FRAME_COUNTER_RELIABLE_PROP] === true;
1585
+ }
1586
+ function markFrameCounterReliable() {
1587
+ contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1588
+ }
1589
+ function cancelVideoFrameProbe() {
1590
+ if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1591
+ try {
1592
+ adVideoElement.cancelVideoFrameCallback(videoFrameCallbackHandle);
1593
+ } catch (error) {
1594
+ console.warn("[HlsAdPlayer] Error cancelling video frame callback:", error);
1595
+ }
1596
+ }
1597
+ videoFrameCallbackHandle = void 0;
1598
+ }
1599
+ function startVideoFrameProbe() {
1600
+ cancelVideoFrameProbe();
1601
+ if (!adVideoElement) return;
1602
+ var rvfc = adVideoElement.requestVideoFrameCallback;
1603
+ if (typeof rvfc !== "function") return;
1604
+ var onPresentedFrame = function onPresentedFrame() {
1605
+ videoFrameCallbackHandle = void 0;
1606
+ if (!adPlaying) return;
1607
+ sawDecodedVideoFrame = true;
1608
+ };
1609
+ try {
1610
+ videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
1611
+ } catch (error) {
1612
+ console.warn("[HlsAdPlayer] Error requesting video frame callback:", error);
1613
+ videoFrameCallbackHandle = void 0;
1614
+ }
1615
+ }
1354
1616
  function handleVideoDecodeFailure() {
1355
1617
  console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
1356
1618
  clearStallWatchdog();
@@ -1366,6 +1628,7 @@ function createHlsAdPlayer(contentVideo, options) {
1366
1628
  clearStallWatchdog();
1367
1629
  noteAdProgress();
1368
1630
  sawDecodedVideoFrame = false;
1631
+ startVideoFrameProbe();
1369
1632
  stallWatchdogId = window.setInterval(function() {
1370
1633
  if (!adPlaying || !adVideoElement) {
1371
1634
  return;
@@ -1374,9 +1637,17 @@ function createHlsAdPlayer(contentVideo, options) {
1374
1637
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1375
1638
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1376
1639
  sawDecodedVideoFrame = true;
1377
- } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1378
- handleVideoDecodeFailure();
1379
- return;
1640
+ markFrameCounterReliable();
1641
+ } else if (adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1642
+ var timeAdvancing = adVideoElement.currentTime > lastAdProgressPosition + 0.05;
1643
+ if (isRvfcSupported(adVideoElement) && timeAdvancing) {
1644
+ handleVideoDecodeFailure();
1645
+ return;
1646
+ }
1647
+ if (decodedFrames === 0 && timeAdvancing && isFrameCounterReliable()) {
1648
+ handleVideoDecodeFailure();
1649
+ return;
1650
+ }
1380
1651
  }
1381
1652
  }
1382
1653
  if (adVideoElement.currentTime > lastAdProgressPosition + 0.05) {
@@ -1393,19 +1664,7 @@ function createHlsAdPlayer(contentVideo, options) {
1393
1664
  }, STALL_CHECK_INTERVAL_MS);
1394
1665
  }
1395
1666
  function releaseAdDecoder() {
1396
- if (adHls) {
1397
- adHls.destroy();
1398
- adHls = void 0;
1399
- }
1400
- if (adVideoElement) {
1401
- try {
1402
- adVideoElement.pause();
1403
- adVideoElement.removeAttribute("src");
1404
- adVideoElement.load();
1405
- } catch (error) {
1406
- console.warn("[HlsAdPlayer] Error releasing ad decoder:", error);
1407
- }
1408
- }
1667
+ prepareVideoElementForNewSource();
1409
1668
  if (adContainerEl) {
1410
1669
  adContainerEl.style.display = "none";
1411
1670
  adContainerEl.style.pointerEvents = "none";
@@ -3976,178 +4235,6 @@ function fetchConsentSignals() {
3976
4235
  return signals;
3977
4236
  });
3978
4237
  }
3979
- // src/utils/browserCompat.ts
3980
- function getChromeVersion(ua) {
3981
- var match = ua.match(/Chrome\/(\d+)/);
3982
- return match && match[1] ? parseInt(match[1], 10) : 0;
3983
- }
3984
- function getWebKitVersion(ua) {
3985
- var match = ua.match(/AppleWebKit\/(\d+)/);
3986
- return match && match[1] ? parseInt(match[1], 10) : 0;
3987
- }
3988
- function getPlatform() {
3989
- var _navigator_userAgentData;
3990
- if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
3991
- return navigator.userAgentData.platform;
3992
- }
3993
- var ua = navigator.userAgent;
3994
- if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
3995
- return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
3996
- }
3997
- if (/Win/i.test(ua)) {
3998
- return "Win32";
3999
- }
4000
- if (/Linux/i.test(ua)) {
4001
- return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
4002
- }
4003
- if (/CrOS/i.test(ua)) {
4004
- return "CrOS";
4005
- }
4006
- return navigator.platform || "Unknown";
4007
- }
4008
- function detectBrowser() {
4009
- var ua = navigator.userAgent;
4010
- var platform = getPlatform();
4011
- var name = "Unknown";
4012
- var version = "0";
4013
- var majorVersion = 0;
4014
- var isSmartTV = false;
4015
- var isLegacyTV = false;
4016
- var supportsModernJS = true;
4017
- var webOSVersion;
4018
- var tizenVersion;
4019
- var chromeVersionNum;
4020
- var chromeVersion = getChromeVersion(ua);
4021
- var webkitVersion = getWebKitVersion(ua);
4022
- chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
4023
- if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
4024
- name = "LG WebOS";
4025
- isSmartTV = true;
4026
- var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
4027
- if (!match || !match[1]) {
4028
- match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
4029
- }
4030
- if (match && match[1]) {
4031
- version = match[1];
4032
- var parts = version.split(".");
4033
- majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
4034
- webOSVersion = majorVersion;
4035
- } else if (chromeVersion > 0) {
4036
- if (chromeVersion >= 79) {
4037
- webOSVersion = 6;
4038
- version = "6.0";
4039
- majorVersion = 6;
4040
- } else if (chromeVersion >= 68) {
4041
- webOSVersion = 5;
4042
- version = "5.0";
4043
- majorVersion = 5;
4044
- } else if (chromeVersion >= 53) {
4045
- webOSVersion = 4;
4046
- version = "4.0";
4047
- majorVersion = 4;
4048
- } else if (chromeVersion >= 38) {
4049
- webOSVersion = 3;
4050
- version = "3.0";
4051
- majorVersion = 3;
4052
- } else {
4053
- webOSVersion = 2;
4054
- version = "2.0";
4055
- majorVersion = 2;
4056
- }
4057
- } else {
4058
- version = "Unknown";
4059
- webOSVersion = void 0;
4060
- }
4061
- isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
4062
- } else if (/Tizen/i.test(ua)) {
4063
- name = "Samsung Tizen";
4064
- isSmartTV = true;
4065
- var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
4066
- version = match1 && match1[1] ? match1[1] : "Unknown";
4067
- if (version !== "Unknown") {
4068
- var parts1 = version.split(".");
4069
- majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
4070
- tizenVersion = majorVersion;
4071
- }
4072
- isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
4073
- } else if (/SMART-TV|SmartTV/i.test(ua)) {
4074
- name = "Smart TV";
4075
- isSmartTV = true;
4076
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4077
- } else if (/NetCast/i.test(ua)) {
4078
- name = "LG NetCast";
4079
- isSmartTV = true;
4080
- isLegacyTV = true;
4081
- } else if (/BRAVIA/i.test(ua)) {
4082
- name = "Sony BRAVIA";
4083
- isSmartTV = true;
4084
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4085
- } else {
4086
- if (chromeVersion > 0) {
4087
- name = "Chrome";
4088
- version = chromeVersion.toString();
4089
- majorVersion = chromeVersion;
4090
- if (chromeVersion < 50) {
4091
- supportsModernJS = false;
4092
- }
4093
- }
4094
- if (webkitVersion > 0 && webkitVersion < 600) {
4095
- supportsModernJS = false;
4096
- }
4097
- }
4098
- if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
4099
- supportsModernJS = false;
4100
- }
4101
- if (typeof URLSearchParams === "undefined") {
4102
- supportsModernJS = false;
4103
- }
4104
- return {
4105
- name: name,
4106
- version: version,
4107
- majorVersion: majorVersion,
4108
- isSmartTV: isSmartTV,
4109
- isLegacyTV: isLegacyTV,
4110
- platform: platform,
4111
- supportsModernJS: supportsModernJS,
4112
- webOSVersion: webOSVersion,
4113
- tizenVersion: tizenVersion,
4114
- chromeVersion: chromeVersionNum
4115
- };
4116
- }
4117
- function requiresMediaPipelineResetAfterAds() {
4118
- var _browser_tizenVersion;
4119
- var browser = detectBrowser();
4120
- return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
4121
- }
4122
- function getBrowserConfigOverrides() {
4123
- var browser = detectBrowser();
4124
- var overrides = {};
4125
- if (browser.isSmartTV) {
4126
- overrides.allowNativeHls = true;
4127
- overrides.pauseContentDuringAds = true;
4128
- }
4129
- return overrides;
4130
- }
4131
- function logBrowserInfo() {
4132
- var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
4133
- if (!debug) return;
4134
- var browser = detectBrowser();
4135
- console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
4136
- browser: "".concat(browser.name, " ").concat(browser.version),
4137
- platform: browser.platform,
4138
- isSmartTV: browser.isSmartTV,
4139
- isLegacyTV: browser.isLegacyTV,
4140
- supportsModernJS: browser.supportsModernJS
4141
- }, browser.webOSVersion !== void 0 ? {
4142
- webOSVersion: browser.webOSVersion
4143
- } : {}, browser.tizenVersion !== void 0 ? {
4144
- tizenVersion: browser.tizenVersion
4145
- } : {}, browser.chromeVersion !== void 0 ? {
4146
- chromeVersion: browser.chromeVersion
4147
- } : {}), {
4148
- userAgent: navigator.userAgent
4149
- }));
4150
- }
4151
4238
  // src/player/Scte35Parser.ts
4152
4239
  function parseCueOutDuration(value) {
4153
4240
  var num = parseFloat(value.trim());
@@ -6219,17 +6306,17 @@ var AdTimingService = /*#__PURE__*/ function() {
6219
6306
  {
6220
6307
  key: "logAdState",
6221
6308
  value: function logAdState(event) {
6222
- 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;
6223
- var _ref;
6309
+ var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6224
6310
  if (!this.debug) {
6225
6311
  return;
6226
6312
  }
6313
+ var _this_callbacks_getAdState = this.callbacks.getAdState(), inAdBreak = _this_callbacks_getAdState.inAdBreak, showAds = _this_callbacks_getAdState.showAds, adPlaying = _this_callbacks_getAdState.adPlaying;
6227
6314
  console.log("[StormcloudVideoPlayer][AdState]", _object_spread({
6228
6315
  event: event,
6229
6316
  timestamp: /* @__PURE__ */ new Date().toISOString(),
6230
- showAds: showAds !== null && showAds !== void 0 ? showAds : false,
6231
- adPlaying: (_ref = adPlayer === null || adPlayer === void 0 ? void 0 : adPlayer.isAdPlaying()) !== null && _ref !== void 0 ? _ref : false,
6232
- inAdBreak: inAdBreak !== null && inAdBreak !== void 0 ? inAdBreak : false,
6317
+ showAds: showAds,
6318
+ adPlaying: adPlaying,
6319
+ inAdBreak: inAdBreak,
6233
6320
  activeAdRequestToken: this.activeAdRequestToken
6234
6321
  }, extra));
6235
6322
  }
@@ -8579,6 +8666,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8579
8666
  },
8580
8667
  onFailsafeTimeout: function onFailsafeTimeout() {
8581
8668
  return _this.adBreak.handleAdFailure();
8669
+ },
8670
+ getAdState: function getAdState() {
8671
+ return {
8672
+ inAdBreak: _this.adBreak.inAdBreak,
8673
+ showAds: _this.adBreak.showAds,
8674
+ adPlaying: _this.adPlayer.isAdPlaying()
8675
+ };
8582
8676
  }
8583
8677
  });
8584
8678
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);