Skip to content

Commit 846c423

Browse files
fix: improve audio playback end handling in playEffect
1 parent c4ad8ac commit 846c423

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/webgal/src/Core/gameScripts/playEffect.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { IPerform } from '@/Core/Modules/perform/performInterface';
66
import { useSelector } from 'react-redux';
77
import { WebGAL } from '@/Core/WebGAL';
88
import { WEBGAL_NONE } from '@/Core/constants';
9+
import { end } from './end';
910

1011
/**
1112
* 播放一段效果音
@@ -91,7 +92,7 @@ export const playEffect = (sentence: ISentence): IPerform => {
9192
};
9293
resolve(perform);
9394
seElement?.play();
94-
seElement.onended = () => {
95+
const endFunc = () => {
9596
for (const e of WebGAL.gameplay.performController.performList) {
9697
if (e.performName === performInitName) {
9798
isOver = true;
@@ -100,10 +101,11 @@ export const playEffect = (sentence: ISentence): IPerform => {
100101
}
101102
}
102103
};
104+
seElement.onended = endFunc;
103105
seElement.addEventListener('error', (e) => {
104106
logger.error(`播放效果音失败: ${url}`);
105107
// 播放失败提前结束
106-
seElement.onended?.(e);
108+
endFunc();
107109
});
108110
}, 1);
109111
}),

0 commit comments

Comments
 (0)