From 36d209de885e3fa93250b2c135cd8838fa9a56da Mon Sep 17 00:00:00 2001 From: Julien Maille Date: Fri, 16 Jan 2026 23:18:11 +0100 Subject: [PATCH] FIX: borken playback --- js/db.js | 10 ++++++++++ js/player.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/js/db.js b/js/db.js index 85f37b9..8107466 100644 --- a/js/db.js +++ b/js/db.js @@ -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); }); diff --git a/js/player.js b/js/player.js index bf769a4..6f9ce59 100644 --- a/js/player.js +++ b/js/player.js @@ -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);