improvements

This commit is contained in:
Julien Maille 2025-12-26 23:15:09 +01:00
parent aeea0038f3
commit 9ffe81e38b

View file

@ -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();
}