How To Replay An Audio-blob In Javascript?
I want to replay an audio blob (wav), recorded in javascript using the Web Audio API. I tried the following: function replayBlob( blob ) { var blobURL = window.URL.createObject
Solution 1:
If you're using Web Audio to record, I figure you can use it for playback as well, right? If so, recorder.js has a how-to in the README: https://github.com/mattdiamond/Recorderjs
I'll go ahead and copy the gist of here, in case recorder.js changes in the future. You have two Float32Arrays (left and right channel) and then do this;
function getBufferCallback( buffers ) {
var newSource = audioContext.createBufferSource();
var newBuffer = audioContext.createBuffer( 2, buffers[0].length, audioContext.sampleRate );
newBuffer.getChannelData(0).set(buffers[0]);
newBuffer.getChannelData(1).set(buffers[1]);
newSource.buffer = newBuffer;
newSource.connect( audioContext.destination );
newSource.start(0);
}
Post a Comment for "How To Replay An Audio-blob In Javascript?"