mirror of
https://codeberg.org/armin/noiz.git
synced 2026-09-01 14:00:54 +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;
|
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) {
|
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.pause();
|
||||||
audio.currentTime = 0;
|
audio.currentTime = 0;
|
||||||
if (isCrossfading) {
|
if (isCrossfading) {
|
||||||
|
|
@ -1069,6 +1080,10 @@ function deleteTrack() {
|
||||||
for (let j = sortedSel.length - 1; j >= 0; j--) tracks.splice(sortedSel[j], 1);
|
for (let j = sortedSel.length - 1; j >= 0; j--) tracks.splice(sortedSel[j], 1);
|
||||||
selectedIndices.clear();
|
selectedIndices.clear();
|
||||||
if (willDeleteCurrent) {
|
if (willDeleteCurrent) {
|
||||||
|
if (playNextOrigIdx >= 0) {
|
||||||
|
const removedBefore = sortedSel.filter(idx => idx < playNextOrigIdx).length;
|
||||||
|
pendingNextIndex = playNextOrigIdx - removedBefore;
|
||||||
|
}
|
||||||
currentIndex = -1;
|
currentIndex = -1;
|
||||||
} else {
|
} else {
|
||||||
const removedBefore = sortedSel.filter(idx => idx < currentIndex).length;
|
const removedBefore = sortedSel.filter(idx => idx < currentIndex).length;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue