mirror of
https://codeberg.org/armin/noiz.git
synced 2026-09-01 05:50:52 +02:00
fix: don't stop playback when deleting the current track from playlist
This commit is contained in:
parent
357e07ad32
commit
154f003787
1 changed files with 16 additions and 1 deletions
17
index.html
17
index.html
|
|
@ -1045,7 +1045,18 @@ function deleteTrack() {
|
|||
if (selectedIndices.size === 0) return;
|
||||
const sortedSel = [...selectedIndices].sort((a, b) => a - b);
|
||||
const willDeleteCurrent = selectedIndices.has(currentIndex);
|
||||
if (willDeleteCurrent) {
|
||||
let playNextOrigIdx = -1;
|
||||
if (willDeleteCurrent && selectedIndices.size < tracks.length) {
|
||||
for (let i = currentIndex + 1; i < tracks.length; i++) {
|
||||
if (!selectedIndices.has(i)) { playNextOrigIdx = i; break; }
|
||||
}
|
||||
if (playNextOrigIdx === -1) {
|
||||
for (let i = currentIndex - 1; i >= 0; i--) {
|
||||
if (!selectedIndices.has(i)) { playNextOrigIdx = i; break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (willDeleteCurrent && playNextOrigIdx === -1) {
|
||||
audio.pause();
|
||||
audio.currentTime = 0;
|
||||
if (isCrossfading) {
|
||||
|
|
@ -1069,6 +1080,10 @@ function deleteTrack() {
|
|||
for (let j = sortedSel.length - 1; j >= 0; j--) tracks.splice(sortedSel[j], 1);
|
||||
selectedIndices.clear();
|
||||
if (willDeleteCurrent) {
|
||||
if (playNextOrigIdx >= 0) {
|
||||
const removedBefore = sortedSel.filter(idx => idx < playNextOrigIdx).length;
|
||||
pendingNextIndex = playNextOrigIdx - removedBefore;
|
||||
}
|
||||
currentIndex = -1;
|
||||
} else {
|
||||
const removedBefore = sortedSel.filter(idx => idx < currentIndex).length;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue