haden Posted December 23, 2013 Share Posted December 23, 2013 While trying to get our last game Fip to run on CocoonJS launcher, we noticed that the sound wasn't playing at all. After much investigation we were able to make it play but after making some changes to Phaser (dev branch). The first problem encountered was in Sound.js, inside update() function here:if (this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).locked){ // console.log('tried playing locked sound, pending set, reload started'); this.game.cache.reloadSound(this.key); this.pendingPlayback = true;}the ".locked" attribute was "undefined" so the sound never reloads. So our first change was inside Cache.js/addSound(), changing this:this._sounds[key] = { url: url, data: data, isDecoding: false, decoded: decoded, webAudio: webAudio, audioTag: audioTag };with this one:this._sounds[key] = { url: url, data: data, isDecoding: false, decoded: decoded, webAudio: webAudio, audioTag: audioTag, locked: this.game.sound.touchLocked };The second problem was in Sound.js/update() at the following line:if (this._sound && this._sound.readyState == 4)the attribute "readyState" is undefined. Changing the previous test to the following fixes the problem:if (this._sound && (this.game.device.cocoonJS || this._sound.readyState == 4))Now the game plays sounds nicely inside CocoonJS launcher Please note, that we didn't try yet to play audiosprites, but just regular sound files (a music actually). Arlefreak and DWboutin 2 Link to comment Share on other sites More sharing options...
woratana Posted December 25, 2013 Share Posted December 25, 2013 Hello, Thank you for sharing! This is a little off-topic. But do you find it hard to get the game shows correctly in cocoonjs?I tried using the cocoonjs app to load my game, but the game seems to be a lot off-screen happened. :/ Link to comment Share on other sites More sharing options...
haden Posted December 25, 2013 Author Share Posted December 25, 2013 About game scaling, I used the code of the following post, which worked perfectly: http://www.html5gamedevs.com/topic/2273-phaser-cocoonjs-vs-webgl-scaling-finally-solved/?p=15265 Arlefreak 1 Link to comment Share on other sites More sharing options...
rich Posted December 31, 2013 Share Posted December 31, 2013 Thanks for this haden - both of your fixes are now merged with 1.1.4-dev. haden 1 Link to comment Share on other sites More sharing options...
korgoth Posted January 20, 2014 Share Posted January 20, 2014 Does Phaser support Cocoonjs Multichannel Sound feature? If i know right its some kind of webaudio api but game.device.webAudio returns false. Link to comment Share on other sites More sharing options...
toto88x Posted February 9, 2014 Share Posted February 9, 2014 Thanks for this haden - both of your fixes are now merged with 1.1.4-dev. So does the new Phaser 1.1.4 is supposed to have sound working with cocoonJS? Link to comment Share on other sites More sharing options...
rich Posted February 9, 2014 Share Posted February 9, 2014 I don't use Cocoon so I don't know, but I merged hadens fixes (and he uses it) so I can only assume so. Link to comment Share on other sites More sharing options...
i_want_to_make_games Posted February 9, 2014 Share Posted February 9, 2014 So does the new Phaser 1.1.4 is supposed to have sound working with cocoonJS?No, it still doesn't work. Will try now the fixes above. Edit: Nop, doesn't work... Link to comment Share on other sites More sharing options...
i_want_to_make_games Posted February 9, 2014 Share Posted February 9, 2014 I don't use Cocoon so I don't know, but I merged hadens fixes (and he uses it) so I can only assume so.What do you use to convert application written in Phaser to android app? Link to comment Share on other sites More sharing options...
rich Posted February 10, 2014 Share Posted February 10, 2014 Nothing. I don't make native apps. Link to comment Share on other sites More sharing options...
i_want_to_make_games Posted February 10, 2014 Share Posted February 10, 2014 Nothing. I don't make native apps.Well, it was my fault for not researching frameworks more. Link to comment Share on other sites More sharing options...
rich Posted February 10, 2014 Share Posted February 10, 2014 Doesn't mean it can't be done - there are a number of Phaser games in app stores. I just personally don't do it. If a native app is your end target platform (i.e. you don't need to publish to the web as well) then I would use a language/framework designed specifically for that (Unity, Corona, AIR, etc). jdnichollsc 1 Link to comment Share on other sites More sharing options...
Hsaka Posted February 10, 2014 Share Posted February 10, 2014 Hi, I can confirm that sound in Phaser 1.1.4 works in CocoonJS. See here: https://play.google.com/store/apps/details?id=com.gamepyong.joggle&hl=en Link to comment Share on other sites More sharing options...
toto88x Posted February 10, 2014 Share Posted February 10, 2014 Hi, I can confirm that sound in Phaser 1.1.4 works in CocoonJS. See here: https://play.google.com/store/apps/details?id=com.gamepyong.joggle&hl=en Did you do anything specific to make the music work? Or just something like "game.add.audio('sound').play('', 0, 0.5, false);" ?What was the file format of the music? mp3? wav ? Thanks! Link to comment Share on other sites More sharing options...
Hsaka Posted February 10, 2014 Share Posted February 10, 2014 I didn't do anything special to make it work, regular loading and playing functions.The format was oggHope that helps. Link to comment Share on other sites More sharing options...
toto88x Posted February 10, 2014 Share Posted February 10, 2014 I didn't do anything special to make it work, regular loading and playing functions.The format was oggHope that helps. I replaced my .wav with a .mp3, and it worked, nice! :-) Link to comment Share on other sites More sharing options...
Athul Dilip Posted November 30, 2014 Share Posted November 30, 2014 For me sound works perfectly on webview of cocoonjs but didn't work for canvas of it!Any ideas why? Link to comment Share on other sites More sharing options...
valueerror Posted November 30, 2014 Share Posted November 30, 2014 @haden: do you have any audio loops in your game? EVERY file i tried to loop (a very exact cut so the user can not hear where the loop restarts) repeats the first 200ms .. did you notice that? Link to comment Share on other sites More sharing options...
Athul Dilip Posted December 3, 2014 Share Posted December 3, 2014 @valueerrorDid sound work for you in the canvas mode of cocoonjs? Link to comment Share on other sites More sharing options...
valueerror Posted December 3, 2014 Share Posted December 3, 2014 sound works.. yes! (i only use canvas mode because webgl offers a black screen) but read this answer from ludei to the one problem with audio i experienced ... it looks like there is no fix for now.. i'm going to ask rich for his opinion on this.http://www.html5gamedevs.com/topic/3980-common-phaser-cocoonjs-issues/?p=63288 Link to comment Share on other sites More sharing options...
Athul Dilip Posted December 9, 2014 Share Posted December 9, 2014 @valueerrorIs the sound working for you when you're not looping it? Link to comment Share on other sites More sharing options...
martzy Posted January 14, 2015 Share Posted January 14, 2015 I ran into glitchy looping problems when using mp3 file format for audio. Try .ogg, worked for me Link to comment Share on other sites More sharing options...
valueerror Posted January 14, 2015 Share Posted January 14, 2015 the problem i already discussed with cocoonjs members i not resoved by using ogg (i always use ogg btw.) Link to comment Share on other sites More sharing options...
mdi Posted September 3, 2015 Share Posted September 3, 2015 I have the same problem with the version of the Phaser ( phaser - arcade - physics - 2.3.0.min.js ) and cocoonjs . My audios are already ogg but no sound. Link to comment Share on other sites More sharing options...
Recommended Posts