fix(audio): return format_id from play_track and set device name for backend system

1. play_track now returns PlayTrackResult with format_id from Qobuz API
   - Returns actual format (5=MP3, 6=FLAC16, 7=FLAC24, 27=Hi-Res)
   - Returns None for cache hits (format unknown)

2. Frontend updates track.format based on format_id
   - QualityBadge can now correctly show "MP3" when format_id=5
   - Previously badge showed "CD" even for MP3 because format was empty

3. Device name now set after backend system init
   - PipeWire and ALSA backends now set current_device from settings
   - Fixes tooltip showing no device when using backend system
This commit is contained in:
vicrodh committed 2026-02-01 04:27:23 -06:00
1 parent e08593af41
commit 52bde38d9f
3 files changed
+68 -10

No files matched your search

+29 -1
View File
@@ -49,6 +49,26 @@ import {
// ============ Types ============
/** Result from play_track command */
interface PlayTrackResult {
format_id: number | null;
}
/**
* Convert Qobuz format_id to format string for QualityBadge
* 5=MP3, 6=FLAC 16-bit (CD), 7=FLAC 24-bit (Hi-Res), 27=FLAC 24-bit Hi-Res+
*/
function formatIdToString(formatId: number | null): string | undefined {
if (formatId === null) return undefined;
switch (formatId) {
case 5: return 'mp3';
case 6: return 'flac';
case 7: return 'flac24';
case 27: return 'flac24';
default: return undefined;
}
}
export interface PlayTrackOptions {
isLocal?: boolean;
showLoadingToast?: boolean;
@@ -128,11 +148,19 @@ export async function playTrack(
if (isLocal) {
await invoke('library_play_track', { trackId: track.id });
} else {
await invoke('play_track', {
const result = await invoke<PlayTrackResult>('play_track', {
trackId: track.id,
durationSecs: track.duration,
quality: getStreamingQuality()
});
// Update track format based on actual stream format_id from Qobuz
const actualFormat = formatIdToString(result.format_id);
if (actualFormat) {
track.format = actualFormat;
// Re-set current track to update the UI with actual format
setCurrentTrack(track);
}
}
}