Skip to content

Instantly share code, notes, and snippets.

@VieVie31
Created August 7, 2021 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VieVie31/15f81e6696c212cad2c8cfcc08e5e5cf to your computer and use it in GitHub Desktop.
Save VieVie31/15f81e6696c212cad2c8cfcc08e5e5cf to your computer and use it in GitHub Desktop.
/**
* Apply a callback on audio data provided as a blob data url ("blob:http://...")
* `processAudioBlobURLinBase64(audio.src, (b64) => console.log(b64));`
*/
function processAudioBlobURLinBase64(audioBlobURL, callback) {
fetch(audio.src).then((a) => a.blob().then(
(blob) => {
var reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = function () {
var base64data = reader.result;
callback(base64data);
}
}
))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment