fix: stop audio playback when currently playing track is deleted

This commit is contained in:
Armin 2026-07-08 16:26:58 +02:00
commit c944e1eb4a

View file

@ -1043,6 +1043,14 @@ function deleteTrack() {
if (selectedIndices.size === 0) return; if (selectedIndices.size === 0) return;
const sortedSel = [...selectedIndices].sort((a, b) => a - b); const sortedSel = [...selectedIndices].sort((a, b) => a - b);
const willDeleteCurrent = selectedIndices.has(currentIndex); const willDeleteCurrent = selectedIndices.has(currentIndex);
if (willDeleteCurrent) {
audio.pause();
audio.currentTime = 0;
if (isCrossfading) {
audioNext.pause();
audioNext.currentTime = 0;
}
}
if (selectedIndices.size === tracks.length) { if (selectedIndices.size === tracks.length) {
for (const idx of sortedSel) { for (const idx of sortedSel) {
if (idx !== currentIndex) URL.revokeObjectURL(tracks[idx].url); if (idx !== currentIndex) URL.revokeObjectURL(tracks[idx].url);