From 6f2d0e7838d08c9938966387287960ee1bfb1633 Mon Sep 17 00:00:00 2001 From: kuangshen04 <2832899707@qq.com> Date: Thu, 18 Jan 2024 23:05:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96playAudio=EF=BC=8C=E4=B9=8B?= =?UTF-8?q?=E5=90=8Eonerror=E4=B8=8D=E4=BC=9AaddVideo=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=8F=AF=E8=83=BD=E7=9A=84=E5=86=85=E5=AD=98?= =?UTF-8?q?=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/game/index.js | 16 +++++++++------- noname/library/element/content.js | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/noname/game/index.js b/noname/game/index.js index ad55dc55f..9b2379276 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -1364,19 +1364,21 @@ export class Game extends Uninstantable { else if (!path.startsWith('db:')) path = `audio/${path}`; if (!lib.config.repeat_audio && _status.skillaudio.includes(path)) return; } - _status.skillaudio.add(path); - game.addVideo('playAudio', null, path); - setTimeout(() => _status.skillaudio.remove(path), 1000); const audio = document.createElement('audio'); audio.autoplay = true; audio.volume = lib.config.volumn_audio / 8; - audio.addEventListener('ended', () => audio.remove()); - audio.onerror = event => { + //Some browsers do not support "autoplay", so "oncanplay" listening has been added + audio.oncanplay = () => Promise.resolve(audio.play()).catch(() => void 0); + audio.onplay = () => { + _status.skillaudio.add(path); + setTimeout(() => _status.skillaudio.remove(path), 1000); + game.addVideo("playAudio", null, path); + }; + audio.onended = (event) => audio.remove(); + audio.onerror = (event) => { audio.remove(); if (onError) onError(event); }; - //Some browsers do not support "autoplay", so "oncanplay" listening has been added - audio.oncanplay = () => Promise.resolve(audio.play()).catch(() => void 0); new Promise((resolve, reject) => { if (path.startsWith('db:')) game.getDB('image', path.slice(3)).then(octetStream => resolve(get.objectURL(octetStream)), reject); else if (lib.path.extname(path)) resolve(`${lib.assetURL}${path}`); diff --git a/noname/library/element/content.js b/noname/library/element/content.js index 62ccb6803..f0caf0960 100644 --- a/noname/library/element/content.js +++ b/noname/library/element/content.js @@ -2025,10 +2025,10 @@ export const Content = { event.choice = event.doing.todoList.filter(info => { if (!lib.filter.filterTrigger(trigger, info.player, event.triggername, info.skill)) return false; if (directUse(info)) return false; + if (event.current.priority !== info.priority) return false; if (event.current.player !== info.player) return false; return lib.skill.global.includes(info.skill) || event.current.player.hasSkill(info.skill, true); }); - event.choice = event.choice.filter(n=>n.priority == event.choice[0].priority); if (event.choice.length < 2) return event.goto(4); 'step 2'; const next = event.choice[0].player.chooseControl(event.choice.map(i => i.skill));