@ives_xxz/framework 2.1.7 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -96,34 +96,37 @@ export default class FWAudioManager extends FWManager implements FW.AudioManager
96
96
  ): Promise<number>;
97
97
  async play(): Promise<number> {
98
98
  try {
99
- if (this.audioPool.size >= this.maxConcurrentAudio) {
100
- this.clearFinishedAudio();
99
+ return new Promise<number>(async (resolve, reject) => {
101
100
  if (this.audioPool.size >= this.maxConcurrentAudio) {
102
- FW.Log.warn('音频池已满,无法播放新音频');
103
- return -1;
101
+ this.clearFinishedAudio();
102
+ if (this.audioPool.size >= this.maxConcurrentAudio) {
103
+ FW.Log.warn('音频池已满,无法播放新音频');
104
+ return -1;
105
+ }
104
106
  }
105
- }
106
107
 
107
- const audioData = await this.processAudioArguments(
108
- arguments,
109
- FW.SystemDefine.FWAudioType.SOUND,
110
- );
111
- if (!audioData.clip) return -1;
108
+ const audioData = await this.processAudioArguments(
109
+ arguments,
110
+ FW.SystemDefine.FWAudioType.SOUND,
111
+ );
112
+ if (!audioData.clip) return -1;
112
113
 
113
- const volume = (audioData.volume ?? this.soundVolume) * this.effectsVolume;
114
- const loop = audioData.loop ?? false;
115
- const tag = audioData.tag;
114
+ const volume = (audioData.volume ?? this.soundVolume) * this.effectsVolume;
115
+ const loop = audioData.loop ?? false;
116
+ const tag = audioData.tag;
116
117
 
117
- const id = cc.audioEngine.play(audioData.clip, loop, volume);
118
+ const id = cc.audioEngine.play(audioData.clip, loop, volume);
118
119
 
119
- this.audioPool.set(id, new FWAudioPoolItem(id, Date.now(), tag));
120
+ this.audioPool.set(id, new FWAudioPoolItem(id, Date.now(), tag));
120
121
 
121
- cc.audioEngine.setFinishCallback(id, () => {
122
- audioData.cb?.(id);
123
- this.audioPool.delete(id);
124
- });
122
+ cc.audioEngine.setFinishCallback(id, () => {
123
+ audioData.cb?.(id);
124
+ resolve(id);
125
+ this.audioPool.delete(id);
126
+ });
125
127
 
126
- return id;
128
+ return id;
129
+ });
127
130
  } catch (e) {
128
131
  FW.Log.error('播放音效失败:', e);
129
132
  return -1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ives_xxz/framework",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "cocoscreator 2.x mvc framework",
5
5
  "main": "index.js",
6
6
  "keywords": ["123456"],