fix(node-player): use blob for audio stream, keep SW for cover art
<audio> elements with Sec-Fetch-Mode: no-cors are unreliable with Service Workers across browsers. Revert stream to blob download via axios (Bearer token works). SW remains for cover art in <img> tags. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { API_ROOT } from './furumiApi'
|
import { furumiApi } from './furumiApi'
|
||||||
import { fmt } from './utils'
|
import { fmt } from './utils'
|
||||||
|
|
||||||
const MAX_PLAYBACK_ERROR_SKIPS = 5
|
const MAX_PLAYBACK_ERROR_SKIPS = 5
|
||||||
@@ -109,8 +109,13 @@ export function attachAudioPlayback(
|
|||||||
volSlider?.addEventListener('input', onVolInput)
|
volSlider?.addEventListener('input', onVolInput)
|
||||||
|
|
||||||
async function loadStreamForTrack(slug: string) {
|
async function loadStreamForTrack(slug: string) {
|
||||||
audio.src = `${API_ROOT}/stream/${slug}`
|
try {
|
||||||
await audio.play().catch(() => { })
|
const res = await furumiApi.get(`/stream/${slug}`, { responseType: 'blob' })
|
||||||
|
audio.src = URL.createObjectURL(res.data)
|
||||||
|
await audio.play().catch(() => { })
|
||||||
|
} catch {
|
||||||
|
// stream failed
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pauseAndClearSource() {
|
function pauseAndClearSource() {
|
||||||
|
|||||||
Reference in New Issue
Block a user