Jump to content

Phaser/CocoonJS Audio problems (with Fix)


haden
 Share

Recommended Posts

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).

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...
  • 9 months later...

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

  • 1 month later...
  • 7 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...