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.
@@ -349,6 +349,179 @@ __export(StormcloudVideoPlayer_exports, {
349
349
  module.exports = __toCommonJS(StormcloudVideoPlayer_exports);
350
350
  // src/sdk/hlsAdPlayer.ts
351
351
  var import_hls = __toESM(require("hls.js"), 1);
352
+ // src/utils/browserCompat.ts
353
+ function getChromeVersion(ua) {
354
+ var match = ua.match(/Chrome\/(\d+)/);
355
+ return match && match[1] ? parseInt(match[1], 10) : 0;
356
+ }
357
+ function getWebKitVersion(ua) {
358
+ var match = ua.match(/AppleWebKit\/(\d+)/);
359
+ return match && match[1] ? parseInt(match[1], 10) : 0;
360
+ }
361
+ function getPlatform() {
362
+ var _navigator_userAgentData;
363
+ if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
364
+ return navigator.userAgentData.platform;
365
+ }
366
+ var ua = navigator.userAgent;
367
+ if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
368
+ return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
369
+ }
370
+ if (/Win/i.test(ua)) {
371
+ return "Win32";
372
+ }
373
+ if (/Linux/i.test(ua)) {
374
+ return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
375
+ }
376
+ if (/CrOS/i.test(ua)) {
377
+ return "CrOS";
378
+ }
379
+ return navigator.platform || "Unknown";
380
+ }
381
+ function detectBrowser() {
382
+ var ua = navigator.userAgent;
383
+ var platform = getPlatform();
384
+ var name = "Unknown";
385
+ var version = "0";
386
+ var majorVersion = 0;
387
+ var isSmartTV = false;
388
+ var isLegacyTV = false;
389
+ var supportsModernJS = true;
390
+ var webOSVersion;
391
+ var tizenVersion;
392
+ var chromeVersionNum;
393
+ var chromeVersion = getChromeVersion(ua);
394
+ var webkitVersion = getWebKitVersion(ua);
395
+ chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
396
+ if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
397
+ name = "LG WebOS";
398
+ isSmartTV = true;
399
+ var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
400
+ if (!match || !match[1]) {
401
+ match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
402
+ }
403
+ if (match && match[1]) {
404
+ version = match[1];
405
+ var parts = version.split(".");
406
+ majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
407
+ webOSVersion = majorVersion;
408
+ } else if (chromeVersion > 0) {
409
+ if (chromeVersion >= 79) {
410
+ webOSVersion = 6;
411
+ version = "6.0";
412
+ majorVersion = 6;
413
+ } else if (chromeVersion >= 68) {
414
+ webOSVersion = 5;
415
+ version = "5.0";
416
+ majorVersion = 5;
417
+ } else if (chromeVersion >= 53) {
418
+ webOSVersion = 4;
419
+ version = "4.0";
420
+ majorVersion = 4;
421
+ } else if (chromeVersion >= 38) {
422
+ webOSVersion = 3;
423
+ version = "3.0";
424
+ majorVersion = 3;
425
+ } else {
426
+ webOSVersion = 2;
427
+ version = "2.0";
428
+ majorVersion = 2;
429
+ }
430
+ } else {
431
+ version = "Unknown";
432
+ webOSVersion = void 0;
433
+ }
434
+ isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
435
+ } else if (/Tizen/i.test(ua)) {
436
+ name = "Samsung Tizen";
437
+ isSmartTV = true;
438
+ var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
439
+ version = match1 && match1[1] ? match1[1] : "Unknown";
440
+ if (version !== "Unknown") {
441
+ var parts1 = version.split(".");
442
+ majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
443
+ tizenVersion = majorVersion;
444
+ }
445
+ isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
446
+ } else if (/SMART-TV|SmartTV/i.test(ua)) {
447
+ name = "Smart TV";
448
+ isSmartTV = true;
449
+ isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
450
+ } else if (/NetCast/i.test(ua)) {
451
+ name = "LG NetCast";
452
+ isSmartTV = true;
453
+ isLegacyTV = true;
454
+ } else if (/BRAVIA/i.test(ua)) {
455
+ name = "Sony BRAVIA";
456
+ isSmartTV = true;
457
+ isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
458
+ } else {
459
+ if (chromeVersion > 0) {
460
+ name = "Chrome";
461
+ version = chromeVersion.toString();
462
+ majorVersion = chromeVersion;
463
+ if (chromeVersion < 50) {
464
+ supportsModernJS = false;
465
+ }
466
+ }
467
+ if (webkitVersion > 0 && webkitVersion < 600) {
468
+ supportsModernJS = false;
469
+ }
470
+ }
471
+ if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
472
+ supportsModernJS = false;
473
+ }
474
+ if (typeof URLSearchParams === "undefined") {
475
+ supportsModernJS = false;
476
+ }
477
+ return {
478
+ name: name,
479
+ version: version,
480
+ majorVersion: majorVersion,
481
+ isSmartTV: isSmartTV,
482
+ isLegacyTV: isLegacyTV,
483
+ platform: platform,
484
+ supportsModernJS: supportsModernJS,
485
+ webOSVersion: webOSVersion,
486
+ tizenVersion: tizenVersion,
487
+ chromeVersion: chromeVersionNum
488
+ };
489
+ }
490
+ function requiresMediaPipelineResetAfterAds() {
491
+ var _browser_tizenVersion;
492
+ var browser = detectBrowser();
493
+ return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
494
+ }
495
+ function getBrowserConfigOverrides() {
496
+ var browser = detectBrowser();
497
+ var overrides = {};
498
+ if (browser.isSmartTV) {
499
+ overrides.allowNativeHls = true;
500
+ overrides.pauseContentDuringAds = true;
501
+ }
502
+ return overrides;
503
+ }
504
+ function logBrowserInfo() {
505
+ var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
506
+ if (!debug) return;
507
+ var browser = detectBrowser();
508
+ console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
509
+ browser: "".concat(browser.name, " ").concat(browser.version),
510
+ platform: browser.platform,
511
+ isSmartTV: browser.isSmartTV,
512
+ isLegacyTV: browser.isLegacyTV,
513
+ supportsModernJS: browser.supportsModernJS
514
+ }, browser.webOSVersion !== void 0 ? {
515
+ webOSVersion: browser.webOSVersion
516
+ } : {}, browser.tizenVersion !== void 0 ? {
517
+ tizenVersion: browser.tizenVersion
518
+ } : {}, browser.chromeVersion !== void 0 ? {
519
+ chromeVersion: browser.chromeVersion
520
+ } : {}), {
521
+ userAgent: navigator.userAgent
522
+ }));
523
+ }
524
+ // src/sdk/hlsAdPlayer.ts
352
525
  var MAX_VAST_WRAPPER_DEPTH = 5;
353
526
  function createHlsAdPlayer(contentVideo, options) {
354
527
  var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
@@ -360,6 +533,7 @@ function createHlsAdPlayer(contentVideo, options) {
360
533
  var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
361
534
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
362
535
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
536
+ var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
363
537
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
364
538
  var adHls;
365
539
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -379,6 +553,8 @@ function createHlsAdPlayer(contentVideo, options) {
379
553
  var lastAdProgressTime = 0;
380
554
  var lastAdProgressPosition = 0;
381
555
  var sawDecodedVideoFrame = false;
556
+ var videoFrameCallbackHandle;
557
+ var pendingPlayPromise;
382
558
  var trackingFired = {
383
559
  impression: false,
384
560
  start: false,
@@ -1182,6 +1358,60 @@ function createHlsAdPlayer(contentVideo, options) {
1182
1358
  complete: false
1183
1359
  };
1184
1360
  }
1361
+ function isRvfcSupported(video) {
1362
+ return typeof video.requestVideoFrameCallback === "function";
1363
+ }
1364
+ function settlePendingPlay() {
1365
+ pendingPlayPromise = void 0;
1366
+ }
1367
+ function startAdPlayback(context) {
1368
+ if (!adVideoElement) return;
1369
+ var playPromise = adVideoElement.play();
1370
+ pendingPlayPromise = playPromise;
1371
+ playPromise.catch(function(error) {
1372
+ if (pendingPlayPromise !== playPromise) {
1373
+ return;
1374
+ }
1375
+ console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
1376
+ handleAdError();
1377
+ }).finally(function() {
1378
+ if (pendingPlayPromise === playPromise) {
1379
+ pendingPlayPromise = void 0;
1380
+ }
1381
+ });
1382
+ }
1383
+ function prepareVideoElementForNewSource() {
1384
+ settlePendingPlay();
1385
+ if (adHls) {
1386
+ adHls.destroy();
1387
+ adHls = void 0;
1388
+ }
1389
+ if (!adVideoElement) return;
1390
+ try {
1391
+ adVideoElement.pause();
1392
+ adVideoElement.removeAttribute("src");
1393
+ adVideoElement.load();
1394
+ } catch (error) {
1395
+ console.warn("[HlsAdPlayer] Error preparing ad video for new source:", error);
1396
+ }
1397
+ }
1398
+ function recreateAdVideoElement() {
1399
+ console.log("[HlsAdPlayer] Recreating ad video element (single-decoder platform)");
1400
+ teardownAdEventListeners();
1401
+ prepareVideoElementForNewSource();
1402
+ if (adVideoElement) {
1403
+ try {
1404
+ adVideoElement.remove();
1405
+ } catch (error) {
1406
+ console.warn("[HlsAdPlayer] Error removing ad video element:", error);
1407
+ }
1408
+ }
1409
+ adVideoElement = createAdVideoElement();
1410
+ adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.appendChild(adVideoElement);
1411
+ contentVideo[AD_VIDEO_PROP] = adVideoElement;
1412
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
1413
+ adVideoElement.muted = originalMutedState;
1414
+ }
1185
1415
  function loadCurrentAdMedia() {
1186
1416
  if (!adVideoElement || !currentAd) {
1187
1417
  throw new Error("No ad video element or ad to load");
@@ -1204,10 +1434,7 @@ function createHlsAdPlayer(contentVideo, options) {
1204
1434
  adHls.attachMedia(adVideoElement);
1205
1435
  adHls.on(import_hls.default.Events.MANIFEST_PARSED, function() {
1206
1436
  console.log("[HlsAdPlayer] HLS manifest parsed, starting playback");
1207
- adVideoElement.play().catch(function(error) {
1208
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1209
- handleAdError();
1210
- });
1437
+ startAdPlayback("HLS ad playback");
1211
1438
  });
1212
1439
  adHls.on(import_hls.default.Events.ERROR, function(_event, data) {
1213
1440
  console.error("[HlsAdPlayer] HLS error:", data);
@@ -1217,10 +1444,7 @@ function createHlsAdPlayer(contentVideo, options) {
1217
1444
  });
1218
1445
  } else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
1219
1446
  adVideoElement.src = mediaFile.url;
1220
- adVideoElement.play().catch(function(error) {
1221
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1222
- handleAdError();
1223
- });
1447
+ startAdPlayback("native HLS ad playback");
1224
1448
  } else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
1225
1449
  if (adHls) {
1226
1450
  adHls.destroy();
@@ -1228,10 +1452,7 @@ function createHlsAdPlayer(contentVideo, options) {
1228
1452
  }
1229
1453
  adVideoElement.src = mediaFile.url;
1230
1454
  adVideoElement.load();
1231
- adVideoElement.play().catch(function(error) {
1232
- console.error("[HlsAdPlayer] Error starting progressive ad playback:", error);
1233
- handleAdError();
1234
- });
1455
+ startAdPlayback("progressive ad playback");
1235
1456
  } else {
1236
1457
  throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
1237
1458
  }
@@ -1248,6 +1469,13 @@ function createHlsAdPlayer(contentVideo, options) {
1248
1469
  trackingFired.impression = true;
1249
1470
  console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
1250
1471
  }
1472
+ clearStallWatchdog();
1473
+ if (requiresMediaPipelineResetAfterAds()) {
1474
+ recreateAdVideoElement();
1475
+ setupAdEventListeners();
1476
+ } else {
1477
+ prepareVideoElementForNewSource();
1478
+ }
1251
1479
  try {
1252
1480
  loadCurrentAdMedia();
1253
1481
  emit("pod_ad_started", {
@@ -1265,6 +1493,7 @@ function createHlsAdPlayer(contentVideo, options) {
1265
1493
  clearInterval(stallWatchdogId);
1266
1494
  stallWatchdogId = void 0;
1267
1495
  }
1496
+ cancelVideoFrameProbe();
1268
1497
  }
1269
1498
  function noteAdProgress() {
1270
1499
  lastAdProgressTime = Date.now();
@@ -1300,6 +1529,39 @@ function createHlsAdPlayer(contentVideo, options) {
1300
1529
  }
1301
1530
  return void 0;
1302
1531
  }
1532
+ function isFrameCounterReliable() {
1533
+ return contentVideo[FRAME_COUNTER_RELIABLE_PROP] === true;
1534
+ }
1535
+ function markFrameCounterReliable() {
1536
+ contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1537
+ }
1538
+ function cancelVideoFrameProbe() {
1539
+ if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1540
+ try {
1541
+ adVideoElement.cancelVideoFrameCallback(videoFrameCallbackHandle);
1542
+ } catch (error) {
1543
+ console.warn("[HlsAdPlayer] Error cancelling video frame callback:", error);
1544
+ }
1545
+ }
1546
+ videoFrameCallbackHandle = void 0;
1547
+ }
1548
+ function startVideoFrameProbe() {
1549
+ cancelVideoFrameProbe();
1550
+ if (!adVideoElement) return;
1551
+ var rvfc = adVideoElement.requestVideoFrameCallback;
1552
+ if (typeof rvfc !== "function") return;
1553
+ var onPresentedFrame = function onPresentedFrame() {
1554
+ videoFrameCallbackHandle = void 0;
1555
+ if (!adPlaying) return;
1556
+ sawDecodedVideoFrame = true;
1557
+ };
1558
+ try {
1559
+ videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
1560
+ } catch (error) {
1561
+ console.warn("[HlsAdPlayer] Error requesting video frame callback:", error);
1562
+ videoFrameCallbackHandle = void 0;
1563
+ }
1564
+ }
1303
1565
  function handleVideoDecodeFailure() {
1304
1566
  console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
1305
1567
  clearStallWatchdog();
@@ -1315,6 +1577,7 @@ function createHlsAdPlayer(contentVideo, options) {
1315
1577
  clearStallWatchdog();
1316
1578
  noteAdProgress();
1317
1579
  sawDecodedVideoFrame = false;
1580
+ startVideoFrameProbe();
1318
1581
  stallWatchdogId = window.setInterval(function() {
1319
1582
  if (!adPlaying || !adVideoElement) {
1320
1583
  return;
@@ -1323,9 +1586,17 @@ function createHlsAdPlayer(contentVideo, options) {
1323
1586
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1324
1587
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1325
1588
  sawDecodedVideoFrame = true;
1326
- } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1327
- handleVideoDecodeFailure();
1328
- return;
1589
+ markFrameCounterReliable();
1590
+ } else if (adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1591
+ var timeAdvancing = adVideoElement.currentTime > lastAdProgressPosition + 0.05;
1592
+ if (isRvfcSupported(adVideoElement) && timeAdvancing) {
1593
+ handleVideoDecodeFailure();
1594
+ return;
1595
+ }
1596
+ if (decodedFrames === 0 && timeAdvancing && isFrameCounterReliable()) {
1597
+ handleVideoDecodeFailure();
1598
+ return;
1599
+ }
1329
1600
  }
1330
1601
  }
1331
1602
  if (adVideoElement.currentTime > lastAdProgressPosition + 0.05) {
@@ -1342,19 +1613,7 @@ function createHlsAdPlayer(contentVideo, options) {
1342
1613
  }, STALL_CHECK_INTERVAL_MS);
1343
1614
  }
1344
1615
  function releaseAdDecoder() {
1345
- if (adHls) {
1346
- adHls.destroy();
1347
- adHls = void 0;
1348
- }
1349
- if (adVideoElement) {
1350
- try {
1351
- adVideoElement.pause();
1352
- adVideoElement.removeAttribute("src");
1353
- adVideoElement.load();
1354
- } catch (error) {
1355
- console.warn("[HlsAdPlayer] Error releasing ad decoder:", error);
1356
- }
1357
- }
1616
+ prepareVideoElementForNewSource();
1358
1617
  if (adContainerEl) {
1359
1618
  adContainerEl.style.display = "none";
1360
1619
  adContainerEl.style.pointerEvents = "none";
@@ -3925,178 +4184,6 @@ function fetchConsentSignals() {
3925
4184
  return signals;
3926
4185
  });
3927
4186
  }
3928
- // src/utils/browserCompat.ts
3929
- function getChromeVersion(ua) {
3930
- var match = ua.match(/Chrome\/(\d+)/);
3931
- return match && match[1] ? parseInt(match[1], 10) : 0;
3932
- }
3933
- function getWebKitVersion(ua) {
3934
- var match = ua.match(/AppleWebKit\/(\d+)/);
3935
- return match && match[1] ? parseInt(match[1], 10) : 0;
3936
- }
3937
- function getPlatform() {
3938
- var _navigator_userAgentData;
3939
- if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
3940
- return navigator.userAgentData.platform;
3941
- }
3942
- var ua = navigator.userAgent;
3943
- if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
3944
- return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
3945
- }
3946
- if (/Win/i.test(ua)) {
3947
- return "Win32";
3948
- }
3949
- if (/Linux/i.test(ua)) {
3950
- return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
3951
- }
3952
- if (/CrOS/i.test(ua)) {
3953
- return "CrOS";
3954
- }
3955
- return navigator.platform || "Unknown";
3956
- }
3957
- function detectBrowser() {
3958
- var ua = navigator.userAgent;
3959
- var platform = getPlatform();
3960
- var name = "Unknown";
3961
- var version = "0";
3962
- var majorVersion = 0;
3963
- var isSmartTV = false;
3964
- var isLegacyTV = false;
3965
- var supportsModernJS = true;
3966
- var webOSVersion;
3967
- var tizenVersion;
3968
- var chromeVersionNum;
3969
- var chromeVersion = getChromeVersion(ua);
3970
- var webkitVersion = getWebKitVersion(ua);
3971
- chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
3972
- if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
3973
- name = "LG WebOS";
3974
- isSmartTV = true;
3975
- var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
3976
- if (!match || !match[1]) {
3977
- match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
3978
- }
3979
- if (match && match[1]) {
3980
- version = match[1];
3981
- var parts = version.split(".");
3982
- majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
3983
- webOSVersion = majorVersion;
3984
- } else if (chromeVersion > 0) {
3985
- if (chromeVersion >= 79) {
3986
- webOSVersion = 6;
3987
- version = "6.0";
3988
- majorVersion = 6;
3989
- } else if (chromeVersion >= 68) {
3990
- webOSVersion = 5;
3991
- version = "5.0";
3992
- majorVersion = 5;
3993
- } else if (chromeVersion >= 53) {
3994
- webOSVersion = 4;
3995
- version = "4.0";
3996
- majorVersion = 4;
3997
- } else if (chromeVersion >= 38) {
3998
- webOSVersion = 3;
3999
- version = "3.0";
4000
- majorVersion = 3;
4001
- } else {
4002
- webOSVersion = 2;
4003
- version = "2.0";
4004
- majorVersion = 2;
4005
- }
4006
- } else {
4007
- version = "Unknown";
4008
- webOSVersion = void 0;
4009
- }
4010
- isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
4011
- } else if (/Tizen/i.test(ua)) {
4012
- name = "Samsung Tizen";
4013
- isSmartTV = true;
4014
- var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
4015
- version = match1 && match1[1] ? match1[1] : "Unknown";
4016
- if (version !== "Unknown") {
4017
- var parts1 = version.split(".");
4018
- majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
4019
- tizenVersion = majorVersion;
4020
- }
4021
- isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
4022
- } else if (/SMART-TV|SmartTV/i.test(ua)) {
4023
- name = "Smart TV";
4024
- isSmartTV = true;
4025
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4026
- } else if (/NetCast/i.test(ua)) {
4027
- name = "LG NetCast";
4028
- isSmartTV = true;
4029
- isLegacyTV = true;
4030
- } else if (/BRAVIA/i.test(ua)) {
4031
- name = "Sony BRAVIA";
4032
- isSmartTV = true;
4033
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4034
- } else {
4035
- if (chromeVersion > 0) {
4036
- name = "Chrome";
4037
- version = chromeVersion.toString();
4038
- majorVersion = chromeVersion;
4039
- if (chromeVersion < 50) {
4040
- supportsModernJS = false;
4041
- }
4042
- }
4043
- if (webkitVersion > 0 && webkitVersion < 600) {
4044
- supportsModernJS = false;
4045
- }
4046
- }
4047
- if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
4048
- supportsModernJS = false;
4049
- }
4050
- if (typeof URLSearchParams === "undefined") {
4051
- supportsModernJS = false;
4052
- }
4053
- return {
4054
- name: name,
4055
- version: version,
4056
- majorVersion: majorVersion,
4057
- isSmartTV: isSmartTV,
4058
- isLegacyTV: isLegacyTV,
4059
- platform: platform,
4060
- supportsModernJS: supportsModernJS,
4061
- webOSVersion: webOSVersion,
4062
- tizenVersion: tizenVersion,
4063
- chromeVersion: chromeVersionNum
4064
- };
4065
- }
4066
- function requiresMediaPipelineResetAfterAds() {
4067
- var _browser_tizenVersion;
4068
- var browser = detectBrowser();
4069
- return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
4070
- }
4071
- function getBrowserConfigOverrides() {
4072
- var browser = detectBrowser();
4073
- var overrides = {};
4074
- if (browser.isSmartTV) {
4075
- overrides.allowNativeHls = true;
4076
- overrides.pauseContentDuringAds = true;
4077
- }
4078
- return overrides;
4079
- }
4080
- function logBrowserInfo() {
4081
- var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
4082
- if (!debug) return;
4083
- var browser = detectBrowser();
4084
- console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
4085
- browser: "".concat(browser.name, " ").concat(browser.version),
4086
- platform: browser.platform,
4087
- isSmartTV: browser.isSmartTV,
4088
- isLegacyTV: browser.isLegacyTV,
4089
- supportsModernJS: browser.supportsModernJS
4090
- }, browser.webOSVersion !== void 0 ? {
4091
- webOSVersion: browser.webOSVersion
4092
- } : {}, browser.tizenVersion !== void 0 ? {
4093
- tizenVersion: browser.tizenVersion
4094
- } : {}, browser.chromeVersion !== void 0 ? {
4095
- chromeVersion: browser.chromeVersion
4096
- } : {}), {
4097
- userAgent: navigator.userAgent
4098
- }));
4099
- }
4100
4187
  // src/player/Scte35Parser.ts
4101
4188
  function parseCueOutDuration(value) {
4102
4189
  var num = parseFloat(value.trim());
@@ -6168,17 +6255,17 @@ var AdTimingService = /*#__PURE__*/ function() {
6168
6255
  {
6169
6256
  key: "logAdState",
6170
6257
  value: function logAdState(event) {
6171
- 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;
6172
- var _ref;
6258
+ var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6173
6259
  if (!this.debug) {
6174
6260
  return;
6175
6261
  }
6262
+ var _this_callbacks_getAdState = this.callbacks.getAdState(), inAdBreak = _this_callbacks_getAdState.inAdBreak, showAds = _this_callbacks_getAdState.showAds, adPlaying = _this_callbacks_getAdState.adPlaying;
6176
6263
  console.log("[StormcloudVideoPlayer][AdState]", _object_spread({
6177
6264
  event: event,
6178
6265
  timestamp: /* @__PURE__ */ new Date().toISOString(),
6179
- showAds: showAds !== null && showAds !== void 0 ? showAds : false,
6180
- adPlaying: (_ref = adPlayer === null || adPlayer === void 0 ? void 0 : adPlayer.isAdPlaying()) !== null && _ref !== void 0 ? _ref : false,
6181
- inAdBreak: inAdBreak !== null && inAdBreak !== void 0 ? inAdBreak : false,
6266
+ showAds: showAds,
6267
+ adPlaying: adPlaying,
6268
+ inAdBreak: inAdBreak,
6182
6269
  activeAdRequestToken: this.activeAdRequestToken
6183
6270
  }, extra));
6184
6271
  }
@@ -8528,6 +8615,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8528
8615
  },
8529
8616
  onFailsafeTimeout: function onFailsafeTimeout() {
8530
8617
  return _this.adBreak.handleAdFailure();
8618
+ },
8619
+ getAdState: function getAdState() {
8620
+ return {
8621
+ inAdBreak: _this.adBreak.inAdBreak,
8622
+ showAds: _this.adBreak.showAds,
8623
+ adPlaying: _this.adPlayer.isAdPlaying()
8624
+ };
8531
8625
  }
8532
8626
  });
8533
8627
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);