eva-engine / eva.js

Eva.js is a front-end game engine specifically for creating interactive game projects.
https://eva.js.org
MIT License
1.75k stars 108 forks source link

音频资源加载报错 #70

Open jamesliu96 opened 3 years ago

jamesliu96 commented 3 years ago

https://github.com/eva-engine/eva.js/blob/c932f97fc41fa03cc7e99b270cd08af4b14168ff/packages/eva.js/lib/loader/Resource.ts#L67

如果资源URL中没有有效后缀(通过resource-loadergetExtension方法获得),会导致默认使用text格式,而非arraybuffer返回,加载音频报错

if there isn't a valid extension within the resource URL (returned by getExtension function of third-party resource-loader module), it will load using text by default, instead of arraybuffer, and there we are getting an error

Failed to execute 'decodeAudioData' on 'BaseAudioContext': parameter 1 is not of type 'ArrayBuffer'.

建议如果设置资源type字段为audio,强制使用arraybuffer

i suggest if user sets the resource's type field to audio, use arraybuffer to parse fetched data rather than let the third-party module determine by itself (code)