unified-video-framework 1.4.252 → 1.4.253
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.
|
@@ -1280,6 +1280,12 @@ export class WebPlayer extends BasePlayer {
|
|
|
1280
1280
|
this.state.isPaused = false;
|
|
1281
1281
|
this.state.isBuffering = false;
|
|
1282
1282
|
this.updateYouTubeUI('playing');
|
|
1283
|
+
|
|
1284
|
+
// Extract qualities when video starts playing
|
|
1285
|
+
setTimeout(() => {
|
|
1286
|
+
this.extractYouTubeAvailableQualities();
|
|
1287
|
+
}, 1000);
|
|
1288
|
+
|
|
1283
1289
|
this.emit('onPlay');
|
|
1284
1290
|
break;
|
|
1285
1291
|
|
|
@@ -1294,6 +1300,12 @@ export class WebPlayer extends BasePlayer {
|
|
|
1294
1300
|
case window.YT.PlayerState.BUFFERING:
|
|
1295
1301
|
this.state.isBuffering = true;
|
|
1296
1302
|
this.updateYouTubeUI('buffering');
|
|
1303
|
+
|
|
1304
|
+
// Try to extract qualities during buffering as well
|
|
1305
|
+
setTimeout(() => {
|
|
1306
|
+
this.extractYouTubeAvailableQualities();
|
|
1307
|
+
}, 500);
|
|
1308
|
+
|
|
1297
1309
|
this.emit('onBuffering', true);
|
|
1298
1310
|
break;
|
|
1299
1311
|
|
|
@@ -1425,14 +1437,28 @@ export class WebPlayer extends BasePlayer {
|
|
|
1425
1437
|
private youtubeCurrentQuality: any = null;
|
|
1426
1438
|
|
|
1427
1439
|
/**
|
|
1428
|
-
* Extract available YouTube video qualities
|
|
1440
|
+
* Extract available YouTube video qualities with retry logic
|
|
1429
1441
|
*/
|
|
1430
|
-
private extractYouTubeAvailableQualities(): void {
|
|
1431
|
-
if (!this.youtubePlayer)
|
|
1442
|
+
private extractYouTubeAvailableQualities(retryCount: number = 0): void {
|
|
1443
|
+
if (!this.youtubePlayer || !this.youtubePlayerReady) {
|
|
1444
|
+
this.debugLog('YouTube player not ready for quality extraction');
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1432
1447
|
|
|
1433
1448
|
try {
|
|
1434
1449
|
const availableQualityLevels = this.youtubePlayer.getAvailableQualityLevels();
|
|
1435
|
-
this.debugLog('YouTube
|
|
1450
|
+
this.debugLog('🔍 YouTube quality detection attempt', retryCount + 1, '- Found levels:', availableQualityLevels);
|
|
1451
|
+
this.debugLog('🔍 YouTube player state:', this.youtubePlayer.getPlayerState());
|
|
1452
|
+
this.debugLog('🔍 Current YouTube quality:', this.youtubePlayer.getPlaybackQuality());
|
|
1453
|
+
|
|
1454
|
+
// If no qualities detected and we haven't retried too much, retry after a delay
|
|
1455
|
+
if ((!availableQualityLevels || availableQualityLevels.length === 0 || (availableQualityLevels.length === 1 && availableQualityLevels[0] === 'auto')) && retryCount < 5) {
|
|
1456
|
+
this.debugLog('No meaningful qualities detected, retrying in', (retryCount + 1) * 1000, 'ms...');
|
|
1457
|
+
setTimeout(() => {
|
|
1458
|
+
this.extractYouTubeAvailableQualities(retryCount + 1);
|
|
1459
|
+
}, (retryCount + 1) * 1000);
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1436
1462
|
|
|
1437
1463
|
// Map YouTube quality levels to standard labels
|
|
1438
1464
|
const qualityMap: Record<string, any> = {
|
|
@@ -1446,18 +1472,25 @@ export class WebPlayer extends BasePlayer {
|
|
|
1446
1472
|
};
|
|
1447
1473
|
|
|
1448
1474
|
this.youtubeAvailableQualities = [];
|
|
1449
|
-
availableQualityLevels.forEach((qualityLevel: string) => {
|
|
1450
|
-
// Skip 'auto' from YouTube API - we'll add it explicitly
|
|
1451
|
-
if (qualityLevel === 'auto') return;
|
|
1452
|
-
if (qualityMap[qualityLevel]) {
|
|
1453
|
-
this.youtubeAvailableQualities.push(qualityMap[qualityLevel]);
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
1475
|
|
|
1457
|
-
// Always add auto quality option
|
|
1458
|
-
this.youtubeAvailableQualities.
|
|
1476
|
+
// Always add auto quality option first
|
|
1477
|
+
this.youtubeAvailableQualities.push({ label: 'Auto', value: 'auto', height: 0 });
|
|
1459
1478
|
|
|
1460
|
-
|
|
1479
|
+
// Add detected qualities, filtering out 'auto' since we already added it
|
|
1480
|
+
if (availableQualityLevels && availableQualityLevels.length > 0) {
|
|
1481
|
+
availableQualityLevels.forEach((qualityLevel: string) => {
|
|
1482
|
+
if (qualityLevel !== 'auto' && qualityMap[qualityLevel]) {
|
|
1483
|
+
this.youtubeAvailableQualities.push(qualityMap[qualityLevel]);
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
|
|
1487
|
+
// Sort qualities by height (descending, excluding auto)
|
|
1488
|
+
const autoQuality = this.youtubeAvailableQualities.shift(); // Remove auto temporarily
|
|
1489
|
+
this.youtubeAvailableQualities.sort((a, b) => (b.height || 0) - (a.height || 0));
|
|
1490
|
+
if (autoQuality) this.youtubeAvailableQualities.unshift(autoQuality); // Add auto back at beginning
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
this.debugLog('✅ Successfully mapped YouTube qualities:', this.youtubeAvailableQualities);
|
|
1461
1494
|
|
|
1462
1495
|
// Get current quality
|
|
1463
1496
|
try {
|
|
@@ -1469,14 +1502,28 @@ export class WebPlayer extends BasePlayer {
|
|
|
1469
1502
|
this.youtubeCurrentQuality = qualityMap['auto'];
|
|
1470
1503
|
}
|
|
1471
1504
|
|
|
1505
|
+
// Update detected qualities to include YouTube qualities
|
|
1506
|
+
this.detectAvailableQualities();
|
|
1507
|
+
|
|
1508
|
+
this.debugLog('🚀 YouTube qualities successfully detected! Available qualities now:', this.availableQualities.length);
|
|
1509
|
+
|
|
1472
1510
|
// Update quality badge with current YouTube quality
|
|
1473
1511
|
this.updateQualityBadge();
|
|
1474
1512
|
|
|
1475
|
-
//
|
|
1476
|
-
|
|
1513
|
+
// Force settings menu refresh with new qualities
|
|
1514
|
+
setTimeout(() => {
|
|
1515
|
+
this.debugLog('🔄 Force refreshing settings menu with YouTube qualities');
|
|
1516
|
+
this.updateSettingsMenu();
|
|
1517
|
+
}, 100);
|
|
1477
1518
|
|
|
1478
1519
|
} catch (error) {
|
|
1479
1520
|
this.debugWarn('Could not extract YouTube qualities:', error);
|
|
1521
|
+
// Retry if we haven't tried too many times
|
|
1522
|
+
if (retryCount < 3) {
|
|
1523
|
+
setTimeout(() => {
|
|
1524
|
+
this.extractYouTubeAvailableQualities(retryCount + 1);
|
|
1525
|
+
}, 2000);
|
|
1526
|
+
}
|
|
1480
1527
|
}
|
|
1481
1528
|
}
|
|
1482
1529
|
|
|
@@ -1563,6 +1610,8 @@ export class WebPlayer extends BasePlayer {
|
|
|
1563
1610
|
clearInterval(this.youtubeTimeTrackingInterval);
|
|
1564
1611
|
}
|
|
1565
1612
|
|
|
1613
|
+
let qualityCheckCounter = 0;
|
|
1614
|
+
|
|
1566
1615
|
this.youtubeTimeTrackingInterval = setInterval(() => {
|
|
1567
1616
|
if (this.youtubePlayer && this.youtubePlayerReady) {
|
|
1568
1617
|
try {
|
|
@@ -1574,6 +1623,14 @@ export class WebPlayer extends BasePlayer {
|
|
|
1574
1623
|
this.state.duration = duration || 0;
|
|
1575
1624
|
this.state.bufferedPercentage = buffered || 0;
|
|
1576
1625
|
|
|
1626
|
+
// Check for qualities periodically (every 10 seconds) if we don't have them yet
|
|
1627
|
+
qualityCheckCounter++;
|
|
1628
|
+
if (qualityCheckCounter >= 40 && this.youtubeAvailableQualities.length <= 1) { // 40 * 250ms = 10s
|
|
1629
|
+
this.debugLog('Periodic YouTube quality check triggered');
|
|
1630
|
+
this.extractYouTubeAvailableQualities();
|
|
1631
|
+
qualityCheckCounter = 0; // Reset counter
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1577
1634
|
// Update UI progress bar
|
|
1578
1635
|
this.updateYouTubeProgressBar(currentTime, duration, buffered);
|
|
1579
1636
|
|
|
@@ -9648,6 +9705,8 @@ export class WebPlayer extends BasePlayer {
|
|
|
9648
9705
|
|
|
9649
9706
|
// Quality Accordion Section (only if enabled in config and qualities detected)
|
|
9650
9707
|
if (this.settingsConfig.quality && this.availableQualities.length > 0) {
|
|
9708
|
+
this.debugLog('🎛️ Building quality menu with', this.availableQualities.length, 'qualities:', this.availableQualities.map(q => q.label));
|
|
9709
|
+
|
|
9651
9710
|
// For YouTube, use youtubeCurrentQuality; otherwise use currentQuality
|
|
9652
9711
|
const qualityForDisplay = this.youtubePlayer && this.youtubePlayerReady && this.youtubeCurrentQuality
|
|
9653
9712
|
? this.youtubeCurrentQuality.value
|
|
@@ -9655,6 +9714,8 @@ export class WebPlayer extends BasePlayer {
|
|
|
9655
9714
|
const currentQuality = this.availableQualities.find(q => q.value === qualityForDisplay);
|
|
9656
9715
|
const currentQualityLabel = currentQuality ? currentQuality.label : 'Auto';
|
|
9657
9716
|
|
|
9717
|
+
this.debugLog('🎛️ Current quality for display:', qualityForDisplay, '(', currentQualityLabel, ')');
|
|
9718
|
+
|
|
9658
9719
|
menuHTML += `
|
|
9659
9720
|
<div class="uvf-accordion-item">
|
|
9660
9721
|
<div class="uvf-accordion-header" data-section="quality">
|