Crashalot
Crashalot

Reputation: 34523

How to capture audio from a browser?

My client needs to let a user record a message from the browser, then export the message as an audio file (e.g., WAV).

How is this best accomplished? Flash, Java, HTML5? By best, I mean something that is straightforward to implement and also broadly supported.

What are people's experiences using HTML5?

Thanks!

Upvotes: 0

Views: 3112

Answers (3)

Peter Knego
Peter Knego

Reputation: 80340

Flash is one option but you need a media streaming server (Adobe Media Server, Wowza, Red5). There is no way to capture and store audio on Flash locally to a file.

If you are willing to go with Java applets there are multiple solutions. All of them require access to local filesystem and will ask users for additional permissions. For example try http://www.javasonics.com/ or Google "applet record audio".

Update: since Flash 10.0 there is option to use Microphone with SampleDataEvent.SAMPLE_DATA. This gives access to raw audio data from microphone. See this project for implementation: http://code.google.com/p/micrecorder/

Upvotes: 4

Ian McGraw
Ian McGraw

Reputation: 571

Assuming you mean "export" to a server, here is an open-source Flash solution that does NOT require a flash media server:

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

The recording is transferred via HTTP post to a server-side technology of your choosing. In the simplest case, you can capture and save audio with 4 lines of PHP code:

<? 
$content = file_get_contents('php://input');
$fh = fopen('output.wav', 'w') or die("can't open file");
fwrite($fh, $content);
fclose($fh);
?>

As for HTML5 support, keep an eye on getUserMedia()

Upvotes: 0

vstoyanov
vstoyanov

Reputation: 881

Well I suspect that such a feature of HTML5 would be pretty non-standard, and the browser support would differ a lot (with many browsers not including any).

Java is not as popular as flash and there are many people who don't have JRE's at all.

So all in all I would go for the Flash solution in this case. And maybe with an HTML5 fallback for some limited cases, shall resources allow.

Upvotes: 1

Related Questions