maandag, mei 19, 2008

Capture and write an audio stream with Adobe AIR

A small demo, including source files, in how to capture and record an audio stream in AIR.
You can listen to the audio stream and write it as an mp3 to your desktop.

I got the idea to try from my colleague Wannes Coolen. Thx dude!

In the example I use the internet radio audio stream from Studio Brussel.
This is the biggest alternative radio station in Belgium.

In general it works like this:
1. Use URLStream class to access the stream
2. Transfer the stream into a bytearray like this:
        var bArray : ByteArray = new ByteArray();
        stream.readBytes(bArray);
3. Write the bytearray to the desktop with FileStream
4. You are done.

Please never mind the looks of this application, it's about what's inside :-)

Download demo AIR app here
Download source files here

Enjoy!

5 reacties:

Benz zei

If we could now only access the bytes from the microphone that would be awesome ;-)

Peter zei

great idea Wim and Wannes -- got me inspired to write a little AIR app for scheduled recordings from online radio stations ;)

alex zei

brilliant! i was wondering if there was a way to specify how much of the stream to save? say if i wanted write only the last 10 seconds of audio to a file? I have struggled to find a way. I tried using filestream.position to set a number of bytes to write from but it didnt work. any suggestions would be great. good job though!

Anoniem zei

...please where can I buy a unicorn?

Anoniem zei

...please where can I buy a unicorn?