fix: load audio thmb

This commit is contained in:
Boris Cherepanov
2026-04-02 00:29:21 +03:00
parent 83a145d0a8
commit 480880f292
2 changed files with 35 additions and 25 deletions
+11 -1
View File
@@ -333,8 +333,18 @@ export function FurumiPlayer() {
if (i < 0 || i >= q.items.length) return if (i < 0 || i >= q.items.length) return
dispatch(playAtIndex(i)) dispatch(playAtIndex(i))
const track = store.getState().queue.items[i] const track = store.getState().queue.items[i]
audio.src = `${API_ROOT}/stream/${track.slug}` // TODO remove after auth refactor
preloadStream(track.slug).then(response => {
console.log('response', response)
audio.src = URL.createObjectURL(response?.data)
void audio.play().catch(() => { }) void audio.play().catch(() => { })
// Optionally revoke old object URL if needed to avoid memory leaks
// if (oldSrc?.startsWith('blob:')) {
// URL.revokeObjectURL(oldSrc)
// }
})
// audio.src = `${API_ROOT}/stream/${track.slug}`
// void audio.play().catch(() => {})
if (window.history && window.history.replaceState) { if (window.history && window.history.replaceState) {
const url = new URL(window.location.href) const url = new URL(window.location.href)
url.searchParams.set('t', track.slug) url.searchParams.set('t', track.slug)
+1 -1
View File
@@ -44,6 +44,6 @@ export async function getTrackInfo(trackSlug: string): Promise<TrackDetail | nul
} }
export async function preloadStream(trackSlug: string) { export async function preloadStream(trackSlug: string) {
await furumiApi.get(`/stream/${trackSlug}`, { responseType: 'arraybuffer' }).catch(() => null) return await furumiApi.get(`/stream/${trackSlug}`, { responseType: 'blob' }).catch(() => null)
} }