In Angular, I have the following code which records audio, get the blob, and converts it to base64, using FileReader. But I'm not able to return this base64 data from onloadend method of file reader
getRecordedAudio() {
if (this.recordedAudio) {
let fileReader = new FileReader();
fileReader.onloadend = function() {
let base64data = fileReader.result;
console.log('base64data-', base64data);
// how to return here?
};
fileReader.readAsDataURL(this.recordedAudio);
}
}
How can I do this using either callback
or .then
? Or any other way?