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}`);
// 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);
});

View file

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