pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

prevent quality debounce

Pas d20066eb 7fa64efc

+29 -1
+29 -1
src/components/player/display/base.ts
··· 97 97 let lastValidDuration = 0; // Store the last valid duration to prevent reset during source switches 98 98 let lastValidTime = 0; // Store the last valid time to prevent reset during source switches 99 99 let shouldAutoplayAfterLoad = false; // Flag to track if we should autoplay after loading completes 100 + let qualityChangeTimeout: NodeJS.Timeout | null = null; // Timeout for debouncing rapid quality changes 100 101 101 102 const languagePromises = new Map< 102 103 string, ··· 308 309 }); 309 310 hls.on(Hls.Events.LEVEL_SWITCHED, () => { 310 311 if (!hls) return; 312 + 313 + // Don't process level switched events during debounced quality changes 314 + if (qualityChangeTimeout) return; 315 + 311 316 if (automaticQuality) { 312 317 // Only emit quality changes when automatic quality is enabled 313 318 const quality = hlsLevelToQuality(hls.levels[hls.currentLevel]); ··· 546 551 } 547 552 548 553 function unloadSource() { 554 + // Clear any pending quality change timeout 555 + if (qualityChangeTimeout) { 556 + clearTimeout(qualityChangeTimeout); 557 + qualityChangeTimeout = null; 558 + } 559 + 549 560 if (videoElement) { 550 561 videoElement.removeAttribute("src"); 551 562 videoElement.load(); ··· 564 575 if (videoElement) { 565 576 videoElement = null; 566 577 } 578 + // Clear any remaining timeout 579 + if (qualityChangeTimeout) { 580 + clearTimeout(qualityChangeTimeout); 581 + qualityChangeTimeout = null; 582 + } 567 583 } 568 584 569 585 function fullscreenChange() { ··· 643 659 }, 644 660 changeQuality(newAutomaticQuality, newPreferredQuality) { 645 661 if (source?.type !== "hls") return; 662 + 663 + // Clear any pending quality change to prevent race conditions 664 + if (qualityChangeTimeout) { 665 + clearTimeout(qualityChangeTimeout); 666 + qualityChangeTimeout = null; 667 + } 668 + 646 669 automaticQuality = newAutomaticQuality; 647 670 preferenceQuality = newPreferredQuality; 648 - setupQualityForHls(); 671 + 672 + // Debounce quality changes to prevent rapid switching issues 673 + qualityChangeTimeout = setTimeout(() => { 674 + setupQualityForHls(); 675 + qualityChangeTimeout = null; 676 + }, 100); // 100ms debounce delay 649 677 }, 650 678 651 679 processVideoElement(video) {