Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
119
rated 0 times [  121] [ 2]  / answers: 1 / hits: 18066  / 9 Years ago, wed, july 1, 2015, 12:00:00

I want to convert audio file into base64 using Javascript only.



We can convert images into base64 using canvas. But how can we convert audio files.



Any help will be grateful.


More From » audio

 Answers
243

you can give the below code a try, it uses btoa



function getData(audioFile, callback) {
var reader = new FileReader();
reader.onload = function(event) {
var data = event.target.result.split(',')
, decodedImageData = btoa(data[1]); // the actual conversion of data from binary to base64 format
callback(decodedImageData);
};
reader.readAsDataURL(audioFile);
}

[#65968] Monday, June 29, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
myakylas

Total Points: 66
Total Questions: 85
Total Answers: 95

Location: Guadeloupe
Member since Sat, Aug 22, 2020
4 Years ago
myakylas questions
Thu, Apr 28, 22, 00:00, 2 Years ago
Thu, Apr 8, 21, 00:00, 3 Years ago
Sat, Sep 19, 20, 00:00, 4 Years ago
;