mirror of
https://github.com/siddharthvaddem/openscreen.git
synced 2026-11-02 04:54:20 +08:00
fix: clear stale peaks before decoding a new source
Reset peaks to null immediately when an uncached URL is set, so the previous video's waveform is not shown during decode. Also clear on decode failure so stale data does not persist indefinitely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
98f7441dfa
commit
f19d1bc668
@@ -70,6 +70,7 @@ export function useAudioPeaks(videoUrl?: string): Float32Array | null {
|
||||
return;
|
||||
}
|
||||
|
||||
setPeaks(null);
|
||||
let cancelled = false;
|
||||
|
||||
(async () => {
|
||||
@@ -83,7 +84,8 @@ export function useAudioPeaks(videoUrl?: string): Float32Array | null {
|
||||
cacheRef.current.set(videoUrl, p);
|
||||
setPeaks(p);
|
||||
} catch {
|
||||
// No audio track or unsupported format — silent degradation.
|
||||
// No audio track or unsupported format — clear stale data silently.
|
||||
if (!cancelled) setPeaks(null);
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user