From e45ef785cfb56457dbd7a1dcc959d6ef7ff3675a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A6=D0=B2=D1=8B=D0=BB=D0=B5=D0=B2=20=D0=90=D0=BB=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20=D0=92=D0=B0=D0=B4=D0=B8?= =?UTF-8?q?=D0=BC=D0=BE=D0=B2=D0=B8=D1=87?= Date: Tue, 28 Jul 2026 21:22:59 +0300 Subject: [PATCH] =?UTF-8?q?feat(player):=20stream=20at=20the=20chosen=20qu?= =?UTF-8?q?ality=20+=20per-track=20optimize=20(=C2=A76.6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Playback quality setting now drives streaming: getStreamUrl appends ?quality= and useAudioPlayer feeds the server-synced streamQuality, so the backend transcodes on demand (miss → original). Adds an optimizeTrack mutation and an Optimize action in the metadata editor to warm a track's rendition. Co-Authored-By: Claude Opus 4.8 --- src/api/endpoints/library.ts | 13 +++++ src/api/endpoints/streaming.ts | 12 +++- .../metadata-editor/MetadataEditorPage.tsx | 56 +++++++++++++++++++ src/hooks/useAudioPlayer.ts | 9 ++- src/i18n/locales/en.ts | 6 ++ src/i18n/locales/ru.ts | 6 ++ 6 files changed, 98 insertions(+), 4 deletions(-) diff --git a/src/api/endpoints/library.ts b/src/api/endpoints/library.ts index 164b874..5219f3e 100644 --- a/src/api/endpoints/library.ts +++ b/src/api/endpoints/library.ts @@ -201,6 +201,18 @@ export const libraryApi = api.injectEndpoints({ }), invalidatesTags: (_r, _e, trackId) => [{ type: 'Track', id: trackId }], }), + // Enqueue a transcode to a cached Opus + HLS rendition (§6.6). Fire-and- + // forget: the worker does the work, playback keeps using the original. + optimizeTrack: build.mutation< + { status: string; job_id: string; quality: string }, + { trackId: string; quality?: string } + >({ + query: ({ trackId, quality = 'high' }) => ({ + url: `/tracks/${trackId}/optimize`, + method: 'POST', + params: { quality }, + }), + }), }), overrideExisting: false, }); @@ -219,4 +231,5 @@ export const { useLazyGetMetadataMatchesQuery, useApplyMetadataMutation, useEnrichTrackMutation, + useOptimizeTrackMutation, } = libraryApi; diff --git a/src/api/endpoints/streaming.ts b/src/api/endpoints/streaming.ts index 8a8e9c3..dda7d93 100644 --- a/src/api/endpoints/streaming.ts +++ b/src/api/endpoints/streaming.ts @@ -5,9 +5,17 @@ import { getApiBaseUrl } from '../../config/runtime-config'; * param because `