我看了一下引擎,Web平台最底层的函数是loadNative,直接加载一个音效。无法通过assetManager.downloader.register来拦截这个加载,请问这是个设计问题吗?还是有其它解决方法。
static loadNative (url: string): Promise<AudioBuffer> {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
const errInfo = `load audio failed: ${url}, status: `;
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = () => {
if (xhr.status === 200 || xhr.status === 0) {
audioContextAgent!.decodeAudioData(xhr.response).then((buffer) => {
resolve(buffer);
}).catch((e) => {});
} else {
reject(new Error(`${errInfo}${xhr.status}(no response)`));
}
};
xhr.onerror = () => { reject(new Error(`${errInfo}${xhr.status}(error)`)); };
xhr.ontimeout = () => { reject(new Error(`${errInfo}${xhr.status}(time out)`)); };
xhr.onabort = () => { reject(new Error(`${errInfo}${xhr.status}(abort)`)); };
xhr.send(null);
});
}