raksa

add audio buffer to cache

Recommended Posts

hi i'm a newbie for phaser framework

i want to know that is it possible to load audio from existing buffer or blob data to cache?

for instant after i got audio buffer from input audio, i want to play it by phaser audio.

because there a problem in Android browser, i can't play audio from converted dataurl via html5 audio tag.

thanks,

Share this post


Link to post
Share on other sites

i got the answer:rolleyes:

var fileReader = new FileReader();
fileReader.onload = function () {
   game.cache.addSound("key", "filename.wav", this.result);
   //and use it
   var audio = game.add.audio("key");
   audio.play();
};
fileReader.readAsArrayBuffer(blob);

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.