Ionic 3 get base64 audio string from recorded file

不想你离开。 提交于 2019-12-02 10:44:16

okay, I just found out that you can use method "resolveLocalFilesystemUrl" of the cordova-plugin-file which will return you the object and inside this object there is a property "nativeURL" which can be used as a source(src) for the video tag(had to video tag instead of audio because 3gp format is actually for video)

this.file.readAsDataURL(filePathtoUpload, this.fileName)
.then((base64Audio) => {
console.log(base64Audio);
})
.catch(function (err: TypeError) {
console.log("readAsDataURL: " + err);
});

this works for me

Read this:https://ionicframework.com/docs/v3/native/base64/

It is the oficial website API of ionic. Just install that plugin and use this:

 this.base64.encodeFile(this.filePath + this.fileName).then(
      (base64:any) =>{
      console.log('file base64 encoding: ' + base64);
    });

In this post, i explain it better. I let the link here: convert audio file to base64 in ionic 3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!