So, I'm currently trying to read an Audio file I just saved on the App's directory (Android) through the cordova file-plugin, but I keep getting the same error code 5, which stands for "ENCODING_ERR".
This is how I create the file and start recording
start() {
this.filename = this.file.externalDataDirectory.replace(/file:\/\//g, '');
this.mediaobject = this.media.create(this.filename + 'audioprofile' + '.3gp');
this.mediaobject.startRecord();
}
This is how I stop recording and save the file
stop() {
this.mediaobject.stopRecord();
this.mediaobject.release();
...
And this is where I'm stuck: right after saving it, I need to have it as a String, so I'm try to read it ( alert(content)
should show me that string)
stop() {
this.mediaobject.stopRecord();
this.mediaobject.release();
this.storage.get("uid").then((id) => {
try{
this.file.readAsDataURL(this.filename,'audioprofile'+'.3gp').then((filecontent)=>{
alert(filecontent);
},(err)=>{
alert(err.code);
})
} `
After some research I found out it PROBABLY means I'm not giving the right path for it, but I've tried everything, any combinations of 'filename' and 'filepath' were made, even adding the prefix removed on start().
I want to know if someone managed to read a file with this cordova plugin and if you did, please help me out.
Thanks in advance, this is my first post here \o/ (although I've always used the website, love u guys).
i had the same problem. I solved it giving this path:
this.media.create(this.file.externalDataDirectory + this.nameFile);
I dont know why but this.file.readAsDataURL
cant read the file if u save it deleting /file:
Remember change the path in all your methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With