Streaming only audio
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Streaming only audio

  1. #1
    Just wondering if anyone has set up the comm server to stream just audio... no video. How is this different from the video method? Any suggestions would be much appreciated.

  2. #2
    psx = new Moderator();
    Join Date
    Jan 2001
    Posts
    923
    Hey -
    It's definitely doable - both use the netStream object. It's roughly the same as doing video:
    Code:
    function init() {
    // create NetConnection object
    connection = new NetConnection();
    // connect to server
    connection.connect("rtmp:/my_app");
    myMic = Microphone.get();
    };
    
    init();
    
    //Broadcast
    function BroadCast() {
    inStream.close();
    outStream = new NetStream(connection);
    outStream.attachAudio(myMic);
    outStream.publish("MyAudio","live");
    	}
    	
    function stopBroadCast() {
    	outStream.publish(false);
    	outStream.close();
    	}
    	
    	
    //Listening
    function Listen() {
    	//Audio
    	inStream = new NetStream(connection);
    	inStream.receiveAudio(true);
    	inStream.play("MyAudio");
    	}
    That should get you going - You'll probably want 2 files - the first being the broadcaster, and would include the "init", "broadcast", and "stopBroadcast" functions. The second file would need just the "init" and "Listen" functions I believe. A few changes would be needed in init, basically you don't need to attach a mic.

    Psx

  3. #3
    What I am trying to do won't be in real time... Just sort of a re-broadcast of a previously recorded audio piece. What format would this audio need to be in? FLV? SWF? or can it handle mp3?

  4. #4
    Danny Gomez Creations cosmiceye's Avatar
    Join Date
    Mar 2002
    Location
    under a palmtree in Jamaica waiting for psytopia 2005 to begin
    Posts
    982
    to record a stream, simply replace the "live" in:
    Code:
    outStream.publish("MyAudio","live");
    to:
    Code:
    outStream.publish("MyAudio","record");
    the filename will be saved as "MyAudio.flv" in a streams folder. I read somewhere in the macromedia site that the streams could be saved as a mp3 instead, however I havent found any instructions for such thing...


    Oh, and if you dont want to be replacing the file , you should store a variable on a shared object and add that as the filename. Something like:

    Code:
    var recordnum=mysharedObject_so.data.amount;
    
    //after user selects recording
    
    recordnum=recordnum+1; 
    
    mysharedObject_so.data.amount=recordnum;
    
    outStream.publish("MyAudio"+recordnum,"record");

    this is not a great copy/paste code like john's but it might give u an idea or something. A similar solution is found among the sample apps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com