title: Phaser HTML5 app cannot play sound after porting by Phonegap Cloud Build
body: <p>This's a simple Phaser audio example. It works well on my Android web browser. However, it's muted after porting to Android app by Phonegap cloud build.</p>
  
  <p>I know how to play sound (and loop) in Phonegap app (<a href="https://stackoverflow.com/questions/13927316/how-to-loop-a-audio-in-phonegap">How to loop a audio in phonegap?</a>) but don't know how to apply it into the Phaser JS framework.</p>
  
  <p>Here's the ported app. I can install and run it but without sound. Do I miss something or Phonegap Cloud Build does support the WebAudio in Phaser JS?</p>
  
  <p><a href="https://build.phonegap.com/apps/1783695/" rel="nofollow noreferrer">https://build.phonegap.com/apps/1783695/</a></p>
  
  <p>My <code>config.xml</code> is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
    &lt;widget id="com.phaser.phasersound" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0"&gt;
  &lt;name&gt;Phaser sound complete&lt;/name&gt;
  &lt;description&gt;
     Phaser sound phonegap
  &lt;/description&gt;
  &lt;gap:plugin name="org.apache.cordova.media" /&gt;
  &lt;icon src="icon.png" /&gt;
  &lt;preference name="splash-screen-duration" value="1"/&gt;
  
  &lt;!--
    If you do not want any permissions to be added to your app, add the
    following tag to your config.xml; you will still have the INTERNET
    permission on your app, which PhoneGap requires.
  --&gt;
  &lt;preference name="permissions" value="none"/&gt;
    &lt;/widget&gt;
  </code></pre>
  
  <p>The source code is: (I changed the local audio files from local to github links to run on code snippet)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var game = new Phaser.Game(600, 800, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
  
  function preload() {
  
   game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
      
      //have the game centered horizontally
      game.scale.pageAlignHorizontally = true;
      game.scale.pageAlignVertically = true;
  
      game.stage.backgroundColor = '#414040';
  
      // I changed the local audio files from local to github links to run on code snippet
  
      /*
      game.load.audio('explosion', 'assets/audio/SoundEffects/explosion.mp3');
      game.load.audio('sword', 'assets/audio/SoundEffects/sword.mp3');
      game.load.audio('blaster', 'assets/audio/SoundEffects/blaster.mp3');
      */
  
      game.load.audio('explosion', 'https://raw.githubusercontent.com/nguoianphu/phaser-sound-complete-phonegap/master/www/assets/audio/SoundEffects/explosion.mp3');
      game.load.audio('sword', 'https://raw.githubusercontent.com/nguoianphu/phaser-sound-complete-phonegap/master/www/assets/audio/SoundEffects/sword.mp3');
      game.load.audio('blaster', 'https://raw.githubusercontent.com/nguoianphu/phaser-sound-complete-phonegap/master/www/assets/audio/SoundEffects/blaster.mp3');
  
  }
  
  var explosion;
  var sword;
  var blaster;
  
  var text;
  
  var text1;
  var text2;
  var text3;
  
  function create() {
  
  
  
      var style = { font: "65px Arial", fill: "#52bace", align: "center" };
      text = game.add.text(game.world.centerX, 100, "decoding", style);
      text.anchor.set(0.5);
  
      explosion = game.add.audio('explosion');
      sword = game.add.audio('sword');
      blaster = game.add.audio('blaster');
  
      //  Being mp3 files these take time to decode, so we can't play them instantly
      //  Using setDecodedCallback we can be notified when they're ALL ready for use.
      //  The audio files could decode in ANY order, we can never be sure which it'll be.
  
      game.sound.setDecodedCallback([ explosion, sword, blaster ], start, this);
  
  }
  
  var keys;
  
  function start() {
  
      text.text = 'Press 1, 2 or 3';
  
      var style = { font: "48px Arial", fill: "#cdba52", align: "center" };
  
      text1 = game.add.text(game.world.centerX, 250, "Blaster: Stopped", style);
      text1.anchor.set(0.5);
  
      text2 = game.add.text(game.world.centerX, 350, "Explosion: Stopped", style);
      text2.anchor.set(0.5);
  
      text3 = game.add.text(game.world.centerX, 450, "Sword: Stopped", style);
      text3.anchor.set(0.5);
  
      explosion.onStop.add(soundStopped, this);
      sword.onStop.add(soundStopped, this);
      blaster.onStop.add(soundStopped, this);
  
      keys = game.input.keyboard.addKeys({ blaster: Phaser.Keyboard.ONE, explosion: Phaser.Keyboard.TWO, sword: Phaser.Keyboard.THREE });
  
      keys.blaster.onDown.add(playFx, this);
      keys.explosion.onDown.add(playFx, this);
      keys.sword.onDown.add(playFx, this);
  
      //  And for touch devices you can also press the top, middle or bottom of the screen
      game.input.onDown.add(onTouch, this);
  
  }
  
  function onTouch(pointer) {
  
      var b = game.height / 3;
  
      if (pointer.y &lt; b)
      {
          playFx(keys.blaster);
      }
      else if (pointer.y &gt; b * 2)
      {
          playFx(keys.sword);
      }
      else
      {
          playFx(keys.explosion);
      }
  
  }
  
  function playFx(key) {
  
      switch (key.keyCode)
      {
          case Phaser.Keyboard.ONE:
              text1.text = "Blaster: Playing";
              blaster.play();
              break;
  
          case Phaser.Keyboard.TWO:
              text2.text = "Explosion: Playing";
              explosion.play();
              break;
  
          case Phaser.Keyboard.THREE:
              text3.text = "Sword: Playing";
              sword.play();
              break;
      }
  
  }
  
  function soundStopped(sound) {
  
      if (sound === blaster)
      {
          text1.text = "Blaster: Complete";
      }
      else if (sound === explosion)
      {
          text2.text = "Explosion: Complete";
      }
      else if (sound === sword)
      {
          text3.text = "Sword: Complete";
      }
  
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.4.4/phaser.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <h2>UPDATE 2015-12-01</h2>
  
  <p>Here is my completed source code. It has both .mp3 and .ogg sound files. You can play them on Android native browser (tested on 4.4.4 Samsung E5).</p>
  
  <p>Source: <a href="https://github.com/nguoianphu/phaser-sound-complete-phonegap" rel="nofollow noreferrer">https://github.com/nguoianphu/phaser-sound-complete-phonegap</a></p>
  
  <p>Here is the ported app on Phonegap. It can display the screen but can't play sounds.
  <a href="https://build.phonegap.com/apps/1783695/builds" rel="nofollow noreferrer">https://build.phonegap.com/apps/1783695/builds</a></p>