stormcloud-video-player 0.8.50 → 0.8.52
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/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +283 -225
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +283 -225
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +260 -202
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +260 -202
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +260 -202
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +231 -30
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +260 -202
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
- package/lib/types-iDjS8f_7.d.cts +0 -133
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;
|
|
@@ -382,6 +578,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
382
578
|
var AD_CONTAINER_PROP = "__stormcloudAdContainer";
|
|
383
579
|
var AD_VIDEO_PROP = "__stormcloudAdVideo";
|
|
384
580
|
var FRAME_COUNTER_RELIABLE_PROP = "__stormcloudFrameCounterReliable";
|
|
581
|
+
var RVFC_RELIABLE_PROP = "__stormcloudRvfcReliable";
|
|
385
582
|
var adVideoElement = (_contentVideo_AD_VIDEO_PROP = contentVideo[AD_VIDEO_PROP]) !== null && _contentVideo_AD_VIDEO_PROP !== void 0 ? _contentVideo_AD_VIDEO_PROP : void 0;
|
|
386
583
|
var adHls;
|
|
387
584
|
var adContainerEl = (_contentVideo_AD_CONTAINER_PROP = contentVideo[AD_CONTAINER_PROP]) !== null && _contentVideo_AD_CONTAINER_PROP !== void 0 ? _contentVideo_AD_CONTAINER_PROP : void 0;
|
|
@@ -402,6 +599,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
402
599
|
var lastAdProgressPosition = 0;
|
|
403
600
|
var sawDecodedVideoFrame = false;
|
|
404
601
|
var videoFrameCallbackHandle;
|
|
602
|
+
var pendingPlayPromise;
|
|
405
603
|
var trackingFired = {
|
|
406
604
|
impression: false,
|
|
407
605
|
start: false,
|
|
@@ -1205,6 +1403,60 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1205
1403
|
complete: false
|
|
1206
1404
|
};
|
|
1207
1405
|
}
|
|
1406
|
+
function isRvfcSupported(video) {
|
|
1407
|
+
return typeof video.requestVideoFrameCallback === "function";
|
|
1408
|
+
}
|
|
1409
|
+
function settlePendingPlay() {
|
|
1410
|
+
pendingPlayPromise = void 0;
|
|
1411
|
+
}
|
|
1412
|
+
function startAdPlayback(context) {
|
|
1413
|
+
if (!adVideoElement) return;
|
|
1414
|
+
var playPromise = adVideoElement.play();
|
|
1415
|
+
pendingPlayPromise = playPromise;
|
|
1416
|
+
playPromise.catch(function(error) {
|
|
1417
|
+
if (pendingPlayPromise !== playPromise) {
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
console.error("[HlsAdPlayer] Error starting ".concat(context, ":"), error);
|
|
1421
|
+
handleAdError();
|
|
1422
|
+
}).finally(function() {
|
|
1423
|
+
if (pendingPlayPromise === playPromise) {
|
|
1424
|
+
pendingPlayPromise = void 0;
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
function prepareVideoElementForNewSource() {
|
|
1429
|
+
settlePendingPlay();
|
|
1430
|
+
if (adHls) {
|
|
1431
|
+
adHls.destroy();
|
|
1432
|
+
adHls = void 0;
|
|
1433
|
+
}
|
|
1434
|
+
if (!adVideoElement) return;
|
|
1435
|
+
try {
|
|
1436
|
+
adVideoElement.pause();
|
|
1437
|
+
adVideoElement.removeAttribute("src");
|
|
1438
|
+
adVideoElement.load();
|
|
1439
|
+
} catch (error) {
|
|
1440
|
+
console.warn("[HlsAdPlayer] Error preparing ad video for new source:", error);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
function recreateAdVideoElement() {
|
|
1444
|
+
console.log("[HlsAdPlayer] Recreating ad video element (single-decoder platform)");
|
|
1445
|
+
teardownAdEventListeners();
|
|
1446
|
+
prepareVideoElementForNewSource();
|
|
1447
|
+
if (adVideoElement) {
|
|
1448
|
+
try {
|
|
1449
|
+
adVideoElement.remove();
|
|
1450
|
+
} catch (error) {
|
|
1451
|
+
console.warn("[HlsAdPlayer] Error removing ad video element:", error);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
adVideoElement = createAdVideoElement();
|
|
1455
|
+
adContainerEl === null || adContainerEl === void 0 ? void 0 : adContainerEl.appendChild(adVideoElement);
|
|
1456
|
+
contentVideo[AD_VIDEO_PROP] = adVideoElement;
|
|
1457
|
+
adVideoElement.volume = Math.max(0, Math.min(1, originalVolume));
|
|
1458
|
+
adVideoElement.muted = originalMutedState;
|
|
1459
|
+
}
|
|
1208
1460
|
function loadCurrentAdMedia() {
|
|
1209
1461
|
if (!adVideoElement || !currentAd) {
|
|
1210
1462
|
throw new Error("No ad video element or ad to load");
|
|
@@ -1227,10 +1479,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1227
1479
|
adHls.attachMedia(adVideoElement);
|
|
1228
1480
|
adHls.on(Hls.Events.MANIFEST_PARSED, function() {
|
|
1229
1481
|
console.log("[HlsAdPlayer] HLS manifest parsed, starting playback");
|
|
1230
|
-
|
|
1231
|
-
console.error("[HlsAdPlayer] Error starting ad playback:", error);
|
|
1232
|
-
handleAdError();
|
|
1233
|
-
});
|
|
1482
|
+
startAdPlayback("HLS ad playback");
|
|
1234
1483
|
});
|
|
1235
1484
|
adHls.on(Hls.Events.ERROR, function(_event, data) {
|
|
1236
1485
|
console.error("[HlsAdPlayer] HLS error:", data);
|
|
@@ -1240,10 +1489,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1240
1489
|
});
|
|
1241
1490
|
} else if (isHlsAd && adVideoElement.canPlayType("application/vnd.apple.mpegurl")) {
|
|
1242
1491
|
adVideoElement.src = mediaFile.url;
|
|
1243
|
-
|
|
1244
|
-
console.error("[HlsAdPlayer] Error starting ad playback:", error);
|
|
1245
|
-
handleAdError();
|
|
1246
|
-
});
|
|
1492
|
+
startAdPlayback("native HLS ad playback");
|
|
1247
1493
|
} else if (!isHlsAd && isProgressiveMediaFile(mediaFile)) {
|
|
1248
1494
|
if (adHls) {
|
|
1249
1495
|
adHls.destroy();
|
|
@@ -1251,10 +1497,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1251
1497
|
}
|
|
1252
1498
|
adVideoElement.src = mediaFile.url;
|
|
1253
1499
|
adVideoElement.load();
|
|
1254
|
-
|
|
1255
|
-
console.error("[HlsAdPlayer] Error starting progressive ad playback:", error);
|
|
1256
|
-
handleAdError();
|
|
1257
|
-
});
|
|
1500
|
+
startAdPlayback("progressive ad playback");
|
|
1258
1501
|
} else {
|
|
1259
1502
|
throw new Error("Unsupported ad media file type: ".concat(mediaFile.type));
|
|
1260
1503
|
}
|
|
@@ -1271,6 +1514,13 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1271
1514
|
trackingFired.impression = true;
|
|
1272
1515
|
console.log("[HlsAdPlayer] Advancing to next pod ad (".concat(podIndex + 1, "/").concat(podAds.length, "): ").concat(currentAd.title, ", duration: ").concat(currentAd.duration, "s"));
|
|
1273
1516
|
}
|
|
1517
|
+
clearStallWatchdog();
|
|
1518
|
+
if (requiresMediaPipelineResetAfterAds()) {
|
|
1519
|
+
recreateAdVideoElement();
|
|
1520
|
+
setupAdEventListeners();
|
|
1521
|
+
} else {
|
|
1522
|
+
prepareVideoElementForNewSource();
|
|
1523
|
+
}
|
|
1274
1524
|
try {
|
|
1275
1525
|
loadCurrentAdMedia();
|
|
1276
1526
|
emit("pod_ad_started", {
|
|
@@ -1330,6 +1580,12 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1330
1580
|
function markFrameCounterReliable() {
|
|
1331
1581
|
contentVideo[FRAME_COUNTER_RELIABLE_PROP] = true;
|
|
1332
1582
|
}
|
|
1583
|
+
function isRvfcReliable() {
|
|
1584
|
+
return contentVideo[RVFC_RELIABLE_PROP] === true;
|
|
1585
|
+
}
|
|
1586
|
+
function markRvfcReliable() {
|
|
1587
|
+
contentVideo[RVFC_RELIABLE_PROP] = true;
|
|
1588
|
+
}
|
|
1333
1589
|
function cancelVideoFrameProbe() {
|
|
1334
1590
|
if (videoFrameCallbackHandle != null && adVideoElement && typeof adVideoElement.cancelVideoFrameCallback === "function") {
|
|
1335
1591
|
try {
|
|
@@ -1349,6 +1605,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1349
1605
|
videoFrameCallbackHandle = void 0;
|
|
1350
1606
|
if (!adPlaying) return;
|
|
1351
1607
|
sawDecodedVideoFrame = true;
|
|
1608
|
+
markRvfcReliable();
|
|
1352
1609
|
};
|
|
1353
1610
|
try {
|
|
1354
1611
|
videoFrameCallbackHandle = rvfc.call(adVideoElement, onPresentedFrame);
|
|
@@ -1373,18 +1630,26 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1373
1630
|
noteAdProgress();
|
|
1374
1631
|
sawDecodedVideoFrame = false;
|
|
1375
1632
|
startVideoFrameProbe();
|
|
1633
|
+
var blackFrameDetectionEnabled = !requiresMediaPipelineResetAfterAds();
|
|
1376
1634
|
stallWatchdogId = window.setInterval(function() {
|
|
1377
1635
|
if (!adPlaying || !adVideoElement) {
|
|
1378
1636
|
return;
|
|
1379
1637
|
}
|
|
1380
|
-
if (!sawDecodedVideoFrame && !adVideoElement.paused) {
|
|
1638
|
+
if (blackFrameDetectionEnabled && !sawDecodedVideoFrame && !adVideoElement.paused) {
|
|
1381
1639
|
var decodedFrames = getDecodedVideoFrameCount(adVideoElement);
|
|
1382
1640
|
if (decodedFrames !== void 0 && decodedFrames > 0) {
|
|
1383
1641
|
sawDecodedVideoFrame = true;
|
|
1384
1642
|
markFrameCounterReliable();
|
|
1385
|
-
} else if (
|
|
1386
|
-
|
|
1387
|
-
|
|
1643
|
+
} else if (adVideoElement.currentTime >= BLACKFRAME_MIN_PLAYBACK_S) {
|
|
1644
|
+
var timeAdvancing = adVideoElement.currentTime > lastAdProgressPosition + 0.05;
|
|
1645
|
+
if (isRvfcSupported(adVideoElement) && timeAdvancing && isRvfcReliable()) {
|
|
1646
|
+
handleVideoDecodeFailure();
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
if (decodedFrames === 0 && timeAdvancing && isFrameCounterReliable()) {
|
|
1650
|
+
handleVideoDecodeFailure();
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1388
1653
|
}
|
|
1389
1654
|
}
|
|
1390
1655
|
if (adVideoElement.currentTime > lastAdProgressPosition + 0.05) {
|
|
@@ -1401,19 +1666,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1401
1666
|
}, STALL_CHECK_INTERVAL_MS);
|
|
1402
1667
|
}
|
|
1403
1668
|
function releaseAdDecoder() {
|
|
1404
|
-
|
|
1405
|
-
adHls.destroy();
|
|
1406
|
-
adHls = void 0;
|
|
1407
|
-
}
|
|
1408
|
-
if (adVideoElement) {
|
|
1409
|
-
try {
|
|
1410
|
-
adVideoElement.pause();
|
|
1411
|
-
adVideoElement.removeAttribute("src");
|
|
1412
|
-
adVideoElement.load();
|
|
1413
|
-
} catch (error) {
|
|
1414
|
-
console.warn("[HlsAdPlayer] Error releasing ad decoder:", error);
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1669
|
+
prepareVideoElementForNewSource();
|
|
1417
1670
|
if (adContainerEl) {
|
|
1418
1671
|
adContainerEl.style.display = "none";
|
|
1419
1672
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -1790,7 +2043,7 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
1790
2043
|
}
|
|
1791
2044
|
},
|
|
1792
2045
|
hidePlaceholder: function hidePlaceholder() {
|
|
1793
|
-
if (adContainerEl) {
|
|
2046
|
+
if (adContainerEl && !adPlaying) {
|
|
1794
2047
|
adContainerEl.style.display = "none";
|
|
1795
2048
|
adContainerEl.style.pointerEvents = "none";
|
|
1796
2049
|
}
|
|
@@ -4007,201 +4260,6 @@ function fetchConsentSignals() {
|
|
|
4007
4260
|
return signals;
|
|
4008
4261
|
});
|
|
4009
4262
|
}
|
|
4010
|
-
// src/utils/browserCompat.ts
|
|
4011
|
-
function getChromeVersion(ua) {
|
|
4012
|
-
var match = ua.match(/Chrome\/(\d+)/);
|
|
4013
|
-
return match && match[1] ? parseInt(match[1], 10) : 0;
|
|
4014
|
-
}
|
|
4015
|
-
function getWebKitVersion(ua) {
|
|
4016
|
-
var match = ua.match(/AppleWebKit\/(\d+)/);
|
|
4017
|
-
return match && match[1] ? parseInt(match[1], 10) : 0;
|
|
4018
|
-
}
|
|
4019
|
-
function getPlatform() {
|
|
4020
|
-
var _navigator_userAgentData;
|
|
4021
|
-
if ("userAgentData" in navigator && ((_navigator_userAgentData = navigator.userAgentData) === null || _navigator_userAgentData === void 0 ? void 0 : _navigator_userAgentData.platform)) {
|
|
4022
|
-
return navigator.userAgentData.platform;
|
|
4023
|
-
}
|
|
4024
|
-
var ua = navigator.userAgent;
|
|
4025
|
-
if (/Mac|iPhone|iPad|iPod/i.test(ua)) {
|
|
4026
|
-
return /iPhone|iPad|iPod/i.test(ua) ? "iPhone" : "MacIntel";
|
|
4027
|
-
}
|
|
4028
|
-
if (/Win/i.test(ua)) {
|
|
4029
|
-
return "Win32";
|
|
4030
|
-
}
|
|
4031
|
-
if (/Linux/i.test(ua)) {
|
|
4032
|
-
return /Android/i.test(ua) ? "Linux armv8l" : "Linux x86_64";
|
|
4033
|
-
}
|
|
4034
|
-
if (/CrOS/i.test(ua)) {
|
|
4035
|
-
return "CrOS";
|
|
4036
|
-
}
|
|
4037
|
-
return navigator.platform || "Unknown";
|
|
4038
|
-
}
|
|
4039
|
-
function detectBrowser() {
|
|
4040
|
-
var ua = navigator.userAgent;
|
|
4041
|
-
var platform = getPlatform();
|
|
4042
|
-
var name = "Unknown";
|
|
4043
|
-
var version = "0";
|
|
4044
|
-
var majorVersion = 0;
|
|
4045
|
-
var isSmartTV = false;
|
|
4046
|
-
var isLegacyTV = false;
|
|
4047
|
-
var supportsModernJS2 = true;
|
|
4048
|
-
var webOSVersion;
|
|
4049
|
-
var tizenVersion;
|
|
4050
|
-
var chromeVersionNum;
|
|
4051
|
-
var chromeVersion = getChromeVersion(ua);
|
|
4052
|
-
var webkitVersion = getWebKitVersion(ua);
|
|
4053
|
-
chromeVersionNum = chromeVersion > 0 ? chromeVersion : void 0;
|
|
4054
|
-
if (/Web0S|webOS|LG Browser|LGSTB/i.test(ua)) {
|
|
4055
|
-
name = "LG WebOS";
|
|
4056
|
-
isSmartTV = true;
|
|
4057
|
-
var match = ua.match(/Web0S[/\s]*([\d.]+)/i) || ua.match(/webOS[/\s]*([\d.]+)/i);
|
|
4058
|
-
if (!match || !match[1]) {
|
|
4059
|
-
match = ua.match(/webOSTV[/\s-]*([\d.]+)/i) || ua.match(/webOS\.TV[/\s-]*([\d.]+)/i);
|
|
4060
|
-
}
|
|
4061
|
-
if (match && match[1]) {
|
|
4062
|
-
version = match[1];
|
|
4063
|
-
var parts = version.split(".");
|
|
4064
|
-
majorVersion = parts[0] ? parseInt(parts[0], 10) : 0;
|
|
4065
|
-
webOSVersion = majorVersion;
|
|
4066
|
-
} else if (chromeVersion > 0) {
|
|
4067
|
-
if (chromeVersion >= 79) {
|
|
4068
|
-
webOSVersion = 6;
|
|
4069
|
-
version = "6.0";
|
|
4070
|
-
majorVersion = 6;
|
|
4071
|
-
} else if (chromeVersion >= 68) {
|
|
4072
|
-
webOSVersion = 5;
|
|
4073
|
-
version = "5.0";
|
|
4074
|
-
majorVersion = 5;
|
|
4075
|
-
} else if (chromeVersion >= 53) {
|
|
4076
|
-
webOSVersion = 4;
|
|
4077
|
-
version = "4.0";
|
|
4078
|
-
majorVersion = 4;
|
|
4079
|
-
} else if (chromeVersion >= 38) {
|
|
4080
|
-
webOSVersion = 3;
|
|
4081
|
-
version = "3.0";
|
|
4082
|
-
majorVersion = 3;
|
|
4083
|
-
} else {
|
|
4084
|
-
webOSVersion = 2;
|
|
4085
|
-
version = "2.0";
|
|
4086
|
-
majorVersion = 2;
|
|
4087
|
-
}
|
|
4088
|
-
} else {
|
|
4089
|
-
version = "Unknown";
|
|
4090
|
-
webOSVersion = void 0;
|
|
4091
|
-
}
|
|
4092
|
-
isLegacyTV = webOSVersion !== void 0 && webOSVersion < 3;
|
|
4093
|
-
} else if (/Tizen/i.test(ua)) {
|
|
4094
|
-
name = "Samsung Tizen";
|
|
4095
|
-
isSmartTV = true;
|
|
4096
|
-
var match1 = ua.match(/Tizen[/\s]*([\d.]+)/i);
|
|
4097
|
-
version = match1 && match1[1] ? match1[1] : "Unknown";
|
|
4098
|
-
if (version !== "Unknown") {
|
|
4099
|
-
var parts1 = version.split(".");
|
|
4100
|
-
majorVersion = parts1[0] ? parseInt(parts1[0], 10) : 0;
|
|
4101
|
-
tizenVersion = majorVersion;
|
|
4102
|
-
}
|
|
4103
|
-
isLegacyTV = tizenVersion !== void 0 && tizenVersion < 3;
|
|
4104
|
-
} else if (/SMART-TV|SmartTV/i.test(ua)) {
|
|
4105
|
-
name = "Smart TV";
|
|
4106
|
-
isSmartTV = true;
|
|
4107
|
-
isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
|
|
4108
|
-
} else if (/NetCast/i.test(ua)) {
|
|
4109
|
-
name = "LG NetCast";
|
|
4110
|
-
isSmartTV = true;
|
|
4111
|
-
isLegacyTV = true;
|
|
4112
|
-
} else if (/BRAVIA/i.test(ua)) {
|
|
4113
|
-
name = "Sony BRAVIA";
|
|
4114
|
-
isSmartTV = true;
|
|
4115
|
-
isLegacyTV = chromeVersion > 0 && chromeVersion < 53;
|
|
4116
|
-
} else {
|
|
4117
|
-
if (chromeVersion > 0) {
|
|
4118
|
-
name = "Chrome";
|
|
4119
|
-
version = chromeVersion.toString();
|
|
4120
|
-
majorVersion = chromeVersion;
|
|
4121
|
-
if (chromeVersion < 50) {
|
|
4122
|
-
supportsModernJS2 = false;
|
|
4123
|
-
}
|
|
4124
|
-
}
|
|
4125
|
-
if (webkitVersion > 0 && webkitVersion < 600) {
|
|
4126
|
-
supportsModernJS2 = false;
|
|
4127
|
-
}
|
|
4128
|
-
}
|
|
4129
|
-
if (typeof Promise === "undefined" || typeof Map === "undefined" || typeof Set === "undefined") {
|
|
4130
|
-
supportsModernJS2 = false;
|
|
4131
|
-
}
|
|
4132
|
-
if (typeof URLSearchParams === "undefined") {
|
|
4133
|
-
supportsModernJS2 = false;
|
|
4134
|
-
}
|
|
4135
|
-
return {
|
|
4136
|
-
name: name,
|
|
4137
|
-
version: version,
|
|
4138
|
-
majorVersion: majorVersion,
|
|
4139
|
-
isSmartTV: isSmartTV,
|
|
4140
|
-
isLegacyTV: isLegacyTV,
|
|
4141
|
-
platform: platform,
|
|
4142
|
-
supportsModernJS: supportsModernJS2,
|
|
4143
|
-
webOSVersion: webOSVersion,
|
|
4144
|
-
tizenVersion: tizenVersion,
|
|
4145
|
-
chromeVersion: chromeVersionNum
|
|
4146
|
-
};
|
|
4147
|
-
}
|
|
4148
|
-
function requiresMediaPipelineResetAfterAds() {
|
|
4149
|
-
var _browser_tizenVersion;
|
|
4150
|
-
var browser = detectBrowser();
|
|
4151
|
-
return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
|
|
4152
|
-
}
|
|
4153
|
-
function getBrowserConfigOverrides() {
|
|
4154
|
-
var browser = detectBrowser();
|
|
4155
|
-
var overrides = {};
|
|
4156
|
-
if (browser.isSmartTV) {
|
|
4157
|
-
overrides.allowNativeHls = true;
|
|
4158
|
-
overrides.pauseContentDuringAds = true;
|
|
4159
|
-
}
|
|
4160
|
-
return overrides;
|
|
4161
|
-
}
|
|
4162
|
-
function supportsModernJS() {
|
|
4163
|
-
try {
|
|
4164
|
-
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";
|
|
4165
|
-
} catch (e) {
|
|
4166
|
-
return false;
|
|
4167
|
-
}
|
|
4168
|
-
}
|
|
4169
|
-
function logBrowserInfo() {
|
|
4170
|
-
var debug = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
4171
|
-
if (!debug) return;
|
|
4172
|
-
var browser = detectBrowser();
|
|
4173
|
-
console.log("[StormcloudVideoPlayer] Browser Compatibility Info:", _object_spread_props(_object_spread({
|
|
4174
|
-
browser: "".concat(browser.name, " ").concat(browser.version),
|
|
4175
|
-
platform: browser.platform,
|
|
4176
|
-
isSmartTV: browser.isSmartTV,
|
|
4177
|
-
isLegacyTV: browser.isLegacyTV,
|
|
4178
|
-
supportsModernJS: browser.supportsModernJS
|
|
4179
|
-
}, browser.webOSVersion !== void 0 ? {
|
|
4180
|
-
webOSVersion: browser.webOSVersion
|
|
4181
|
-
} : {}, browser.tizenVersion !== void 0 ? {
|
|
4182
|
-
tizenVersion: browser.tizenVersion
|
|
4183
|
-
} : {}, browser.chromeVersion !== void 0 ? {
|
|
4184
|
-
chromeVersion: browser.chromeVersion
|
|
4185
|
-
} : {}), {
|
|
4186
|
-
userAgent: navigator.userAgent
|
|
4187
|
-
}));
|
|
4188
|
-
}
|
|
4189
|
-
function supportsFeature(feature) {
|
|
4190
|
-
switch(feature){
|
|
4191
|
-
case "urlsearchparams":
|
|
4192
|
-
return typeof URLSearchParams !== "undefined";
|
|
4193
|
-
case "textencoder":
|
|
4194
|
-
return typeof TextEncoder !== "undefined";
|
|
4195
|
-
case "promises":
|
|
4196
|
-
return typeof Promise !== "undefined";
|
|
4197
|
-
case "fetch":
|
|
4198
|
-
return typeof fetch !== "undefined";
|
|
4199
|
-
case "crypto":
|
|
4200
|
-
return typeof crypto !== "undefined" && typeof crypto.subtle !== "undefined";
|
|
4201
|
-
default:
|
|
4202
|
-
return false;
|
|
4203
|
-
}
|
|
4204
|
-
}
|
|
4205
4263
|
// src/player/Scte35Parser.ts
|
|
4206
4264
|
function parseCueOutDuration(value) {
|
|
4207
4265
|
var num = parseFloat(value.trim());
|