From 68129fc8c852326e9d7ced70bd7fd2e9a623f261 Mon Sep 17 00:00:00 2001 From: Rintim Date: Sun, 21 Apr 2024 21:46:51 +0800 Subject: [PATCH] feat: background music blob support. --- noname/game/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/noname/game/index.js b/noname/game/index.js index 0b681754f..26c194869 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -1776,7 +1776,9 @@ export class Game { _status.currentAozhan ); _status.currentAozhan = aozhan; - if (aozhan.startsWith("db:")) + if (["blob:", "data:"].some((prefix) => aozhan.startsWith(prefix))) { + ui.backgroundMusic.src = aozhan; + } else if (aozhan.startsWith("db:")) game.getDB("image", aozhan.slice(3)).then((result) => (ui.backgroundMusic.src = result)); else if (aozhan.startsWith("ext:")) ui.backgroundMusic.src = `${lib.assetURL}extension/${aozhan.slice(4)}`; @@ -1799,7 +1801,9 @@ export class Game { ui.backgroundMusic.src = backgroundMusicSourceConfiguration; return; } - if (music.startsWith("db:")) + if (["blob:", "data:"].some((prefix) => music.startsWith(prefix))) { + ui.backgroundMusic.src = music; + } else if (music.startsWith("db:")) game.getDB("image", music.slice(3)).then((result) => (ui.backgroundMusic.src = result)); else if (music.startsWith("ext:")) ui.backgroundMusic.src = `${lib.assetURL}extension/${music.slice(4)}`;