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.
package/lib/index.js CHANGED
@@ -370,6 +370,202 @@ function _ts_values(o) {
370
370
  import React, { useEffect, useRef, useMemo, useCallback } from "react";
371
371
  // src/sdk/hlsAdPlayer.ts
372
372
  import Hls from "hls.js";
373
+ // src/utils/browserCompat.ts
374
+ function getChromeVersion(ua) {
375
+ var match = ua.match(/Chrome\/(\d+)/);
376
+ return match && match[1] ? parseInt(match[1], 10) : 0;
377
+ }
378
+ function getWebKitVersion(ua) {
379
+ var match = ua.match(/AppleWebKit\/(\d+)/);
380
+ return match && match[1] ? parseInt(match[1], 10) : 0;
381
+ }
382
+ function getPlatform() {
383
+ var _navigator_userAgentData;
384
+ if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
385
+ return navigator.userAgentData.platform;
386
+ }
387
+ var ua = navigator.userAgent;
388
+ if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
389
+ return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
390
+ }
391
+ if (/Win/i.test(ua)) {
392
+ return "Win32";
393
+ }
394
+ if (/Linux/i.test(ua)) {
395
+ return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
396
+ }
397
+ if (/CrOS/i.test(ua)) {
398
+ return "CrOS";
399
+ }
400
+ return navigator.platform || "Unknown";
401
+ }
402
+ function detectBrowser() {
403
+ var ua = navigator.userAgent;
404
+ var platform = getPlatform();
405
+ var name = "Unknown";
406
+ var version = "0";
407
+ var majorVersion = 0;
408
+ var isSmartTV = false;
409
+ var isLegacyTV = false;
410
+ var supportsModernJS2 = true;
411
+ var webOSVersion;
412
+ var tizenVersion;
413
+ var chromeVersionNum;
414
+ var chromeVersion = getChromeVersion(ua);
415
+ var webkitVersion = getWebKitVersion(ua);
416
+ chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
417
+ if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
418
+ name = "LG WebOS";
419
+ isSmartTV = true;
420
+ var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
421
+ if (!match || !match[1]) {
422
+ match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
423
+ }
424
+ if (match && match[1]) {
425
+ version = match[1];
426
+ var parts = version.split(".");
427
+ majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
428
+ webOSVersion = majorVersion;
429
+ } else if (chromeVersion > 0) {
430
+ if (chromeVersion >= 79) {
431
+ webOSVersion = 6;
432
+ version = "6.0";
433
+ majorVersion = 6;
434
+ } else if (chromeVersion >= 68) {
435
+ webOSVersion = 5;
436
+ version = "5.0";
437
+ majorVersion = 5;
438
+ } else if (chromeVersion >= 53) {
439
+ webOSVersion = 4;
440
+ version = "4.0";
441
+ majorVersion = 4;
442
+ } else if (chromeVersion >= 38) {
443
+ webOSVersion = 3;
444
+ version = "3.0";
445
+ majorVersion = 3;
446
+ } else {
447
+ webOSVersion = 2;
448
+ version = "2.0";
449
+ majorVersion = 2;
450
+ }
451
+ } else {
452
+ version = "Unknown";
453
+ webOSVersion = void 0;
454
+ }
455
+ isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
456
+ } else if (/Tizen/i.test(ua)) {
457
+ name = "Samsung Tizen";
458
+ isSmartTV = true;
459
+ var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
460
+ version = match1 && match1[1] ? match1[1] : "Unknown";
461
+ if (version !== "Unknown") {
462
+ var parts1 = version.split(".");
463
+ majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
464
+ tizenVersion = majorVersion;
465
+ }
466
+ isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
467
+ } else if (/SMART-TV|SmartTV/i.test(ua)) {
468
+ name = "Smart TV";
469
+ isSmartTV = true;
470
+ isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
471
+ } else if (/NetCast/i.test(ua)) {
472
+ name = "LG NetCast";
473
+ isSmartTV = true;
474
+ isLegacyTV = true;
475
+ } else if (/BRAVIA/i.test(ua)) {
476
+ name = "Sony BRAVIA";
477
+ isSmartTV = true;
478
+ isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
479
+ } else {
480
+ if (chromeVersion > 0) {
481
+ name = "Chrome";
482
+ version = chromeVersion.toString();
483
+ majorVersion = chromeVersion;
484
+ if (chromeVersion < 50) {
485
+ supportsModernJS2 = false;
486
+ }
487
+ }
488
+ if (webkitVersion > 0 && webkitVersion < 600) {
489
+ supportsModernJS2 = false;
490
+ }
491
+ }
492
+ if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
493
+ supportsModernJS2 = false;
494
+ }
495
+ if (typeof URLSearchParams === "undefined") {
496
+ supportsModernJS2 = false;
497
+ }
498
+ return {
499
+ name: name,
500
+ version: version,
501
+ majorVersion: majorVersion,
502
+ isSmartTV: isSmartTV,
503
+ isLegacyTV: isLegacyTV,
504
+ platform: platform,
505
+ supportsModernJS: supportsModernJS2,
506
+ webOSVersion: webOSVersion,
507
+ tizenVersion: tizenVersion,
508
+ chromeVersion: chromeVersionNum
509
+ };
510
+ }
511
+ function requiresMediaPipelineResetAfterAds() {
512
+ var _browser_tizenVersion;
513
+ var browser = detectBrowser();
514
+ return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
515
+ }
516
+ function getBrowserConfigOverrides() {
517
+ var browser = detectBrowser();
518
+ var overrides = {};
519
+ if (browser.isSmartTV) {
520
+ overrides.allowNativeHls = true;
521
+ overrides.pauseContentDuringAds = true;
522
+ }
523
+ return overrides;
524
+ }
525
+ function supportsModernJS() {
526
+ try {
527
+ return typeof Promise !== "undefined" && typeof Map !== "undefined" && typeof Set !== "undefined" && typeof Array.from !== "undefined" && typeof Object.assign !== "undefined" && typeof Array.prototype.forEach !== "undefined" && typeof String.prototype.includes !== "undefined";
528
+ } catch (e) {
529
+ return false;
530
+ }
531
+ }
532
+ function logBrowserInfo() {
533
+ var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
534
+ if (!debug) return;
535
+ var browser = detectBrowser();
536
+ console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
537
+ browser: "".concat(browser.name, " ").concat(browser.version),
538
+ platform: browser.platform,
539
+ isSmartTV: browser.isSmartTV,
540
+ isLegacyTV: browser.isLegacyTV,
541
+ supportsModernJS: browser.supportsModernJS
542
+ }, browser.webOSVersion !== void 0 ? {
543
+ webOSVersion: browser.webOSVersion
544
+ } : {}, browser.tizenVersion !== void 0 ? {
545
+ tizenVersion: browser.tizenVersion
546
+ } : {}, browser.chromeVersion !== void 0 ? {
547
+ chromeVersion: browser.chromeVersion
548
+ } : {}), {
549
+ userAgent: navigator.userAgent
550
+ }));
551
+ }
552
+ function supportsFeature(feature) {
553
+ switch(feature){
554
+ case "urlsearchparams":
555
+ return typeof URLSearchParams !== "undefined";
556
+ case "textencoder":
557
+ return typeof TextEncoder !== "undefined";
558
+ case "promises":
559
+ return typeof Promise !== "undefined";
560
+ case "fetch":
561
+ return typeof fetch !== "undefined";
562
+ case "crypto":
563
+ return typeof crypto !== "undefined" && typeof crypto.subtle !== "undefined";
564
+ default:
565
+ return false;
566
+ }
567
+ }
568
+ // src/sdk/hlsAdPlayer.ts
373
569
  var MAX_VAST_WRAPPER_DEPTH = 5;
374
570
  function createHlsAdPlayer(contentVideo, options) {
375
571
  var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP;
@@ -381,6 +577,7 @@ function createHlsAdPlayer(contentVideo, options) {
381
577
  var mainHlsInstance = options === null || options === void 0 ? void 0 : options.mainHlsInstance;
382
578
  var AD_CONTAINER_PROP = "__stormcloudAdContainer";
383
579
  var AD_VIDEO_PROP = "__stormcloudAdVideo";
580
+ var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
384
581
  var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
385
582
  var adHls;
386
583
  var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
@@ -400,6 +597,8 @@ function createHlsAdPlayer(contentVideo, options) {
400
597
  var lastAdProgressTime = 0;
401
598
  var lastAdProgressPosition = 0;
402
599
  var sawDecodedVideoFrame = false;
600
+ var videoFrameCallbackHandle;
601
+ var pendingPlayPromise;
403
602
  var trackingFired = {
404
603
  impression: false,
405
604
  start: false,
@@ -1203,6 +1402,60 @@ function createHlsAdPlayer(contentVideo, options) {
1203
1402
  complete: false
1204
1403
  };
1205
1404
  }
1405
+ function isRvfcSupported(video) {
1406
+ return typeof video.requestVideoFrameCallback === "function";
1407
+ }
1408
+ function settlePendingPlay() {
1409
+ pendingPlayPromise = void 0;
1410
+ }
1411
+ function startAdPlayback(context) {
1412
+ if (!adVideoElement) return;
1413
+ var playPromise = adVideoElement.play();
1414
+ pendingPlayPromise = playPromise;
1415
+ playPromise.catch(function(error) {
1416
+ if (pendingPlayPromise !== playPromise) {
1417
+ return;
1418
+ }
1419
+ console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
1420
+ handleAdError();
1421
+ }).finally(function() {
1422
+ if (pendingPlayPromise === playPromise) {
1423
+ pendingPlayPromise = void 0;
1424
+ }
1425
+ });
1426
+ }
1427
+ function prepareVideoElementForNewSource() {
1428
+ settlePendingPlay();
1429
+ if (adHls) {
1430
+ adHls.destroy();
1431
+ adHls = void 0;
1432
+ }
1433
+ if (!adVideoElement) return;
1434
+ try {
1435
+ adVideoElement.pause();
1436
+ adVideoElement.removeAttribute("src");
1437
+ adVideoElement.load();
1438
+ } catch (error) {
1439
+ console.warn("[HlsAdPlayer] Error preparing ad video for new source:", error);
1440
+ }
1441
+ }
1442
+ function recreateAdVideoElement() {
1443
+ console.log("[HlsAdPlayer] Recreating ad video element (single-decoder platform)");
1444
+ teardownAdEventListeners();
1445
+ prepareVideoElementForNewSource();
1446
+ if (adVideoElement) {
1447
+ try {
1448
+ adVideoElement.remove();
1449
+ } catch (error) {
1450
+ console.warn("[HlsAdPlayer] Error removing ad video element:", error);
1451
+ }
1452
+ }
1453
+ adVideoElement = createAdVideoElement();
1454
+ adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.appendChild(adVideoElement);
1455
+ contentVideo[AD_VIDEO_PROP] = adVideoElement;
1456
+ adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
1457
+ adVideoElement.muted = originalMutedState;
1458
+ }
1206
1459
  function loadCurrentAdMedia() {
1207
1460
  if (!adVideoElement || !currentAd) {
1208
1461
  throw new Error("No ad video element or ad to load");
@@ -1225,10 +1478,7 @@ function createHlsAdPlayer(contentVideo, options) {
1225
1478
  adHls.attachMedia(adVideoElement);
1226
1479
  adHls.on(Hls.Events.MANIFEST_PARSED, function() {
1227
1480
  console.log("[HlsAdPlayer] HLS manifest parsed, starting playback");
1228
- adVideoElement.play().catch(function(error) {
1229
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1230
- handleAdError();
1231
- });
1481
+ startAdPlayback("HLS ad playback");
1232
1482
  });
1233
1483
  adHls.on(Hls.Events.ERROR, function(_event, data) {
1234
1484
  console.error("[HlsAdPlayer] HLS error:", data);
@@ -1238,10 +1488,7 @@ function createHlsAdPlayer(contentVideo, options) {
1238
1488
  });
1239
1489
  } else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
1240
1490
  adVideoElement.src = mediaFile.url;
1241
- adVideoElement.play().catch(function(error) {
1242
- console.error("[HlsAdPlayer] Error starting ad playback:", error);
1243
- handleAdError();
1244
- });
1491
+ startAdPlayback("native HLS ad playback");
1245
1492
  } else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
1246
1493
  if (adHls) {
1247
1494
  adHls.destroy();
@@ -1249,10 +1496,7 @@ function createHlsAdPlayer(contentVideo, options) {
1249
1496
  }
1250
1497
  adVideoElement.src = mediaFile.url;
1251
1498
  adVideoElement.load();
1252
- adVideoElement.play().catch(function(error) {
1253
- console.error("[HlsAdPlayer] Error starting progressive ad playback:", error);
1254
- handleAdError();
1255
- });
1499
+ startAdPlayback("progressive ad playback");
1256
1500
  } else {
1257
1501
  throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
1258
1502
  }
@@ -1269,6 +1513,13 @@ function createHlsAdPlayer(contentVideo, options) {
1269
1513
  trackingFired.impression = true;
1270
1514
  console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
1271
1515
  }
1516
+ clearStallWatchdog();
1517
+ if (requiresMediaPipelineResetAfterAds()) {
1518
+ recreateAdVideoElement();
1519
+ setupAdEventListeners();
1520
+ } else {
1521
+ prepareVideoElementForNewSource();
1522
+ }
1272
1523
  try {
1273
1524
  loadCurrentAdMedia();
1274
1525
  emit("pod_ad_started", {
@@ -1286,6 +1537,7 @@ function createHlsAdPlayer(contentVideo, options) {
1286
1537
  clearInterval(stallWatchdogId);
1287
1538
  stallWatchdogId = void 0;
1288
1539
  }
1540
+ cancelVideoFrameProbe();
1289
1541
  }
1290
1542
  function noteAdProgress() {
1291
1543
  lastAdProgressTime = Date.now();
@@ -1321,6 +1573,39 @@ function createHlsAdPlayer(contentVideo, options) {
1321
1573
  }
1322
1574
  return void 0;
1323
1575
  }
1576
+ function isFrameCounterReliable() {
1577
+ return contentVideo[FRAME_COUNTER_RELIABLE_PROP] === true;
1578
+ }
1579
+ function markFrameCounterReliable() {
1580
+ contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
1581
+ }
1582
+ function cancelVideoFrameProbe() {
1583
+ if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
1584
+ try {
1585
+ adVideoElement.cancelVideoFrameCallback(videoFrameCallbackHandle);
1586
+ } catch (error) {
1587
+ console.warn("[HlsAdPlayer] Error cancelling video frame callback:", error);
1588
+ }
1589
+ }
1590
+ videoFrameCallbackHandle = void 0;
1591
+ }
1592
+ function startVideoFrameProbe() {
1593
+ cancelVideoFrameProbe();
1594
+ if (!adVideoElement) return;
1595
+ var rvfc = adVideoElement.requestVideoFrameCallback;
1596
+ if (typeof rvfc !== "function") return;
1597
+ var onPresentedFrame = function onPresentedFrame() {
1598
+ videoFrameCallbackHandle = void 0;
1599
+ if (!adPlaying) return;
1600
+ sawDecodedVideoFrame = true;
1601
+ };
1602
+ try {
1603
+ videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
1604
+ } catch (error) {
1605
+ console.warn("[HlsAdPlayer] Error requesting video frame callback:", error);
1606
+ videoFrameCallbackHandle = void 0;
1607
+ }
1608
+ }
1324
1609
  function handleVideoDecodeFailure() {
1325
1610
  console.warn("[HlsAdPlayer] Ad audio is advancing but no video frames decoded (black screen) - skipping this creative");
1326
1611
  clearStallWatchdog();
@@ -1336,6 +1621,7 @@ function createHlsAdPlayer(contentVideo, options) {
1336
1621
  clearStallWatchdog();
1337
1622
  noteAdProgress();
1338
1623
  sawDecodedVideoFrame = false;
1624
+ startVideoFrameProbe();
1339
1625
  stallWatchdogId = window.setInterval(function() {
1340
1626
  if (!adPlaying || !adVideoElement) {
1341
1627
  return;
@@ -1344,9 +1630,17 @@ function createHlsAdPlayer(contentVideo, options) {
1344
1630
  var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
1345
1631
  if (decodedFrames !== void 0 && decodedFrames > 0) {
1346
1632
  sawDecodedVideoFrame = true;
1347
- } else if (decodedFrames === 0 && adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1348
- handleVideoDecodeFailure();
1349
- return;
1633
+ markFrameCounterReliable();
1634
+ } else if (adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
1635
+ var timeAdvancing = adVideoElement.currentTime > lastAdProgressPosition + 0.05;
1636
+ if (isRvfcSupported(adVideoElement) && timeAdvancing) {
1637
+ handleVideoDecodeFailure();
1638
+ return;
1639
+ }
1640
+ if (decodedFrames === 0 && timeAdvancing && isFrameCounterReliable()) {
1641
+ handleVideoDecodeFailure();
1642
+ return;
1643
+ }
1350
1644
  }
1351
1645
  }
1352
1646
  if (adVideoElement.currentTime > lastAdProgressPosition + 0.05) {
@@ -1363,19 +1657,7 @@ function createHlsAdPlayer(contentVideo, options) {
1363
1657
  }, STALL_CHECK_INTERVAL_MS);
1364
1658
  }
1365
1659
  function releaseAdDecoder() {
1366
- if (adHls) {
1367
- adHls.destroy();
1368
- adHls = void 0;
1369
- }
1370
- if (adVideoElement) {
1371
- try {
1372
- adVideoElement.pause();
1373
- adVideoElement.removeAttribute("src");
1374
- adVideoElement.load();
1375
- } catch (error) {
1376
- console.warn("[HlsAdPlayer] Error releasing ad decoder:", error);
1377
- }
1378
- }
1660
+ prepareVideoElementForNewSource();
1379
1661
  if (adContainerEl) {
1380
1662
  adContainerEl.style.display = "none";
1381
1663
  adContainerEl.style.pointerEvents = "none";
@@ -3969,201 +4251,6 @@ function fetchConsentSignals() {
3969
4251
  return signals;
3970
4252
  });
3971
4253
  }
3972
- // src/utils/browserCompat.ts
3973
- function getChromeVersion(ua) {
3974
- var match = ua.match(/Chrome\/(\d+)/);
3975
- return match && match[1] ? parseInt(match[1], 10) : 0;
3976
- }
3977
- function getWebKitVersion(ua) {
3978
- var match = ua.match(/AppleWebKit\/(\d+)/);
3979
- return match && match[1] ? parseInt(match[1], 10) : 0;
3980
- }
3981
- function getPlatform() {
3982
- var _navigator_userAgentData;
3983
- if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
3984
- return navigator.userAgentData.platform;
3985
- }
3986
- var ua = navigator.userAgent;
3987
- if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
3988
- return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
3989
- }
3990
- if (/Win/i.test(ua)) {
3991
- return "Win32";
3992
- }
3993
- if (/Linux/i.test(ua)) {
3994
- return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
3995
- }
3996
- if (/CrOS/i.test(ua)) {
3997
- return "CrOS";
3998
- }
3999
- return navigator.platform || "Unknown";
4000
- }
4001
- function detectBrowser() {
4002
- var ua = navigator.userAgent;
4003
- var platform = getPlatform();
4004
- var name = "Unknown";
4005
- var version = "0";
4006
- var majorVersion = 0;
4007
- var isSmartTV = false;
4008
- var isLegacyTV = false;
4009
- var supportsModernJS2 = true;
4010
- var webOSVersion;
4011
- var tizenVersion;
4012
- var chromeVersionNum;
4013
- var chromeVersion = getChromeVersion(ua);
4014
- var webkitVersion = getWebKitVersion(ua);
4015
- chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
4016
- if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
4017
- name = "LG WebOS";
4018
- isSmartTV = true;
4019
- var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
4020
- if (!match || !match[1]) {
4021
- match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
4022
- }
4023
- if (match && match[1]) {
4024
- version = match[1];
4025
- var parts = version.split(".");
4026
- majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
4027
- webOSVersion = majorVersion;
4028
- } else if (chromeVersion > 0) {
4029
- if (chromeVersion >= 79) {
4030
- webOSVersion = 6;
4031
- version = "6.0";
4032
- majorVersion = 6;
4033
- } else if (chromeVersion >= 68) {
4034
- webOSVersion = 5;
4035
- version = "5.0";
4036
- majorVersion = 5;
4037
- } else if (chromeVersion >= 53) {
4038
- webOSVersion = 4;
4039
- version = "4.0";
4040
- majorVersion = 4;
4041
- } else if (chromeVersion >= 38) {
4042
- webOSVersion = 3;
4043
- version = "3.0";
4044
- majorVersion = 3;
4045
- } else {
4046
- webOSVersion = 2;
4047
- version = "2.0";
4048
- majorVersion = 2;
4049
- }
4050
- } else {
4051
- version = "Unknown";
4052
- webOSVersion = void 0;
4053
- }
4054
- isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
4055
- } else if (/Tizen/i.test(ua)) {
4056
- name = "Samsung Tizen";
4057
- isSmartTV = true;
4058
- var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
4059
- version = match1 && match1[1] ? match1[1] : "Unknown";
4060
- if (version !== "Unknown") {
4061
- var parts1 = version.split(".");
4062
- majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
4063
- tizenVersion = majorVersion;
4064
- }
4065
- isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
4066
- } else if (/SMART-TV|SmartTV/i.test(ua)) {
4067
- name = "Smart TV";
4068
- isSmartTV = true;
4069
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4070
- } else if (/NetCast/i.test(ua)) {
4071
- name = "LG NetCast";
4072
- isSmartTV = true;
4073
- isLegacyTV = true;
4074
- } else if (/BRAVIA/i.test(ua)) {
4075
- name = "Sony BRAVIA";
4076
- isSmartTV = true;
4077
- isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
4078
- } else {
4079
- if (chromeVersion > 0) {
4080
- name = "Chrome";
4081
- version = chromeVersion.toString();
4082
- majorVersion = chromeVersion;
4083
- if (chromeVersion < 50) {
4084
- supportsModernJS2 = false;
4085
- }
4086
- }
4087
- if (webkitVersion > 0 && webkitVersion < 600) {
4088
- supportsModernJS2 = false;
4089
- }
4090
- }
4091
- if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
4092
- supportsModernJS2 = false;
4093
- }
4094
- if (typeof URLSearchParams === "undefined") {
4095
- supportsModernJS2 = false;
4096
- }
4097
- return {
4098
- name: name,
4099
- version: version,
4100
- majorVersion: majorVersion,
4101
- isSmartTV: isSmartTV,
4102
- isLegacyTV: isLegacyTV,
4103
- platform: platform,
4104
- supportsModernJS: supportsModernJS2,
4105
- webOSVersion: webOSVersion,
4106
- tizenVersion: tizenVersion,
4107
- chromeVersion: chromeVersionNum
4108
- };
4109
- }
4110
- function requiresMediaPipelineResetAfterAds() {
4111
- var _browser_tizenVersion;
4112
- var browser = detectBrowser();
4113
- return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
4114
- }
4115
- function getBrowserConfigOverrides() {
4116
- var browser = detectBrowser();
4117
- var overrides = {};
4118
- if (browser.isSmartTV) {
4119
- overrides.allowNativeHls = true;
4120
- overrides.pauseContentDuringAds = true;
4121
- }
4122
- return overrides;
4123
- }
4124
- function supportsModernJS() {
4125
- try {
4126
- return typeof Promise !== "undefined" && typeof Map !== "undefined" && typeof Set !== "undefined" && typeof Array.from !== "undefined" && typeof Object.assign !== "undefined" && typeof Array.prototype.forEach !== "undefined" && typeof String.prototype.includes !== "undefined";
4127
- } catch (e) {
4128
- return false;
4129
- }
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
- function supportsFeature(feature) {
4152
- switch(feature){
4153
- case "urlsearchparams":
4154
- return typeof URLSearchParams !== "undefined";
4155
- case "textencoder":
4156
- return typeof TextEncoder !== "undefined";
4157
- case "promises":
4158
- return typeof Promise !== "undefined";
4159
- case "fetch":
4160
- return typeof fetch !== "undefined";
4161
- case "crypto":
4162
- return typeof crypto !== "undefined" && typeof crypto.subtle !== "undefined";
4163
- default:
4164
- return false;
4165
- }
4166
- }
4167
4254
  // src/player/Scte35Parser.ts
4168
4255
  function parseCueOutDuration(value) {
4169
4256
  var num = parseFloat(value.trim());
@@ -6239,17 +6326,17 @@ var AdTimingService = /*#__PURE__*/ function() {
6239
6326
  {
6240
6327
  key: "logAdState",
6241
6328
  value: function logAdState(event) {
6242
- 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;
6243
- var _ref;
6329
+ var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6244
6330
  if (!this.debug) {
6245
6331
  return;
6246
6332
  }
6333
+ var _this_callbacks_getAdState = this.callbacks.getAdState(), inAdBreak = _this_callbacks_getAdState.inAdBreak, showAds = _this_callbacks_getAdState.showAds, adPlaying = _this_callbacks_getAdState.adPlaying;
6247
6334
  console.log("[StormcloudVideoPlayer][AdState]", _object_spread({
6248
6335
  event: event,
6249
6336
  timestamp: /* @__PURE__ */ new Date().toISOString(),
6250
- showAds: showAds !== null && showAds !== void 0 ? showAds : false,
6251
- adPlaying: (_ref = adPlayer === null || adPlayer === void 0 ? void 0 : adPlayer.isAdPlaying()) !== null && _ref !== void 0 ? _ref : false,
6252
- inAdBreak: inAdBreak !== null && inAdBreak !== void 0 ? inAdBreak : false,
6337
+ showAds: showAds,
6338
+ adPlaying: adPlaying,
6339
+ inAdBreak: inAdBreak,
6253
6340
  activeAdRequestToken: this.activeAdRequestToken
6254
6341
  }, extra));
6255
6342
  }
@@ -8603,6 +8690,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8603
8690
  },
8604
8691
  onFailsafeTimeout: function onFailsafeTimeout() {
8605
8692
  return _this.adBreak.handleAdFailure();
8693
+ },
8694
+ getAdState: function getAdState() {
8695
+ return {
8696
+ inAdBreak: _this.adBreak.inAdBreak,
8697
+ showAds: _this.adBreak.showAds,
8698
+ adPlaying: _this.adPlayer.isAdPlaying()
8699
+ };
8606
8700
  }
8607
8701
  });
8608
8702
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);