Rectangle 27 2

If I'm understanding this correctly (there are some missing pieces in your code sample)...

decodeAudioData can only decode things like MP3 or WAV. It looks like you're passing it a raw Int16Array or Uint16Array. Because the underlying ArrayBuffer isn't a format that decodeAudioData understands, it gives up.

function playsound( raw ) {
  // i'll assume you know how to convert in this direction
  // since you have convertFloat32ToInt16
  var buffer = convertInt16ToFloat32( raw ),
    src = context.createBufferSource(),
    audioBuffer = context.createBuffer( 1, buffer.length, context.sampleRate );
  audioBuffer.getChannelData( 0 ).set( buffer );
  src.buffer = audioBuffer;
  src.connect( context.destination );
  src.start( 0 );
}

Basically, you already have a way to create the raw Float32Array that the Web Audio API likes, so there's no need to decode (and you can't decode anyway, since your data isn't a valid file format). So you just convert back to Float32Array, create your own AudioBuffer, write in the data from buffer, and go from there.

I am going to try it nowe. This is the first round about with Webkit audio and there is barely any documentation on it .

Oustanding. Now I get the process of webkit audio

although the process is not completely reversible and I get bad audio loss.

do you have a link or an example to convert back to 32b float as mine might be wrong?

javascript - HTML5 Audio API inputBuffer.getChannelData to audio Array...

javascript html5 audio web-audio arraybuffer
Rectangle 27 11

With JavaScript and the HTML5 Audio API you could do something like this:

var snd1  = new Audio();
var src1  = document.createElement("source");
src1.type = "audio/mpeg";
src1.src  = "audio/Dombra.mp3";
snd1.appendChild(src1);

var snd2  = new Audio();
var src2  = document.createElement("source");
src2.type = "audio/mpeg";
src2.src  = "audio/(TESBIHAT).mp3";
snd2.appendChild(src2);

snd1.play(); snd2.play(); // Now both will play at the same time

I have tested this in Chrome v. 20, and it seems to work :)

The <source> tag is used to specify different formats of the same file - such that the browser can choose another format as fallback in case the first one is not supported. That is why your own suggested solution does not work.

Thanks for reply Chrome and IE work but only n't working Opera not important thanks :)

Will this work on mobile devices that only support one audio stream at a time?

javascript - Play multiple sound at the same time - Stack Overflow

javascript html html5
Rectangle 27 1

For converting from float32 to unsigned int 16 you can multiply each float32 value with 0xffff(which is 16 bit max value). and for int16 to float32 do this reversely which means divide by 0xffff. audio should be fine now.

I am new in stackoverflow. I should write this as a comment but due to lack of reputation point i can't. Thats why i have to write it as a answer. sorry for inconvenience.

javascript - HTML5 Audio API inputBuffer.getChannelData to audio Array...

javascript html5 audio web-audio arraybuffer
Rectangle 27 40

Yes! The HTML5 audio tag with the "controls" attribute uses the browser's default player. You can customize it to your liking by not using the browser controls, but rolling your own controls and talking to the audio API via javascript.

Luckily, other people have already done this. My favorite player right now is jPlayer, it is very stylable and works great. Check it out.

You're still not telling us how to customize it. I found something here : theparticlelab.com/

So the answer is "no, it is not possible, you must use an external player"?

@Fernando: it is indeed possible. This answers the question "is it possible?"

Thank you @dsschnau. I posted my comment because the question is about styling html5 video tag, and all the answers are more or less like yes, it is possible, using other tags.

So, is that really a "no"? Rolling your own UI is not the same thing a stying existing markup.

Is it possible to style html5 audio tag? - Stack Overflow

html5 audio
Rectangle 27 12

  • JavaScript-plugin for playing sounds based on Web Audio API with fallback to HTML5 Audio.
  • Plugin is working on most popular desktop and mobile browsers and can be used everywhere, from common web sites to browser games.
  • No dependecies (jQuery not required).
// set up config
ion.sound({
    sounds: [
        {
            name: "my_cool_sound"
        },
        {
            name: "notify_sound",
            volume: 0.2
        },
        {
            name: "alert_sound",
            volume: 0.3,
            preload: false
        }
    ],
    volume: 0.5,
    path: "sounds/",
    preload: true
});

// And play sound!
ion.sound.play("my_cool_sound");

javascript - How to play a notification sound on websites? - Stack Ove...

javascript html audio notifications html5-audio
Rectangle 27 6

You can only create a single AudioContext per window and you should be waiting until the audio's canplay event fires before setting up your MediaElementSource. You should also be disconnecting the MediaElementSource when you're finished using it.

Isn't there only one AudioContext in my code? What is the canplay event and how do I use it? How do I disconnect the MediaElementSource?

You're creating a new AudioContext every time your click event fires. Follow the example code here: jsbin.com/acolet/1/edit

Your answer will be downvoted if you don't provide an explanation as to what process the link follows, just providing a link doesn't do me any good if I don't understand it, and you didn't either of my other questions.

I cannot dumb it down anymore than I have already. The answers to your questions should be easy to see in the example I provided. I'm not going to do your homework for you.

What is the difference between the audio.load(); call and the event listener for the 'canplay' event?

javascript - I'm trying to use the HTML5 Web Audio API to create an eq...

javascript jquery html5 html5-audio web-audio
Rectangle 27 35

I had the same problem and I found this very simple solution.

audio_file.onchange = function(){
  var files = this.files;
  var file = URL.createObjectURL(files[0]); 
              audio_player.src = file; 
  audio_player.play();
};
<input id="audio_file" type="file" accept="audio/*" />
<audio id="audio_player" />

html5 - Using local file for Web Audio API in Javascript - Stack Overf...

html5 client-side web-audio
Rectangle 27 32

I had the same problem and I found this very simple solution.

audio_file.onchange = function(){
  var files = this.files;
  var file = URL.createObjectURL(files[0]); 
              audio_player.src = file; 
  audio_player.play();
};
<input id="audio_file" type="file" accept="audio/*" />
<audio id="audio_player" />

html5 - Using local file for Web Audio API in Javascript - Stack Overf...

html5 client-side web-audio
Rectangle 27 1

Sure, just look in the console and you'll see the errors. Around line 595 of index.html, it's failing because the article is using the old deprecated types for biquadfilter - numeric values - and it needs to be changed to use the new string-based values. (I.e. a value of "3" - the default lowshelf filter - needs to be passed into currentFilterType as "lowshelf".) See http://webaudio.github.io/web-audio-api/#the-biquadfilternode-interface.

javascript - HTML5 Web Audio API: Filters is not working - Stack Overf...

javascript html5 html5-audio web-audio
Rectangle 27 20

For game authoring, one of the best solutions is to use a library which solves the many problems we face when writing code for the web, such as howler.js. howler.js abstracts the great (but low-level) Web Audio API into an easy to use framework. It will attempt to fall back to HTML5 Audio Element if Web Audio API is unavailable.

var sound = new Howl({
  urls: ['sound.mp3', 'sound.ogg']
}).play();
// it also provides calls for spatial/3d audio effects (most browsers)
sound.pos3d(0.1,0.3,0.5);

Another great library is wad.js, which is especially useful for producing synth audio, such as music and effects. For example:

var saw = new Wad({source : 'sawtooth'})
saw.play({
    volume  : 0.8,
    wait    : 0,     // Time in seconds between calling play() and actually triggering the note.
    loop    : false, // This overrides the value for loop on the constructor, if it was set. 
    pitch   : 'A4',  // A4 is 440 hertz.
    label   : 'A',   // A label that identifies this note.
    env     : {hold : 9001},
    panning : [1, -1, 10],
    filter  : {frequency : 900},
    delay   : {delayTime : .8}
})

Another library similar to Wad.js is "Sound for Games", it has more focus on effects production, while providing a similar set of functionality through a relatively distinct (and perhaps more concise feeling) API:

function shootSound() {
  soundEffect(
    1046.5,           //frequency
    0,                //attack
    0.3,              //decay
    "sawtooth",       //waveform
    1,                //Volume
    -0.8,             //pan
    0,                //wait before playing
    1200,             //pitch bend amount
    false,            //reverse bend
    0,                //random pitch range
    25,               //dissonance
    [0.2, 0.2, 2000], //echo array: [delay, feedback, filter]
    undefined         //reverb array: [duration, decay, reverse?]
  );
}

Each of these libraries are worth a look, whether you need to play back a single sound file, or perhaps create your own html-based music editor, effects generator, or video game.

Can't comment on game-development, but I'm using this for some minor audio feedback in an interface and for that it works an absolute treat. Quick, easy & simple.

Really nice framework, works nice in mobile as well. You have to trigger it with touchstart... but once that's done it works out of the box :)

Sound effects in JavaScript / HTML5 - Stack Overflow

javascript html5
Rectangle 27 13

Ok, it's taken me two days of prototyping different solutions and I've finally figured out how I can do this without storing my resources on a server. There's a few blogs that detail this but I couldn't find the full solution in one place so I'm adding it here. This may be considered a bit hacky by seasoned programmers but it's the only way I can see this working, so if anyone has a more elegent solution I'd love to hear it.

The solution was to store my sound files as a Base64 encoded string. The sound files are relatively small (less than 30kb) so I'm hoping performance won't be too much of an issue. Note that I put 'xxx' in front of some of the hyperlinks as my n00b status means I can't post more than two links.

First I need to convert my mp3 to a Base64 encoded string and store it as JSON. I found a website that does this conversion for me here - xxxhttp://www.mobilefish.com/services/base64/base64.php You may need to remove return characters using a text editor but for anyone that needs an example I found some piano tones here - xxxhttps://raw.github.com/mudcube/MIDI.js/master/soundfont/acoustic_grand_piano-mp3.js Note that in order to work with my example you're need to remove the header part data:audio/mpeg;base64,

You could implement this yourself but I found an API that does this perfectly (why re-invent the wheel, right?) - https://github.com/danguer/blog-examples/blob/master/js/base64-binary.js Resource taken from - here

Step 3: Adding the rest of the code

var cNote  = acoustic_grand_piano.C2;
var byteArray = Base64Binary.decodeArrayBuffer(cNote); 
var context = new webkitAudioContext();

context.decodeAudioData(byteArray, function(buffer) {
    var source = context.createBufferSource(); // creates a sound source
    source.buffer = buffer;    
    source.connect(context.destination); // connect the source to the context's destination (the speakers)
    source.noteOn(0); 
}, function(err) { console.log("err(decodeAudioData): "+err); });

And that's it! I have this working through my desktop version of Chrome and also running on mobile Safari (iOS 6 only of course as Web Audio is not supported in older versions). It takes a couple of seconds to load on mobile Safari (Vs less than 1 second on desktop Chrome) but this might be due to the fact that it spends time downloading the sound fonts. It might also be the fact that iOS prevents any sound playing until a user interaction event has occured. I need to do more work looking at how it performs.

Hope this saves someone else the grief I went through.

very interesting! thanks for the details. Would this approach work on an audio file that it's being recorded by another concurrent process? out of the JS browser/engine

html5 - Using local file for Web Audio API in Javascript - Stack Overf...

html5 client-side web-audio
Rectangle 27 12

Ok, it's taken me two days of prototyping different solutions and I've finally figured out how I can do this without storing my resources on a server. There's a few blogs that detail this but I couldn't find the full solution in one place so I'm adding it here. This may be considered a bit hacky by seasoned programmers but it's the only way I can see this working, so if anyone has a more elegent solution I'd love to hear it.

The solution was to store my sound files as a Base64 encoded string. The sound files are relatively small (less than 30kb) so I'm hoping performance won't be too much of an issue. Note that I put 'xxx' in front of some of the hyperlinks as my n00b status means I can't post more than two links.

First I need to convert my mp3 to a Base64 encoded string and store it as JSON. I found a website that does this conversion for me here - xxxhttp://www.mobilefish.com/services/base64/base64.php You may need to remove return characters using a text editor but for anyone that needs an example I found some piano tones here - xxxhttps://raw.github.com/mudcube/MIDI.js/master/soundfont/acoustic_grand_piano-mp3.js Note that in order to work with my example you're need to remove the header part data:audio/mpeg;base64,

You could implement this yourself but I found an API that does this perfectly (why re-invent the wheel, right?) - https://github.com/danguer/blog-examples/blob/master/js/base64-binary.js Resource taken from - here

Step 3: Adding the rest of the code

var cNote  = acoustic_grand_piano.C2;
var byteArray = Base64Binary.decodeArrayBuffer(cNote); 
var context = new webkitAudioContext();

context.decodeAudioData(byteArray, function(buffer) {
    var source = context.createBufferSource(); // creates a sound source
    source.buffer = buffer;    
    source.connect(context.destination); // connect the source to the context's destination (the speakers)
    source.noteOn(0); 
}, function(err) { console.log("err(decodeAudioData): "+err); });

And that's it! I have this working through my desktop version of Chrome and also running on mobile Safari (iOS 6 only of course as Web Audio is not supported in older versions). It takes a couple of seconds to load on mobile Safari (Vs less than 1 second on desktop Chrome) but this might be due to the fact that it spends time downloading the sound fonts. It might also be the fact that iOS prevents any sound playing until a user interaction event has occured. I need to do more work looking at how it performs.

Hope this saves someone else the grief I went through.

html5 - Using local file for Web Audio API in Javascript - Stack Overf...

html5 client-side web-audio
Rectangle 27 13

Yes: you can hide the built-in browser UI (by removing the controls attribute from audio) and instead build your own interface and control the playback using Javascript (source):

<audio id="player" src="vincent.mp3"></audio>
<div> 
  <button onclick="document.getElementById('player').play()">Play</button> 
  <button onclick="document.getElementById('player').pause()">Pause</button> 
  <button onclick="document.getElementById('player').volume += 0.1">Vol+ </button> 
  <button onclick="document.getElementById('player').volume -= 0.1">Vol- </button> 
</div>

You can then add CSS classes to each one of the elements (in this case, the div + buttons) and style them however you wish.

Additional properties & methods of the HTMLAudioElement JavaScript interface can be found here.

Is it possible to style html5 audio tag? - Stack Overflow

html5 audio
Rectangle 27 4

I don't know of any internet radio services playing back their streams with the Web Audio API currently, but I wouldn't be surprised to find one. I've been working on one myself using Audiocog's excellent Aurora.js library, which enables codecs in-browser that wouldn't normally be available, by decoding the audio with JavaScript. However, for compatibility reasons as you have pointed out, this would be considered a bit experimental today.

Most internet radio stations use progressive HTTP streaming (SHOUTcast/Icecast style) which can be played back within an <audio> element or Flash. This works well but can be hard to get right, especially if you use SHOUTcast servers as they are not quite 100% compatible with HTTP, hurting browser support in some versions of Firefox and a lot of mobile browsers. I ended up writing my own server called AudioPump Server to get better browser and mobile browser support with HTTP progressive.

Depending on your Flash code and ActionScript version available, you might also have to deal with memory leaks in creative ways, since by default Flash will keep all of your stream data in memory indefinitely as it was never built to stream over HTTP. Many use RTMP with Flash (with Wowza or similar on the server), which Flash was built to stream with to get around this problem.

iOS supports HLS which is basically a collection of static files served by an HTTP server. The encoder writes a chunk of the stream to each file as the encoding occurs, and the client just downloads them and plays them back seamlessly. The benefit here is that the client can choose a bitrate to stream and, raising quality up and down as network conditions change. This also means that you can completely switch networks (say from WiFi to 3G) and still maintain the stream since chunks are downloaded independently and statelessly. Android "supports" HLS, but it is buggy. Safari is the only browser currently supporting HLS.

Compatibility detection is not something you need to solve yourself. There are many players, such as jPlayer and JW Player which wrangle HTML5 audio support detection, codec support detection, and provide a common API between playback for HTML5 audio and Flash. They also provide an optional UI if you want to get up and running quickly.

Finally, most stations do offer a link to allow you to play the stream in your own media player. This is done by linking to a playlist file (usually M3U or PLS) which is downloaded and often immediately opened (as configured by the user and their browser). The player software loads this playlist and then connects directly to the streaming server to begin playback. On Android, you simply link to the stream URL. It will detect the Content-Type response header, disconnect, and open its configured media player for playback. These days you have to hunt to find these direct links, but they are out there.

If you ever want to know what a station is using without digging around in their compiled and minified source code, simply use a tool like Fiddler or Wireshark and watch the traffic. You will find that it is very straightforward under the hood.

html5 - Does web based radio and audio streaming services use the Web ...

html5 audio audio-streaming webradio
Rectangle 27 1

Because ios apps are sandboxed, the web view (basically safari wrapped in phonegap) allows you to store your mp3 file locally. I.e, there is no "cross domain" security issue.

This is as of ios6 as previous ios versions didn't support web audio api

html5 - Using local file for Web Audio API in Javascript - Stack Overf...

html5 client-side web-audio
Rectangle 27 1

Because ios apps are sandboxed, the web view (basically safari wrapped in phonegap) allows you to store your mp3 file locally. I.e, there is no "cross domain" security issue.

This is as of ios6 as previous ios versions didn't support web audio api

html5 - Using local file for Web Audio API in Javascript - Stack Overf...

html5 client-side web-audio
Rectangle 27 1

The JS Audio Data API will let you do this with an html5 audio tag, or audio that is played from javascript. See https://wiki.mozilla.org/Audio_Data_API for details and examples. I don't know offhand what the status of this API is in current browsers.

It's Mozilla only, therefore works in Firefox only. WebKit also has an Audio API that's more complex but also allows you to achieve the same.

html5 - Javascript mp3 audio data - Stack Overflow

javascript html5 audio mp3 volume
Rectangle 27 1

The answer is Yes. If it can be programmed in JavaScript it will be programmed in JavaScript. Also HTML5 would probably play a role with the Audio tag. Both work together to create the interaction.

JavaScript is a very powerful language and it is the most popular open source community at the moment. What that means is there is a large variety of modules to choose from. So you need a tool.

STEP #1: Use tools like NPM or GitHub. My first step for such a question would be to search for your key words on NPM like this:

https://www.npmjs.com/search?q=binaural+holophonic+stereo

STEP #2: See what is out there...

Surprisingly GitHub and Bower did not return results, but NPM did.

It looks like there are some good things there...

    - web-audio-school
    - audiosynth
    - augiobugger
    - sink

The next step is to hit the readme files of each to see if these libraries have the holophonic capabilities that you need.

STEP #4: But fret not if is doesn't exist.

Because of Atwoods Law - everything that can be written in JavaScript, will be written in JavaScript.

At least that is the trend we see is proving itself over the years. I personally know a group of computer music hackers in my city. And I can guarantee that if it has not been done - this is the type of thing that they are looking out for to solve.

So, if it is possible (which it sounds like it is) - then rest with some sense of inevitability, that it will turn up on NPM, eventually. And if not - it is you that has the pleasure of creating it, once you've mastered JavaScript modularization methodology. I've seen a few of these technologies surface now through NPM and the like. Web Audio is a specific area of advancement, which you can be on look out for impact with ES6. , WebWorkers might help you eventually.

Diving in technically - if a library does not exist. It sounds like what is required is - JS interoperability with the headphone hardware interface. Which increasingly is a capability of JS. But you may be slightly ahead of the curve here. It is possible, but the key word that would be missing if it does not exist is - interoperability. The need would be for JS to hardware interface interoperability... Which, by the way, is exactly what JS does really wel. So in concept yes this is reasonable. In implementation - I can't say. It requires a search.

  • But also learn the command line tools - bc they get u what u want.

All in all, even if you don't finish your holophonic proof of concept - you are learning valuable professional skills. JavaScript is a ripe ecosystem for a hobby deep-dive into Web Audio capabilities. It is a great idea - and if nothing exists... it is up to you to become the creator that gives it to the open-source world.

can you edit audio to play different amounts of sound through the 2 sp...

javascript html5 audio
Rectangle 27 2

@Tuan, You are trying to play the audio with the webview library. It is likely using the HTML5 API for audio or webaudio. If it is neither of these, then you need to ask the author.

Next, it is not best practice to use external source (http:). Your assests (javascript, css, audio files, etc) should live on the device. If you load files from the web, then the sound quality could be poor (or the audio may not play at all - see whitelist below). Load from the device.

Android 4.4.4 is Kitkat. The standard webview library was exchanged for the chromium version. This means your audio library might be confused about this or you need to give the library knowledge about this library. This also means your code may not work on devices before 4.4.4. (Mostly, because you cannot test it.)

The link you point to is likely using the core media plugin, even though they dont say so. In addition, the post is over 3 years old. Many thing have changed since them. NOTE: you have installed the media plugin in your config.xml. This is likely why your loop works.

You should start over. You've made many errors. In addition, to all that you have, You will need to implement the whitelist plugin (if you are going to import files, or talk to the network).

FIRST TRY this sample app - example plays on Android and iOS. You can download the Android version and test it. The iOS version requires I have your UUID compiled in.

There are 16 audio plugins you can choose from. I know a few do real time audio playback and have better control than the "core" plugin.

You should read:

  • Phonegap-Media-Test - source code for the example that plays on Android and iOS. You can download the Android version and test it.

UPDATE: 2015-12-01 - 2am Previously, I had forgotten to add a wild-card (*) to the CSP meta tag. I am now including this. This meta tag should be added to the header of the index.html file that is playing the audio.

<meta http-equiv="Content-Security-Policy" 
         content="default-src *; 
                  style-src * 'self' 'unsafe-inline' 'unsafe-eval'; 
                  script-src * 'self' 'unsafe-inline' 'unsafe-eval';">

UPDATE: 2015-12-01 - 3pm @Tuan, I've applied all the fixes as outlined in

The audio is now working on my Android LG Leon/Android 5.1.1 Truthfully, I would never do this on my own, but your code had enough working that after I tested it on my firefox(v34) browser, I was fairly certain it would work.

UPDATE: 2016-04-15 The code has been removed. Ask in the comments, if you need code.

Thanks but I knew Phonegap can play audio. My issue is the Phaser game can play sound after porting by Phonegap. Your example works because it doesn't play the audios by Phaser's functions.

Apparently I was not clear enough. You know very little about the task ahead, you can spend weeks and months and never find an answer - mostly because you have made bad assumption about Cordova/Phonegap. To fix your problem 1) don't load audio samples from the internet 2) if you must load audio sample internet, you will need to implement the whitelist system - otherwise your request will be blocked. 3) the audio library for Phaser may not be supported - you need details on it to make reasonable decisions on it.

To be extra clear, your post now looks confused. Mostly because you are making bad assumptions. And the addition to not get you any closer to your goal --- which appears to be to play this Phase audio library. This is why I posted the links. Best of Luck.

HMM... I'm not being clear on this. Your browser is not the webview library that Cordova/Phonegap uses. You can read my Notes on webview here. In short, every browser uses it's own custom library. (This is the reason for caniuse.com) The audio part has been the most inconsistent. The only way to know if an audio library works, is to make the most simple test. Otherwise, you are wasting you time. Best of Luck.

@Tuan, I found an error in my CSP which may explain why you are not getting sound. Previously, I had script-src 'self' 'unsafe-inline' 'unsafe-eval';. I did not have the wild card for loading the network. It should have been script-src * 'self' 'unsafe-inline' 'unsafe-eval';. I found this out about an hour ago testing a new App. I am surprised no one has mentioned it until now. Let me know. I'm adding this to my original answer.

cordova - Phaser HTML5 app cannot play sound after porting by Phonegap...

html5 cordova phonegap-build hybrid-mobile-app phaser-framework
Rectangle 27 2

@Tuan, You are trying to play the audio with the webview library. It is likely using the HTML5 API for audio or webaudio. If it is neither of these, then you need to ask the author.

Next, it is not best practice to use external source (http:). Your assests (javascript, css, audio files, etc) should live on the device. If you load files from the web, then the sound quality could be poor (or the audio may not play at all - see whitelist below). Load from the device.

Android 4.4.4 is Kitkat. The standard webview library was exchanged for the chromium version. This means your audio library might be confused about this or you need to give the library knowledge about this library. This also means your code may not work on devices before 4.4.4. (Mostly, because you cannot test it.)

The link you point to is likely using the core media plugin, even though they dont say so. In addition, the post is over 3 years old. Many thing have changed since them. NOTE: you have installed the media plugin in your config.xml. This is likely why your loop works.

You should start over. You've made many errors. In addition, to all that you have, You will need to implement the whitelist plugin (if you are going to import files, or talk to the network).

FIRST TRY this sample app - example plays on Android and iOS. You can download the Android version and test it. The iOS version requires I have your UUID compiled in.

There are 16 audio plugins you can choose from. I know a few do real time audio playback and have better control than the "core" plugin.

You should read:

  • Phonegap-Media-Test - source code for the example that plays on Android and iOS. You can download the Android version and test it.

UPDATE: 2015-12-01 - 2am Previously, I had forgotten to add a wild-card (*) to the CSP meta tag. I am now including this. This meta tag should be added to the header of the index.html file that is playing the audio.

<meta http-equiv="Content-Security-Policy" 
         content="default-src *; 
                  style-src * 'self' 'unsafe-inline' 'unsafe-eval'; 
                  script-src * 'self' 'unsafe-inline' 'unsafe-eval';">

UPDATE: 2015-12-01 - 3pm @Tuan, I've applied all the fixes as outlined in

The audio is now working on my Android LG Leon/Android 5.1.1 Truthfully, I would never do this on my own, but your code had enough working that after I tested it on my firefox(v34) browser, I was fairly certain it would work.

UPDATE: 2016-04-15 The code has been removed. Ask in the comments, if you need code.

Thanks but I knew Phonegap can play audio. My issue is the Phaser game can play sound after porting by Phonegap. Your example works because it doesn't play the audios by Phaser's functions.

Apparently I was not clear enough. You know very little about the task ahead, you can spend weeks and months and never find an answer - mostly because you have made bad assumption about Cordova/Phonegap. To fix your problem 1) don't load audio samples from the internet 2) if you must load audio sample internet, you will need to implement the whitelist system - otherwise your request will be blocked. 3) the audio library for Phaser may not be supported - you need details on it to make reasonable decisions on it.

To be extra clear, your post now looks confused. Mostly because you are making bad assumptions. And the addition to not get you any closer to your goal --- which appears to be to play this Phase audio library. This is why I posted the links. Best of Luck.

HMM... I'm not being clear on this. Your browser is not the webview library that Cordova/Phonegap uses. You can read my Notes on webview here. In short, every browser uses it's own custom library. (This is the reason for caniuse.com) The audio part has been the most inconsistent. The only way to know if an audio library works, is to make the most simple test. Otherwise, you are wasting you time. Best of Luck.

@Tuan, I found an error in my CSP which may explain why you are not getting sound. Previously, I had script-src 'self' 'unsafe-inline' 'unsafe-eval';. I did not have the wild card for loading the network. It should have been script-src * 'self' 'unsafe-inline' 'unsafe-eval';. I found this out about an hour ago testing a new App. I am surprised no one has mentioned it until now. Let me know. I'm adding this to my original answer.

cordova - Phaser HTML5 app cannot play sound after porting by Phonegap...

html5 cordova phonegap-build hybrid-mobile-app phaser-framework