产品
Egret Engine
版本
5.2.13
复现概率
100%
平台
Windows 所有平台
复现步骤
先用await RES.getResAsync加载音乐资源,加载完后播放,后用RES.getRes获取资源,再播放
问题描述
异步已经加载的音乐资源,用RES.getRes进行播放,播放没有声音
错误代码
public async playBgSound(mp3: string, repeatNum: number = 0) {
let self = this; if (!GameConfig.bolMusic) return; let sound: egret.Sound = RES.getRes(mp3); if (!sound) { sound = await RES.getResAsync(mp3); } if (!sound) return; self.stopBgSound(); self._currBgSound = new SoundInfo(); sound.type = egret.Sound.MUSIC; self._currBgSound.sound = sound; try { self._currBgSound.soundChannel = sound.play(0, repeatNum); self._currBgSound.soundChannel.volume = self._soundBgVolume; self._currBgSound.repeatNum = repeatNum; } catch (e) { Logger.log(LOG_TAG.Sound, e); } }
BUG截图
![]()
| |
Powered by Discuz! X3.4 © 2001-2019 Comsenz Inc.