if (!cc.loader.getItem(this.sound)) {
cc.audioEngine.preload(this.sound, function () {
});
}
--
var id = cc.audioEngine.play(this.sound);
cc.audioEngine.setFinishCallback(id, this._onAudioEnd.bind(this));
Thank you very much for your answers.
I dont know if this is the right topic to ask this question but I am confused about the difference between cc.AudioSource and cc.AudioEngine. In this page it is written that:
Audio needs a full url, Different from res path. So we recommend avoiding url, try to use audioClip as much as possible to replace url.
Notice the code above is converting “res path” into raw url.
To answer your question on the difference between cc.AudioSource and cc.AudioEngine:
cc.AudioSource is component based, where by you have to place in on a node to use it. The scope which it can manage is limited to itself.
cc.AudioEngine is a static instance, something like a singleton which you may use it to manage all your audio instances at once. Being a singleton, you have api like pauseAll and resumeAll.