Read an external audio file in Cordova

Asked

Viewed 10 times

1

Good afternoon, you guys. I’m having difficulty reading the external file of Cordova I download it from my server it saves correctly in the android app by the indicated way but when I try to read it does not come out audio but the file is correct I can read the downloaded file with my audio player from cellular normally.

follows the code

var fileTransfer = new FileTransfer();
           var uri = encodeURI(meu_host);
           var fileURL =  cordova.file.externalDataDirectory + "teste.ogg";

           fileTransfer.download(
              uri, fileURL, function(entry) {
                    console.log("download complete: " + entry.toURL());
                  $("#audio-teste").attr('src',fileURL)
                  /*--codigo de teste--*/
            var meuFile = cordova.file.externalDataDirectory;
                  resolveLocalFileSystemURL(meuFile, function(entry) {
                      
                      var readerN = fileSystem.createReader();
                      readerN.readEntries(
                          function (entry) {
                              var arrayN =[];
                        for(var i="0"; i < entry.length; ++i){
                            var entradaN = entry[i].name;
                            arrayN.push(entradaN);
                            //console.log(array);
                            console.log('teste aq' + arrayN);
                        }
                          }
                      )
                      //console.log(entry);
                  });
            
                  /*----*/
                  
              },

              function(error) {
                 console.log("download error source " + error.source);
                 console.log("download error target " + error.target);
                 console.log("download error code" + error.code);
              },

              false, {
                 headers: {
                    "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
                 }
              }
           );
          
          /*----*/
            
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.