HarmonyOS 鸿蒙Next SoundPool 一次能载入多少个音频文件?代码每次载入32个后面就错误了
HarmonyOS 鸿蒙Next SoundPool 一次能载入多少个音频文件?代码每次载入32个后面就错误了
soundstr数组里面有80个音频文件,没个文件大小不超过10kb,循环载入音频文件,每次载入到32个左右就报错了
错误:soundPool load failed and catch error is load sound failed=============5400102
首先音频测试没有问题,是不能这样载入吗,还是数量有限制,如果载入量多的音频怎么载入,以前做android就是一次性初始化音频
求助求助求助求助
soundPool = await media.createSoundPool(soundstr.length, audioRendererInfo);
for(let i=0;i<soundstr.length;i++){
console.info(‘soundPool soundstr=======i===================’+i+"=============")
try {
context.resourceManager.getRawFd(soundstr[i], (error: BusinessError, value: resourceManager.RawFileDescriptor) => {
if (error != null) {
console.error(callback getRawFd failed error code: ${error.code}, message: ${error.message}.
);
} else {
let fd = value.fd;
let offset = value.offset;
let length = value.length;
uri = ‘fd://’ + fd.toString();
soundPool.load(fd, offset, length).then((soundId: number) => {
console.info(‘soundPool load uri success===’+soundId+“soundstr[i]=”+soundstr[i]);
soundMap.set(soundstr[i],soundId);
}).catch((err: BusinessError) => {
console.error('soundPool load failed and catch error is ’ + err.message+"============="+err.code);
})
}
});
} catch (error) {
let code = (error as BusinessError).code;
let message = (error as BusinessError).message;
console.error(callback getRawFd failed, error code: ${code}, message: ${message}.
);
}
}
关于HarmonyOS 鸿蒙Next SoundPool 一次能载入多少个音频文件?代码每次载入32个后面就错误了的问题,您也可以访问:https://www.itying.com/category-93-b0.html 联系官网客服。