0 Replies Latest reply on Jan 19, 2012 3:32 AM by Geetika.s

    Audio stream not published on Android (recorded stream file size only 1 kb)

    Geetika.s Level 1

      I created a netstream object, attached the android microphone and published it as recorded. The point is that the stream's "publish.start" is fired but "record.start" is not fired. And even the file size created on the server is just 1 kb. It does not update.

       

      Can anyone please provide me with a suitable solution?

       

      --> The microphone object is not null. I have checked that.

       

                  private var nc:NetConnection = new NetConnection();

                  private var ns:NetStream = null;

                  private var recNs:NetStream = null;

                  private var mic:Microphone = Microphone.getMicrophone(-1);

                 

                  protected function startPub_clickHandler(event:MouseEvent):void

                  {

                      nc.connect("rtmp://xx.xx.xx.xx/abc");

                      nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);

                      startPub.enabled = false;

                  }

                 

                  private function netStatus(evt:NetStatusEvent):void{

                      txtArea.appendText("Mobile " + evt.info.code);

                      switch(evt.info.code){

                          case "NetConnection.Connect.Success":

                              ns = new NetStream(nc);

                              mic.gain = 100;

                              mic.addEventListener(SampleDataEvent.SAMPLE_DATA, sampleDataEventHandler);

                              txtArea.appendText("\nMic " + mic.name + mic.gain);

                              ns.attachAudio(mic);

                              ns.publish("stream", "record");

                              ns.addEventListener(NetStatusEvent.NET_STATUS, streamStatus);

                              break;

                      }

                  }

                 

                  private function streamStatus(evt:NetStatusEvent):void{

                      txtArea.appendText("\nMobile " + evt.info.code);

                      switch(evt.info.code){

                          case "NetStream.Publish.Start":

                              recNs = new NetStream(nc);

                              recNs.play("stream");

                              break;

                          case "NetStream.Record.Start":

                              break;

                      }

                  }

                 

                  private function sampleDataEventHandler(evt:SampleDataEvent):void{

                      txtArea.appendText("\nActivity " + mic.activityLevel);

                  }