Created
August 7, 2021 09:21
-
-
Save VieVie31/15f81e6696c212cad2c8cfcc08e5e5cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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