修复音效播放器,在资源还未加载完就释放,导致音效播放器报错问题

This commit is contained in:
dgflash
2024-11-28 17:52:53 +08:00
parent 74016b54f2
commit 0dc016f690

View File

@@ -56,16 +56,6 @@ export class AudioEffectPool {
return new Promise(async (resolve, reject) => {
if (!this.switch) return resolve(-1);
let aeid = this.getAeId();
let key: string;
if (url instanceof AudioClip) {
key = url.uuid;
}
else {
key = `${bundleName}_${url}`;
}
key += "_" + aeid;
// 创建音效资源
let clip: AudioClip;
if (url instanceof AudioClip) {
@@ -79,6 +69,22 @@ export class AudioEffectPool {
}
}
// 资源已被释放
if (!clip.isValid) {
resolve(-1);
return;
}
let aeid = this.getAeId();
let key: string;
if (url instanceof AudioClip) {
key = url.uuid;
}
else {
key = `${bundleName}_${url}`;
}
key += "_" + aeid;
// 获取音效果播放器播放音乐
let ae: AudioEffect;
let node: Node = null!;