开发者

Recording sound in browser

If one wants to record sound from the m开发者_StackOverflow中文版icrophone 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)".


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.


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/


Here's an example of sending the audio to a server via an HTTP post. This gets around the messy business of setting up a Flash Media Server:

https://code.google.com/p/wami-recorder/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜