Sending Audio to a Server Using NetStream (or similar) in Flex (not Mic or webcam)

Posted on 2010-01-03
Last Modified: 2012-05-08

I am trying to ascertain if it is possible to stream audio to a server using NetStream in the same way you can with a microphone.

To clarify I know how to send webcam or microphone content (using AttachAudio and AttachVideo).  What I am trying to achieve is have a button in the flex app to play a soundfile and have that sound file streamed to the server.

I can't find any way of doing it currently and am hoping someone might know a workaround.


Question by:olifarago
    LVL 14

    Expert Comment

    It's possible, just call the publish method of your NetStream instance without calling attachAudio.
    LVL 9

    Author Comment

    And what will that transmit over the stream?
    LVL 14

    Accepted Solution

    It will still be Audio.

    Look at the example below using attachAudio

    var conn:NetConnection = new NetConnection();
         var stream:NetStream = new NetStream(conn);
         var live_mic:Microphone = Microphone.get();
         live_mic.rate = 8;
         var soundTrans:SoundTransform = new SoundTransform();
         soundTrans.volume = 6;
         live_mic.soundTransform = soundTrans;

    See how the attaching of the mic allows you to use the mic as an audio with a name of mic_stream.

    Therefore if you want to publish normal audio, you need to give your audio a name and attach it. However, the thing is how would the publish method know you are publishing audio?

    So here's another example demonstrating how you should do it.

    Given audio id is :sample_music.mp3

    Then the code would be like this:

    var conn:NetConnection = new NetConnection();
         var stream:NetStream = new NetStream(conn);
    LVL 9

    Author Closing Comment

    I have had to abandon this project for now so this is untested.  I thought this solution starts on demand streaming an MP3 that is stored on a server to the client over the netstream but the answer is suggesting it will stream form the client to the server.

    I don't have time to test so I have accepted in case it is useful for others.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.eā€¦
    After several days of searching and hunting for limited documentation, I wanted to share this guide to hopefully save someone the hassle of trying to figure this out on their own. I have tested this on Xendesktop 7.1 and PS 4.5 running simultaneousā€¦
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now