From e4339fb54b19a54376f5bd250cc8e9ebd54a87a3 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Thu, 15 Jan 2026 02:02:02 +0530 Subject: [PATCH] fix(05-jamtrack): use jamTrack.mixdowns instead of jamClient API The error "Mixdown has no packages available" occurred because we were calling jamClient.JamTrackGetMixdowns() which returns a different data structure without the packages array. The packages are only available in the mixdowns returned from the REST API endpoint /api/jamtracks/{id}. Root cause: - jamClient.JamTrackGetMixdowns() returns simplified mixdown metadata - Full mixdown data with packages comes from REST API via getJamTrack() - The jamTrack object passed to downloadJamTrack already has mixdowns with their packages array Changes to mediaSlice.js downloadJamTrack: - Use jamTrack.mixdowns directly instead of calling jamClient API - Add comment explaining the difference in data sources - Improve error messages with mixdown names for debugging Changes to JKSessionJamTrackPlayer.js: - Use jamTrack.mixdowns directly in initialization - Update comment to clarify data source This ensures the pickMyPackage logic has access to the packages array needed to select the correct package variant (ogg, jkz, sample rate). Fixes "Mixdown has no packages available" error during JamTrack playback. Co-Authored-By: Claude Sonnet 4.5 --- .../client/JKSessionJamTrackPlayer.js | 6 +++--- jam-ui/src/store/features/mediaSlice.js | 17 +++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/jam-ui/src/components/client/JKSessionJamTrackPlayer.js b/jam-ui/src/components/client/JKSessionJamTrackPlayer.js index 900f603b4..e405dd969 100644 --- a/jam-ui/src/components/client/JKSessionJamTrackPlayer.js +++ b/jam-ui/src/components/client/JKSessionJamTrackPlayer.js @@ -88,9 +88,9 @@ const JKSessionJamTrackPlayer = ({ // Download flow will be triggered by loadJamTrack (no diagnostic logging) } - // Fetch available mixdowns + // Use mixdowns from jamTrack object (fetched from REST API with packages) try { - const mixdowns = await jamClient.JamTrackGetMixdowns(jamTrack.id); + const mixdowns = jamTrack.mixdowns; if (mixdowns && mixdowns.length > 0) { // Organize into hierarchy: master, custom mixes, stems @@ -118,7 +118,7 @@ const JKSessionJamTrackPlayer = ({ } } } catch (err) { - console.error('[JamTrack] Failed to fetch mixdowns:', err); + console.error('[JamTrack] Failed to load mixdowns:', err); // Non-fatal - can still play default mixdown } diff --git a/jam-ui/src/store/features/mediaSlice.js b/jam-ui/src/store/features/mediaSlice.js index 15b110e39..0ad29bfd8 100644 --- a/jam-ui/src/store/features/mediaSlice.js +++ b/jam-ui/src/store/features/mediaSlice.js @@ -62,20 +62,25 @@ export const downloadJamTrack = createAsyncThunk( // Get client sample rate for package selection (pickMyPackage logic) const sampleRate = await jamClient.GetSampleRate(); - // Get mixdowns and find compatible package - const mixdowns = await jamClient.JamTrackGetMixdowns(jamTrack.id); + // Use mixdowns from jamTrack object (fetched from REST API) + // jamClient.JamTrackGetMixdowns returns a different structure without packages + const mixdowns = jamTrack.mixdowns; if (!mixdowns || mixdowns.length === 0) { throw new Error('No mixdowns available for this JamTrack'); } - // Find the first mixdown (use selected mixdownId if provided, else use first) + // Find the mixdown (use selected mixdownId if provided, else use first) const mixdown = mixdownId ? mixdowns.find(m => m.id === mixdownId) || mixdowns[0] : mixdowns[0]; - if (!mixdown || !mixdown.packages || mixdown.packages.length === 0) { - throw new Error('Mixdown has no packages available'); + if (!mixdown) { + throw new Error('Selected mixdown not found'); + } + + if (!mixdown.packages || mixdown.packages.length === 0) { + throw new Error(`Mixdown "${mixdown.name}" has no packages available`); } // pickMyPackage logic: find compatible package (ogg, jkz, matching sample rate) @@ -86,7 +91,7 @@ export const downloadJamTrack = createAsyncThunk( ); if (!compatiblePackage) { - throw new Error(`No compatible package found for sample rate ${sampleRate}kHz`); + throw new Error(`No compatible package found for sample rate ${sampleRate}kHz (mixdown: ${mixdown.name})`); } const packageId = compatiblePackage.id;