fix: audio path fix.

This commit is contained in:
Rintim 2024-04-21 21:24:24 +08:00
parent 0eec71eb01
commit 6e6662553c
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
1 changed files with 6 additions and 1 deletions

View File

@ -1469,6 +1469,7 @@ export class Game {
reject
);
else if (lib.path.extname(path)) resolve(`${lib.assetURL}${path}`);
else if (URL.canParse(path)) resolve(path);
else resolve(`${lib.assetURL}${path}.mp3`);
}).then((resolvedPath) => {
audio.src = resolvedPath;
@ -1603,7 +1604,11 @@ export class Game {
let path = "",
format = "";
if (!/^db:|^ext:|\//.test(audioInfo)) path = "skill/";
if (!/\.\w+$/.test(audioInfo)) format = ".mp3";
if (
!/\.\w+$/.test(audioInfo) &&
!["data:", "blob:"].some((name) => audioInfo.startsWith(name))
)
format = ".mp3";
if (path && format) return parseAudio(audioInfo, options, [true, 2]);
return [`${path}${audioInfo}${format}`];
}