improvements
This commit is contained in:
parent
aeea0038f3
commit
9ffe81e38b
1 changed files with 27 additions and 12 deletions
39
js/player.js
39
js/player.js
|
|
@ -353,22 +353,37 @@ export class Player {
|
|||
|
||||
removeFromQueue(index) {
|
||||
const currentQueue = this.shuffleActive ? this.shuffledQueue : this.queue;
|
||||
|
||||
if (index < 0 || index >= currentQueue.length) return;
|
||||
|
||||
if (this.shuffleActive) {
|
||||
this.shuffledQueue.splice(index, 1);
|
||||
} else {
|
||||
this.queue.splice(index, 1);
|
||||
|
||||
// If removing current track
|
||||
if (index === this.currentQueueIndex) {
|
||||
// If playing, we might want to stop or just let it finish?
|
||||
// For now, let's just remove it.
|
||||
// If it's the last track, playback will stop naturally or we handle it?
|
||||
}
|
||||
|
||||
|
||||
if (index < this.currentQueueIndex) {
|
||||
this.currentQueueIndex--;
|
||||
} else if (index === this.currentQueueIndex) {
|
||||
if (currentQueue.length > 0) {
|
||||
this.playTrackFromQueue();
|
||||
}
|
||||
}
|
||||
|
||||
const removedTrack = currentQueue.splice(index, 1)[0];
|
||||
|
||||
if (this.shuffleActive) {
|
||||
// Also remove from original queue
|
||||
const originalIndex = this.originalQueueBeforeShuffle.findIndex(t => t.id === removedTrack.id); // Simple ID check
|
||||
if (originalIndex !== -1) {
|
||||
this.originalQueueBeforeShuffle.splice(originalIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
this.saveQueueState();
|
||||
this.preloadNextTracks();
|
||||
}
|
||||
|
||||
clearQueue() {
|
||||
this.queue = [];
|
||||
this.shuffledQueue = [];
|
||||
this.originalQueueBeforeShuffle = [];
|
||||
this.currentQueueIndex = -1;
|
||||
this.saveQueueState();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue