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 <noreply@anthropic.com>
This commit is contained in:
parent
8681b2d3bd
commit
e4339fb54b
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue