diff --git a/public/js/audio.js b/public/js/audio.js index 9550511b..a8948dd8 100644 --- a/public/js/audio.js +++ b/public/js/audio.js @@ -31,6 +31,7 @@ // which follows the store). import { PHASE } from '../../shared/constants.js'; +import { mediaUrl } from './media.js'; const MAX_VOICES = 8; const UNIT_COOLDOWN_MS = 160; @@ -383,7 +384,10 @@ export class AudioManager { } const p = (async () => { try { - const res = await fetch(url); + // Extension-less URL first so download managers leave the BGM alone; a host without /media/ still works. + const media = mediaUrl(url); + let res = await fetch(media); + if (!res.ok && media !== url) res = await fetch(url); if (!res.ok) throw new Error(`HTTP ${res.status}`); const ab = await res.arrayBuffer(); return await new Promise((resolve) => { diff --git a/public/js/media.js b/public/js/media.js new file mode 100644 index 00000000..6b7fade5 --- /dev/null +++ b/public/js/media.js @@ -0,0 +1,60 @@ +// Audio URLs for download managers (IDM / 迅雷 / FDM …) — and why they have no extension. +// +// The game plays audio with fetch() + Web Audio (`audio.js`): it never uses