Fixed idiocy not working when sound isn't initialised.

This commit is contained in:
flash 2024-01-23 02:25:49 +00:00
parent 017b720f8d
commit 1e439b87c0

View file

@ -20,8 +20,13 @@ const MamiYouAreAnIdiot = function() {
const pub = { const pub = {
getElement: () => html, getElement: () => html,
onViewPush: () => { onViewPush: () => {
return new Promise((resolve, reject) => { return new Promise(resolve => {
const soundMgr = mami.getSound(); const soundMgr = mami.getSound();
if(soundMgr === undefined || soundMgr === null) {
resolve();
return;
}
const soundSrcs = mami.getSoundLibrary().getSound('misc:youare').getSources(); const soundSrcs = mami.getSoundLibrary().getSound('misc:youare').getSources();
soundMgr.load('youarebgm', soundSrcs, (success, buffer) => { soundMgr.load('youarebgm', soundSrcs, (success, buffer) => {
if(success) { if(success) {
@ -32,7 +37,7 @@ const MamiYouAreAnIdiot = function() {
soundSrc.setLoop(); soundSrc.setLoop();
soundSrc.play(); soundSrc.play();
resolve(); resolve();
} else reject(); } else resolve();
}); });
}); });
}, },