Go to the /frameworks/cocos2d-html5/tools directory and run “ant” via the command line.
Open /samples/js-moonwarriors/index.html and replace the CCBoot.js path ("…/…/frameworks/cocos2d-html5/CCBoot.js") with the minified source path ("…/…/frameworks/cocos2d-html5/lib/cocos2d-js-v3.0-min.js").
Run the moonwarriors sample as you normally would.
When I test on Firefox, I don’t hear any music using the minified lib.
I’ve also tested the 3.1 release, but the problem seems to be the same there, too (and the performance of my actual game is worse when I use the minified 3.1 library, so I’m hesitant to upgrade).
Does anyone have any thoughts on how to fix or otherwise address this audio issue?
I’m updating just in case someone else with the same problem finds this post.
As far as I can tell, it seems FF may be more susceptible to bad closures / namespace issues in minified code than other browsers, but I wasn’t able to track anything down that confirms it’s the issue here. I ended up just reverting to the unminified library in order to release the game.
I have the same when join all files in singe .js file.
I tried many variants, but still nothing…
If someone doesn’t have this problem, please let us know.
We found a way how to fix it. Sounds in firefox doesn’t work when framework cocos2d-html5 minified, because there is problem with AudioBufferSourceNode. If SWA will be false (CCAudio.js) then sound works ok in all browsers.
@Wadimir, your idea doesn’t seem to work on me, or maybe I didn’t get it.
To test your idea quickly, I changed line 455 in CCAudio.js to: var SWA = false,//polyfill.webAudio, but it seems to give me the same result: No sound in Firefox with minimized JS.
I use Cocos2d-JS v3.3.
EDIT: Thanks to a friend, I noticed something even more interesting. Your fix does work, but loading it via DOM is actually randomly timing out the audio loads, no matter the format or size. It sometimes loads one of the sounds. The others are reported in console as audio load timeouts.
The funny thing is that i’m using a big js with all files concatenated and the audio only works in Chrome. if i use the command line cocos run -p web the audio works fine
I have the same problem
This does not fix it for me too…
While developing, everything was fine. But after joining all to one file (cocos compile -p web -m release), it’s not working anymore with Firefox. A fix would be great, as firefox is really popular and currently not usable for cocos2d projects…
While using DOM audio loading and by using this new method, loading is actually working and has stopped failing randomly. It’s always working for me now, at least in Firefox, Chrome and Opera; I have not tested other browsers.