大家可能知道、CocosCreator生产的原生程序调用不了DOM API。这是因为,下篇文章说的
https://stackoverflow.com/questions/33725402/why-web-audio-api-isnt-supported-in-nodejs
Node.js 不支持Web Audio ,因为它不是JavaScript语言的一部分。Web Audio是一个与之分开的web平台的JavaScript API.
参考リンク:
https://stackoverflow.com/questions/33725402/why-web-audio-api-isnt-supported-in-nodejs
https://developer.mozilla.org/en-US/docs/Web/API
本来浏览器有的WebAudioAPI, 自带ACC解码功能,所以无需意识就可以使用。但在cocos creator原生平台下,只有v8之类的JS引擎可以用。所以,按照WebAudioAPI的API,自己做一个,或者网上找一个。我找到的是一个纯js写的
https://github.com/mohayonao/web-audio-engine 是WebAudioAPI的纯js的实现
还有地下这个是aac解码用的,也是纯js写的
https://github.com/audiocogs/aac.js
这个比起原生的WebAudioAPI,肯定会慢很多。所以我想利用开源的WebAudioAPI的C++代码
https://github.com/WebKit/webkit/tree/master/Source/WebCore/Modules/webaudio
只不过,·怎么导入还在摸索中。。。