keep visualizers active after clearing playlist while audio is still playing

This commit is contained in:
Armin 2026-07-08 19:31:52 +02:00
commit cba38cf500

View file

@ -560,7 +560,7 @@ function drawSpectrum() {
}
}
const vuCanvas = document.getElementById('vuMeter');
if (vuCanvas && tracks.length && analyserL && analyserR) {
if (vuCanvas && (tracks.length || !audio.paused) && analyserL && analyserR) {
const vuctx = vuCanvas.getContext('2d');
const vuRect = vuCanvas.getBoundingClientRect();
const vuDpr = window.devicePixelRatio || 1;
@ -1683,13 +1683,14 @@ isolateBtn.addEventListener('click', isolateTracks);
deleteBtn.addEventListener('click', deleteTrack);
clearBtn.addEventListener('click', () => {
if (tracks.length === 0) return;
audio.pause();
audio.src = '';
audio.load();
if (isCrossfading) { audioNext.pause(); audioNext.src = ''; audioNext.load(); }
for (const t of tracks) URL.revokeObjectURL(t.url);
tracks = [];
currentIndex = -1;
if (currentIndex >= 0) {
const current = tracks[currentIndex];
tracks = [current];
currentIndex = 0;
} else {
tracks = [];
currentIndex = -1;
}
selectedIndices.clear();
anchorTrack = null;
renderTracks();