title: Mp3 file to Base64 encode string conversion in android phonegap
body: <p>I have a function to encode an mp3 file to base64 string.But when the file get executed some errors are generating.My function is follows :</p>
  
  <p>function recordAudioToBase64() {</p>
  
  <pre><code>console.log('encodeing fun reached');
  var file = 'jivebirdrecord.mp3';
  window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFile, fail);
  </code></pre>
  
  <p>}</p>
  
  <p>function gotFile(fileSystem) {</p>
  
  <pre><code>fileSystem.root.getFile("jivebirdrecord.mp3", null, gotFileEntry, fail);
  </code></pre>
  
  <p>}</p>
  
  <p>function gotFileEntry(fileEntry) {</p>
  
  <pre><code>fileEntry.file(gotFile, fail);
  </code></pre>
  
  <p>}</p>
  
  <p>function gotFile(file) {</p>
  
  <pre><code>readDataUrl(file);
  </code></pre>
  
  <p>}</p>
  
  <p>function readDataUrl(file) {</p>
  
  <pre><code> var reader = new FileReader();
   reader.onloadend = function(evt) {
      base = evt.target.result;
    };
    reader.readAsBinaryString(file);
  </code></pre>
  
  <p>}</p>
  
  <p>function fail() {</p>
  
  <pre><code> console.log('failed......');
  </code></pre>
  
  <p>}</p>
  
  <p>And i have the following error :</p>
  
  <p>**processMessage failed: Error: TypeError: Failed to execute 'readAsDataURL' on 'FileReader': The argument is not a Blob.</p>
  
  <p>processMessage failed: Stack: TypeError: Failed to execute 'readAsDataURL' on 'FileReader': The argument is not a Blob.</p>
  
  <pre><code>at FileReader.readAsDataURL (file:///android_asset/www/plugins/org.apache.cordova.file/www/FileReader.js:201:33)
  
  at readDataUrl (file:///android_asset/www/js/script.js:293:14)
  
  at gotFile (file:///android_asset/www/js/script.js:283:4)
  
  at file:///android_asset/www/plugins/org.apache.cordova.file/www/requestFileSystem.js:52:25
  at success (file:///android_asset/www/plugins/org.apache.cordova.file/www/fileSystems-roots.js:40:13)
  
  at Object.cordova.callbackFromNative (file:///android_asset/www/cordova.js:292:54)
  
  at processMessage (file:///android_asset/www/cordova.js:1039:21)
  
  at Function.androidExec.processMessages (file:///android_asset/www/cordova.js:1076:13)
  
  at pollOnce (file:///android_asset/www/cordova.js:944:17)
  
  at pollOnceFromOnlineEvent (file:///android_asset/www/cordova.js:939:5)
  
  processMessage failed: Message: S01 File810616738 
  
   [{"fullPath":"\/","filesystemName":"temporary","isDirectory":true,"nativeURL":"file:\/\/\/storage\/emulated\/0\/Android\/data\/com.phonegap.helloworld\/cache\/","filesystem":0,"isFile":false,"name":""},
  </code></pre>
  
  <p>{"fullPath":"/","filesystemName":"persistent","isDirectory":true,"nativeURL":"file:///storage/emulated/0/","filesystem":1,"isFile":false,"name":""},</p>
  
  <p>{"fullPath":"/","filesystemName":"content","isDirectory":true,"nativeURL":"cdvfile://localhost/content/","filesystem":1,"isFile":false,"name":""},</p>
  
  <p>{"fullPath":"/","filesystemName":"files","isDirectory":true,"nativeURL":"file:///data/data/com.phonegap.helloworld/files/","filesystem":1,"isFile":false,"name":""},</p>
  
  <p>{"fullPath":"/","filesystemName":"files-external","isDirectory":true,"nativeURL":"file:///storage/emulated/0/Android/data/com.phonegap.helloworld/files/","filesystem":1,"isFile":false,"name":""},</p>
  
  <p>{"fullPath":"/","filesystemName":"documents","isDirectory":true,"nativeURL":"file:///data/data/com.phonegap.helloworld/files/Documents/","filesystem":1,"isFile":false,"name":""},{"fullPath":"/","filesystemName":"sdcard","isDirectory":true,"nativeURL":"file:///storage/emulated/0/","filesystem":1,"isFile":false,"name":""},</p>
  
  <p>{"fullPath":"/","filesystemName":"cache","isDirectory":true,"nativeURL":"file:///data/data/com.phonegap.helloworld/cache/","filesystem":1,"isFile":false,"name":""},</p>
  
  <p>{"fullPath":"/","filesystemName":"cache-external","isDirectory":true,"nativeURL":"file:///storage/emulated/0/Android/data/com.phonegap.helloworld/cache/","filesystem":1,"isFile":false,"name":""},</p>
  
  <p>{"fullPath":"/","filesystemName":"root","isDirectory":true,"nativeURL":"file:///","filesystem":1,"isFile":false,"name":""}]**</p>
  
  <p>Please help me to find a solution for converting an mp3 file to base64 string using phonegap and jquery mobile.
  Thnaks</p>