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.
@@ -386,6 +386,179 @@ module.exports = __toCommonJS(StormcloudVideoPlayer_exports);
386
386
  var import_react = __toESM(require("react"), 1);
387
387
  // src/sdk/hlsAdPlayer.ts
388
388
  var import_hls = __toESM(require("hls.js"), 1);
389
+ // src/utils/browserCompat.ts
390
+ function getChromeVersion(ua) {
391
+ var match = ua.match(/Chrome\/(\d+)/);
392
+ return match && match[1] ? parseInt(match[1], 10) : 0;
393
+ }
394
+ function getWebKitVersion(ua) {
395
+ var match = ua.match(/AppleWebKit\/(\d+)/);
396
+ return match && match[1] ? parseInt(match[1], 10) : 0;
397
+ }
398
+ function getPlatform() {
399
+ var _navigator_userAgentData;
400
+ if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
401
+ return navigator.userAgentData.platform;
402
+ }
403
+ var ua = navigator.userAgent;
404
+ if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
405
+ return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
406
+ }
407
+ if (/Win/i.test(ua)) {
408
+ return "Win32";
409
+ }
410
+ if (/Linux/i.test(ua)) {
411
+ return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
412
+ }
413
+ if (/CrOS/i.test(ua)) {
414
+ return "CrOS";
415
+ }
416
+ return navigator.platform || "Unknown";
417
+ }
418
+ function detectBrowser() {
419
+ var ua = navigator.userAgent;
420
+ var platform = getPlatform();
421
+ var name = "Unknown";
422
+ var version = "0";
423
+ var majorVersion = 0;
424
+ var isSmartTV = false;
425
+ var isLegacyTV = false;
426
+ var supportsModernJS = true;
427
+ var webOSVersion;
428
+ var tizenVersion;
429
+ var chromeVersionNum;
430
+ var chromeVersion = getChromeVersion(ua);
431
+ var webkitVersion = getWebKitVersion(ua);
432
+ chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
433
+ if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
434
+ name = "LG WebOS";
435
+ isSmartTV = true;
436
+ var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
437
+ if (!match || !match[1]) {
438
+ match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
439
+ }
440
+ if (match && match[1]) {
441
+ version = match[1];
442
+ var parts = version.split(".");
443
+ majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
444
+ webOSVersion = majorVersion;
445
+ } else if (chromeVersion > 0) {
446
+ if (chromeVersion >= 79) {
447
+ webOSVersion = 6;
448
+ version = "6.0";
449
+ majorVersion = 6;
450
+ } else if (chromeVersion >= 68) {
451
+ webOSVersion = 5;
452
+ version = "5.0";
453
+ majorVersion = 5;
454
+ } else if (chromeVersion >= 53) {
455
+ webOSVersion = 4;
456
+ version = "4.0";
457
+ majorVersion = 4;
458
+ } else if (chromeVersion >= 38) {
459
+ webOSVersion = 3;
460
+ version = "3.0";
461
+ majorVersion = 3;
462
+ } else {
463
+ webOSVersion = 2;
464
+ version = "2.0";
465
+ majorVersion = 2;
466
+ }
467
+ } else {
468
+ version = "Unknown";
469
+ webOSVersion = void 0;
470
+ }
471
+ isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
472
+ } else if (/Tizen/i.test(ua)) {
473
+ name = "Samsung Tizen";
474
+ isSmartTV = true;
475
+ var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
476
+ version = match1 && match1[1] ? match1[1] : "Unknown";
477
+ if (version !== "Unknown") {
478
+ var parts1 = version.split(".");
479
+ majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
480
+ tizenVersion = majorVersion;
481
+ }
482
+ isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
483
+ } else if (/SMART-TV|SmartTV/i.test(ua)) {
484
+ name = "Smart TV";
485
+ isSmartTV = true;
486
+ isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
487
+ } else if (/NetCast/i.test(ua)) {
488
+ name = "LG NetCast";
489
+ isSmartTV = true;
490
+ isLegacyTV = true;
491
+ } else if (/BRAVIA/i.test(ua)) {
492
+ name = "Sony BRAVIA";
493
+ isSmartTV = true;
494
+ isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
495
+ } else {
496
+ if (chromeVersion > 0) {
497
+ name = "Chrome";
498
+ version = chromeVersion.toString();
499
+ majorVersion = chromeVersion;
500
+ if (chromeVersion < 50) {
501
+ supportsModernJS = false;
502
+ }
503
+ }
504
+ if (webkitVersion > 0 && webkitVersion < 600) {
505
+ supportsModernJS = false;
506
+ }
507
+ }
508
+ if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
509
+ supportsModernJS = false;
510
+ }
511
+ if (typeof URLSearchParams === "undefined") {
512
+ supportsModernJS = false;
513
+ }
514
+ return {
515
+ name: name,
516
+ version: version,
517
+ majorVersion: majorVersion,
518
+ isSmartTV: isSmartTV,
519
+ isLegacyTV: isLegacyTV,
520
+ platform: platform,
521
+ supportsModernJS: supportsModernJS,
522
+ webOSVersion: webOSVersion,
523
+ tizenVersion: tizenVersion,
524
+ chromeVersion: chromeVersionNum
525
+ };
526
+ }
527
+ function requiresMediaPipelineResetAfterAds() {
528
+ var _browser_tizenVersion;
529
+ var browser = detectBrowser();
530
+ return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
531
+ }
532
+ function getBrowserConfigOverrides() {
533
+ var browser = detectBrowser();
534
+ var overrides = {};
535
+ if (browser.isSmartTV) {
536
+ overrides.allowNativeHls = true;
537
+ overrides.pauseContentDuringAds = true;
538
+ }
539
+ return overrides;
540
+ }
541
+ function logBrowserInfo() {
542
+ var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
543
+ if (!debug) return;
544
+ var browser = detectBrowser();
545
+ console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
546
+ browser: "".concat(browser.name, " ").concat(browser.version),
547
+ platform: browser.platform,
548
+ isSmartTV: browser.isSmartTV,
549
+ isLegacyTV: browser.isLegacyTV,
550
+ supportsModernJS: browser.supportsModernJS
551
+ }, browser.webOSVersion !== void 0 ? {
552
+ webOSVersion: browser.webOSVersion
553
+ } : {}, browser.tizenVersion !== void 0 ? {
554
+ tizenVersion: browser.tizenVersion
555
+ } : {}, browser.chromeVersion !== void 0 ? {
556
+ chromeVersion: browser.chromeVersion
557
+ } : {}), {
558
+ userAgent: navigator.userAgent
559
+ }));
560
+ }
561
+ // src/sdk/hlsAdPlayer.ts
389
562
  var MAX_VAST_WRAPPER_DEPTH = 5;
390
563
  function createHlsAdPlayer(contentVideo, options) {
391
564
  var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
@@ -397,6 +570,7 @@ function createHlsAdPlayer(contentVideo, options) {
397
570
  var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
398
571
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
399
572
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
573
+ var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
400
574
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
401
575
  var adHls;
402
576
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -416,6 +590,8 @@ function createHlsAdPlayer(contentVideo, options) {
416
590
  var lastAdProgressTime = 0;
417
591
  var lastAdProgressPosition = 0;
418
592
  var sawDecodedVideoFrame = false;
593
+ var videoFrameCallbackHandle;
594
+ var pendingPlayPromise;
419
595
  var trackingFired = {
420
596
  impression: false,
421
597
  start: false,
@@ -1219,6 +1395,60 @@ function createHlsAdPlayer(contentVideo, options) {
1219
1395
  complete: false
1220
1396
  };
1221
1397
  }
1398
+ function isRvfcSupported(video) {
1399
+ return typeof video.requestVideoFrameCallback === "function";
1400
+ }
1401
+ function settlePendingPlay() {
1402
+ pendingPlayPromise = void 0;
1403
+ }
1404
+ function startAdPlayback(context) {
1405
+ if (!adVideoElement) return;
1406
+ var playPromise = adVideoElement.play();
1407
+ pendingPlayPromise = playPromise;
1408
+ playPromise.catch(function(error) {
1409
+ if (pendingPlayPromise !== playPromise) {
1410
+ return;
1411
+ }
1412
+ console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
1413
+ handleAdError();
1414
+ }).finally(function() {
1415
+ if (pendingPlayPromise === playPromise) {
1416
+ pendingPlayPromise = void 0;
1417
+ }
1418
+ });
1419
+ }
1420
+ function prepareVideoElementForNewSource() {
1421
+ settlePendingPlay();
1422
+ if (adHls) {
1423
+ adHls.destroy();
1424
+ adHls = void 0;
1425
+ }
1426
+ if (!adVideoElement) return;
1427
+ try {
1428
+ adVideoElement.pause();
1429
+ adVideoElement.removeAttribute("src");
1430
+ adVideoElement.load();
1431
+ } catch (error) {
1432
+ console.warn("[HlsAdPlayer] Error preparing ad video for new source:", error);
1433
+ }
1434
+ }
1435
+ function recreateAdVideoElement() {
1436
+ console.log("[HlsAdPlayer] Recreating ad video element (single-decoder platform)");
1437
+ teardownAdEventListeners();
1438
+ prepareVideoElementForNewSource();
1439
+ if (adVideoElement) {
1440
+ try {
1441
+ adVideoElement.remove();
1442
+ } catch (error) {
1443
+ console.warn("[HlsAdPlayer] Error removing ad video element:", error);
1444
+ }
1445
+ }
1446
+ adVideoElement = createAdVideoElement();
1447
+ adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.appendChild(adVideoElement);
1448
+ contentVideo[AD_VIDEO_PROP] = adVideoElement;
1449
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
1450
+ adVideoElement.muted = originalMutedState;
1451
+ }
1222
1452
  function loadCurrentAdMedia() {
1223
1453
  if (!adVideoElement || !currentAd) {
1224
1454
  throw new Error("No ad video element or ad to load");
@@ -1241,10 +1471,7 @@ function createHlsAdPlayer(contentVideo, options) {
1241
1471
  adHls.attachMedia(adVideoElement);
1242
1472
  adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
1243
1473
  console.log("[HlsAdPlayer] HLS manifest parsed, starting playback");
1244
- adVideoElement.play().catch(function(error) {
1245
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1246
- handleAdError();
1247
- });
1474
+ startAdPlayback("HLS ad playback");
1248
1475
  });
1249
1476
  adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
1250
1477
  console.error("[HlsAdPlayer] HLS error:", data);
@@ -1254,10 +1481,7 @@ function createHlsAdPlayer(contentVideo, options) {
1254
1481
  });
1255
1482
  } else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
1256
1483
  adVideoElement.src = mediaFile.url;
1257
- adVideoElement.play().catch(function(error) {
1258
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1259
- handleAdError();
1260
- });
1484
+ startAdPlayback("native HLS ad playback");
1261
1485
  } else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
1262
1486
  if (adHls) {
1263
1487
  adHls.destroy();
@@ -1265,10 +1489,7 @@ function createHlsAdPlayer(contentVideo, options) {
1265
1489
  }
1266
1490
  adVideoElement.src = mediaFile.url;
1267
1491
  adVideoElement.load();
1268
- adVideoElement.play().catch(function(error) {
1269
- console.error("[HlsAdPlayer] Error starting progressive ad playback:", error);
1270
- handleAdError();
1271
- });
1492
+ startAdPlayback("progressive ad playback");
1272
1493
  } else {
1273
1494
  throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
1274
1495
  }
@@ -1285,6 +1506,13 @@ function createHlsAdPlayer(contentVideo, options) {
1285
1506
  trackingFired.impression = true;
1286
1507
  console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
1287
1508
  }
1509
+ clearStallWatchdog();
1510
+ if (requiresMediaPipelineResetAfterAds()) {
1511
+ recreateAdVideoElement();
1512
+ setupAdEventListeners();
1513
+ } else {
1514
+ prepareVideoElementForNewSource();
1515
+ }
1288
1516
  try {
1289
1517
  loadCurrentAdMedia();
1290
1518
  emit("pod_ad_started", {
@@ -1302,6 +1530,7 @@ function createHlsAdPlayer(contentVideo, options) {
1302
1530
  clearInterval(stallWatchdogId);
1303
1531
  stallWatchdogId = void 0;
1304
1532
  }
1533
+ cancelVideoFrameProbe();
1305
1534
  }
1306
1535
  function noteAdProgress() {
1307
1536
  lastAdProgressTime = Date.now();
@@ -1337,6 +1566,39 @@ function createHlsAdPlayer(contentVideo, options) {
1337
1566
  }
1338
1567
  return void 0;
1339
1568
  }
1569
+ function isFrameCounterReliable() {
1570
+ return contentVideo[FRAME_COUNTER_RELIABLE_PROP] === true;
1571
+ }
1572
+ function markFrameCounterReliable() {
1573
+ contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1574
+ }
1575
+ function cancelVideoFrameProbe() {
1576
+ if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1577
+ try {
1578
+ adVideoElement.cancelVideoFrameCallback(videoFrameCallbackHandle);
1579
+ } catch (error) {
1580
+ console.warn("[HlsAdPlayer] Error cancelling video frame callback:", error);
1581
+ }
1582
+ }
1583
+ videoFrameCallbackHandle = void 0;
1584
+ }
1585
+ function startVideoFrameProbe() {
1586
+ cancelVideoFrameProbe();
1587
+ if (!adVideoElement) return;
1588
+ var rvfc = adVideoElement.requestVideoFrameCallback;
1589
+ if (typeof rvfc !== "function") return;
1590
+ var onPresentedFrame = function onPresentedFrame() {
1591
+ videoFrameCallbackHandle = void 0;
1592
+ if (!adPlaying) return;
1593
+ sawDecodedVideoFrame = true;
1594
+ };
1595
+ try {
1596
+ videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
1597
+ } catch (error) {
1598
+ console.warn("[HlsAdPlayer] Error requesting video frame callback:", error);
1599
+ videoFrameCallbackHandle = void 0;
1600
+ }
1601
+ }
1340
1602
  function handleVideoDecodeFailure() {
1341
1603
  console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
1342
1604
  clearStallWatchdog();
@@ -1352,6 +1614,7 @@ function createHlsAdPlayer(contentVideo, options) {
1352
1614
  clearStallWatchdog();
1353
1615
  noteAdProgress();
1354
1616
  sawDecodedVideoFrame = false;
1617
+ startVideoFrameProbe();
1355
1618
  stallWatchdogId = window.setInterval(function() {
1356
1619
  if (!adPlaying || !adVideoElement) {
1357
1620
  return;
@@ -1360,9 +1623,17 @@ function createHlsAdPlayer(contentVideo, options) {
1360
1623
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1361
1624
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1362
1625
  sawDecodedVideoFrame = true;
1363
- } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1364
- handleVideoDecodeFailure();
1365
- return;
1626
+ markFrameCounterReliable();
1627
+ } else if (adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1628
+ var timeAdvancing = adVideoElement.currentTime > lastAdProgressPosition + 0.05;
1629
+ if (isRvfcSupported(adVideoElement) && timeAdvancing) {
1630
+ handleVideoDecodeFailure();
1631
+ return;
1632
+ }
1633
+ if (decodedFrames === 0 && timeAdvancing && isFrameCounterReliable()) {
1634
+ handleVideoDecodeFailure();
1635
+ return;
1636
+ }
1366
1637
  }
1367
1638
  }
1368
1639
  if (adVideoElement.currentTime > lastAdProgressPosition + 0.05) {
@@ -1379,19 +1650,7 @@ function createHlsAdPlayer(contentVideo, options) {
1379
1650
  }, STALL_CHECK_INTERVAL_MS);
1380
1651
  }
1381
1652
  function releaseAdDecoder() {
1382
- if (adHls) {
1383
- adHls.destroy();
1384
- adHls = void 0;
1385
- }
1386
- if (adVideoElement) {
1387
- try {
1388
- adVideoElement.pause();
1389
- adVideoElement.removeAttribute("src");
1390
- adVideoElement.load();
1391
- } catch (error) {
1392
- console.warn("[HlsAdPlayer] Error releasing ad decoder:", error);
1393
- }
1394
- }
1653
+ prepareVideoElementForNewSource();
1395
1654
  if (adContainerEl) {
1396
1655
  adContainerEl.style.display = "none";
1397
1656
  adContainerEl.style.pointerEvents = "none";
@@ -3962,178 +4221,6 @@ function fetchConsentSignals() {
3962
4221
  return signals;
3963
4222
  });
3964
4223
  }
3965
- // src/utils/browserCompat.ts
3966
- function getChromeVersion(ua) {
3967
- var match = ua.match(/Chrome\/(\d+)/);
3968
- return match && match[1] ? parseInt(match[1], 10) : 0;
3969
- }
3970
- function getWebKitVersion(ua) {
3971
- var match = ua.match(/AppleWebKit\/(\d+)/);
3972
- return match && match[1] ? parseInt(match[1], 10) : 0;
3973
- }
3974
- function getPlatform() {
3975
- var _navigator_userAgentData;
3976
- if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
3977
- return navigator.userAgentData.platform;
3978
- }
3979
- var ua = navigator.userAgent;
3980
- if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
3981
- return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
3982
- }
3983
- if (/Win/i.test(ua)) {
3984
- return "Win32";
3985
- }
3986
- if (/Linux/i.test(ua)) {
3987
- return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
3988
- }
3989
- if (/CrOS/i.test(ua)) {
3990
- return "CrOS";
3991
- }
3992
- return navigator.platform || "Unknown";
3993
- }
3994
- function detectBrowser() {
3995
- var ua = navigator.userAgent;
3996
- var platform = getPlatform();
3997
- var name = "Unknown";
3998
- var version = "0";
3999
- var majorVersion = 0;
4000
- var isSmartTV = false;
4001
- var isLegacyTV = false;
4002
- var supportsModernJS = true;
4003
- var webOSVersion;
4004
- var tizenVersion;
4005
- var chromeVersionNum;
4006
- var chromeVersion = getChromeVersion(ua);
4007
- var webkitVersion = getWebKitVersion(ua);
4008
- chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
4009
- if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
4010
- name = "LG WebOS";
4011
- isSmartTV = true;
4012
- var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
4013
- if (!match || !match[1]) {
4014
- match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
4015
- }
4016
- if (match && match[1]) {
4017
- version = match[1];
4018
- var parts = version.split(".");
4019
- majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
4020
- webOSVersion = majorVersion;
4021
- } else if (chromeVersion > 0) {
4022
- if (chromeVersion >= 79) {
4023
- webOSVersion = 6;
4024
- version = "6.0";
4025
- majorVersion = 6;
4026
- } else if (chromeVersion >= 68) {
4027
- webOSVersion = 5;
4028
- version = "5.0";
4029
- majorVersion = 5;
4030
- } else if (chromeVersion >= 53) {
4031
- webOSVersion = 4;
4032
- version = "4.0";
4033
- majorVersion = 4;
4034
- } else if (chromeVersion >= 38) {
4035
- webOSVersion = 3;
4036
- version = "3.0";
4037
- majorVersion = 3;
4038
- } else {
4039
- webOSVersion = 2;
4040
- version = "2.0";
4041
- majorVersion = 2;
4042
- }
4043
- } else {
4044
- version = "Unknown";
4045
- webOSVersion = void 0;
4046
- }
4047
- isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
4048
- } else if (/Tizen/i.test(ua)) {
4049
- name = "Samsung Tizen";
4050
- isSmartTV = true;
4051
- var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
4052
- version = match1 && match1[1] ? match1[1] : "Unknown";
4053
- if (version !== "Unknown") {
4054
- var parts1 = version.split(".");
4055
- majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
4056
- tizenVersion = majorVersion;
4057
- }
4058
- isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
4059
- } else if (/SMART-TV|SmartTV/i.test(ua)) {
4060
- name = "Smart TV";
4061
- isSmartTV = true;
4062
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4063
- } else if (/NetCast/i.test(ua)) {
4064
- name = "LG NetCast";
4065
- isSmartTV = true;
4066
- isLegacyTV = true;
4067
- } else if (/BRAVIA/i.test(ua)) {
4068
- name = "Sony BRAVIA";
4069
- isSmartTV = true;
4070
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4071
- } else {
4072
- if (chromeVersion > 0) {
4073
- name = "Chrome";
4074
- version = chromeVersion.toString();
4075
- majorVersion = chromeVersion;
4076
- if (chromeVersion < 50) {
4077
- supportsModernJS = false;
4078
- }
4079
- }
4080
- if (webkitVersion > 0 && webkitVersion < 600) {
4081
- supportsModernJS = false;
4082
- }
4083
- }
4084
- if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
4085
- supportsModernJS = false;
4086
- }
4087
- if (typeof URLSearchParams === "undefined") {
4088
- supportsModernJS = false;
4089
- }
4090
- return {
4091
- name: name,
4092
- version: version,
4093
- majorVersion: majorVersion,
4094
- isSmartTV: isSmartTV,
4095
- isLegacyTV: isLegacyTV,
4096
- platform: platform,
4097
- supportsModernJS: supportsModernJS,
4098
- webOSVersion: webOSVersion,
4099
- tizenVersion: tizenVersion,
4100
- chromeVersion: chromeVersionNum
4101
- };
4102
- }
4103
- function requiresMediaPipelineResetAfterAds() {
4104
- var _browser_tizenVersion;
4105
- var browser = detectBrowser();
4106
- return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
4107
- }
4108
- function getBrowserConfigOverrides() {
4109
- var browser = detectBrowser();
4110
- var overrides = {};
4111
- if (browser.isSmartTV) {
4112
- overrides.allowNativeHls = true;
4113
- overrides.pauseContentDuringAds = true;
4114
- }
4115
- return overrides;
4116
- }
4117
- function logBrowserInfo() {
4118
- var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
4119
- if (!debug) return;
4120
- var browser = detectBrowser();
4121
- console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
4122
- browser: "".concat(browser.name, " ").concat(browser.version),
4123
- platform: browser.platform,
4124
- isSmartTV: browser.isSmartTV,
4125
- isLegacyTV: browser.isLegacyTV,
4126
- supportsModernJS: browser.supportsModernJS
4127
- }, browser.webOSVersion !== void 0 ? {
4128
- webOSVersion: browser.webOSVersion
4129
- } : {}, browser.tizenVersion !== void 0 ? {
4130
- tizenVersion: browser.tizenVersion
4131
- } : {}, browser.chromeVersion !== void 0 ? {
4132
- chromeVersion: browser.chromeVersion
4133
- } : {}), {
4134
- userAgent: navigator.userAgent
4135
- }));
4136
- }
4137
4224
  // src/player/Scte35Parser.ts
4138
4225
  function parseCueOutDuration(value) {
4139
4226
  var num = parseFloat(value.trim());
@@ -6205,17 +6292,17 @@ var AdTimingService = /*#__PURE__*/ function() {
6205
6292
  {
6206
6293
  key: "logAdState",
6207
6294
  value: function logAdState(event) {
6208
- 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;
6209
- var _ref;
6295
+ var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6210
6296
  if (!this.debug) {
6211
6297
  return;
6212
6298
  }
6299
+ var _this_callbacks_getAdState = this.callbacks.getAdState(), inAdBreak = _this_callbacks_getAdState.inAdBreak, showAds = _this_callbacks_getAdState.showAds, adPlaying = _this_callbacks_getAdState.adPlaying;
6213
6300
  console.log("[StormcloudVideoPlayer][AdState]", _object_spread({
6214
6301
  event: event,
6215
6302
  timestamp: /* @__PURE__ */ new Date().toISOString(),
6216
- showAds: showAds !== null && showAds !== void 0 ? showAds : false,
6217
- adPlaying: (_ref = adPlayer === null || adPlayer === void 0 ? void 0 : adPlayer.isAdPlaying()) !== null && _ref !== void 0 ? _ref : false,
6218
- inAdBreak: inAdBreak !== null && inAdBreak !== void 0 ? inAdBreak : false,
6303
+ showAds: showAds,
6304
+ adPlaying: adPlaying,
6305
+ inAdBreak: inAdBreak,
6219
6306
  activeAdRequestToken: this.activeAdRequestToken
6220
6307
  }, extra));
6221
6308
  }
@@ -8565,6 +8652,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8565
8652
  },
8566
8653
  onFailsafeTimeout: function onFailsafeTimeout() {
8567
8654
  return _this.adBreak.handleAdFailure();
8655
+ },
8656
+ getAdState: function getAdState() {
8657
+ return {
8658
+ inAdBreak: _this.adBreak.inAdBreak,
8659
+ showAds: _this.adBreak.showAds,
8660
+ adPlaying: _this.adPlayer.isAdPlaying()
8661
+ };
8568
8662
  }
8569
8663
  });
8570
8664
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);