FIX: borken playback

This commit is contained in:
Julien Maille 2026-01-16 23:18:11 +01:00
parent 46240b85e2
commit 36d209de88
2 changed files with 12 additions and 2 deletions

View file

@ -337,6 +337,16 @@ export class MusicDatabase {
} }
console.log(`${storeName}: Adding item with ID ${item.id || item.uuid || item.timestamp}`); console.log(`${storeName}: Adding item with ID ${item.id || item.uuid || item.timestamp}`);
// Critical: Ensure key exists for IndexedDB store.put()
const keyPath = store.keyPath;
if (keyPath && !item[keyPath]) {
console.warn(`Item missing keyPath "${keyPath}" in ${storeName}, generating fallback.`);
if (keyPath === 'uuid') item.uuid = crypto.randomUUID();
else if (keyPath === 'id') item.id = item.trackId || item.albumId || item.artistId || Date.now() + Math.random();
else if (keyPath === 'timestamp') item.timestamp = Date.now() + Math.random();
}
store.put(item); store.put(item);
}); });

View file

@ -242,8 +242,7 @@ export class Player {
} }
} }
async playTrack(track, options = {}) { async playTrackFromQueue(startTime = 0) {
const { startTime = 0 } = options;
const currentQueue = this.shuffleActive ? this.shuffledQueue : this.queue; const currentQueue = this.shuffleActive ? this.shuffledQueue : this.queue;
if (this.currentQueueIndex < 0 || this.currentQueueIndex >= currentQueue.length) { if (this.currentQueueIndex < 0 || this.currentQueueIndex >= currentQueue.length) {
return; return;
@ -251,6 +250,7 @@ export class Player {
this.saveQueueState(); this.saveQueueState();
const track = currentQueue[this.currentQueueIndex];
this.currentTrack = track; this.currentTrack = track;
const trackTitle = getTrackTitle(track); const trackTitle = getTrackTitle(track);