File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
packages/webgal/src/Core/gameScripts Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { IPerform } from '@/Core/Modules/perform/performInterface';
66import { useSelector } from 'react-redux' ;
77import { WebGAL } from '@/Core/WebGAL' ;
88import { 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,6 +101,12 @@ export const playEffect = (sentence: ISentence): IPerform => {
100101 }
101102 }
102103 } ;
104+ seElement . onended = endFunc ;
105+ seElement . addEventListener ( 'error' , ( e ) => {
106+ logger . error ( `播放效果音失败: ${ url } ` ) ;
107+ // 播放失败提前结束
108+ endFunc ( ) ;
109+ } ) ;
103110 } , 1 ) ;
104111 } ) ,
105112 } ;
You can’t perform that action at this time.
0 commit comments