Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recording sound in browser

Tags:

html

flash

audio

If one wants to record sound from the microphone input in the browser one can do so today through Flash. (Afaik there is currently no other good option which works across browsers.)

Is there a simple swf-plugin which allows one to do so? That is, with the options "Start recording", "Stop recording", "Get wave of recorded sound (or similar)".

like image 323
Michael Avatar asked Jan 20 '23 13:01

Michael


2 Answers

This question is a little old, but I recently had to answer this myself and found the following article most useful:

http://www.html5rocks.com/en/tutorials/getusermedia/intro/

With HTML 5 you can avoid Flash altogether and simply use

<input type="file" accept="audio/*;capture=microphone"> 

This mitigate the reliance on Flash (as you say you were concerned about cross browser compatibility) and is still understood by most up to date desktop and mobile browsers.

like image 106
Jamie M Avatar answered Jan 28 '23 23:01

Jamie M


You can do it easily since FlashPlayer 10.1 with SampleData (event) from Microphone.

microphoneInstance = Microphone.getMicrophone();    
microphoneInstance.addEventListener(SampleDataEvent.SAMPLE_DATA, sampleDataHandler);

//will contains your microphone RAW sound data
buffer = new ByteArray();
function sampleDataHandler(event:SampleDataEvent):void
{              
    while(event.data.bytesAvailable > 0)
        buffer.writeFloat(event.data.readFloat());
}

An example (with code), recording locally (without any server) and save a WAV file:

MicRecorder, a tiny microphone library by Thibault Imbert MicRecorder - A tiny AS3 Microphone library on Google Code

An other example (without code), recording locally also but save a MP3 file:

http://unitzeroone.com/labs/rtmic2mp3/

like image 31
mems Avatar answered Jan 28 '23 23:01

mems