javascript - Receiving "decodeAudioData error null" in Chrome -


hello web audio developers,

i receiving "decodeaudiodata error null" in chrome , "decodeaudiodata error undefined" in firebug.

firebug says "the buffer passed decodeaudiodata contains unknown content type."

is there wrong code or there else needs worked out "web audio api"?

<!doctype html> <html lang="en-us"> <head>     <meta charset="utf-8">     <title>together 2 </title> </head> <body> <script type="text/javascript">   window.onload = init;   var context;   var bufferloader;   function init() {     window.audiocontext = window.audiocontext || window.webkitaudiocontext;     context = new audiocontext();     bufferloader = new bufferloader(context,       [ '../web-audio/path/chrono.mp3' ],       finishedloading     );     bufferloader.load(); }  function finishedloading(bufferlist) {   var source1 = context.createbuffersource();   source1.buffer = bufferlist[0];   source1.connect(context.destination);   source1.start(0); }  function bufferloader(context, urllist, callback) {   this.context = context;   this.urllist = urllist;   this.onload = callback;   this.bufferlist = new array();   this.loadcount = 0; } bufferloader.prototype.loadbuffer = function(url, index) { // load buffer asynchronously   var request = new xmlhttprequest();   request.open("get", url, true);   request.responsetype = "arraybuffer";   var loader = this;   request.onload = function() {     // asynchronously decode audio file data in request.response     loader.context.decodeaudiodata(       request.response,       function(buffer) {         if (!buffer) {           alert('error decoding file data: ' + url);           return;         }         loader.bufferlist[index] = buffer;         if (++loader.loadcount == loader.urllist.length)           loader.onload(loader.bufferlist);       },       function(error) {         console.error('decodeaudiodata error', error);       }     );   }   request.onerror = function() {     alert('bufferloader: xhr error');   }   request.send(); }  bufferloader.prototype.load = function() {     (var = 0; < this.urllist.length; ++i)       this.loadbuffer(this.urllist[i], i);     } </script> </body> </html> 

i had same problem , down type of codec used on wav file itself. pcm supported whereas files throwing me errors ms-adpcm. can use quicktime or vlc codec information , convert them pcm if necessary.

i'd imagine similar issue mp3.


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -