2 Replies Latest reply on Sep 8, 2010 9:07 AM by yohann.martineau

    flex applet in flash application, no sound

    yohann.martineau Level 1

      Hello,

       

      I have flex applet which captures microphone and plays back remote contact's voice. This application is running fine in browser or in standalone pages, but when this application is loaded in a flash application, no sound nor microphone capture. I have logs in this application, network invocations are working fine with my remote rtmp server application.

       

      I remember I had an issue with allowScriptAccess which needed to be set to always instead of sameDomain on the web page where the main flash application was loaded, but here, this parameter seems to be set.

       

      Any idea is welcome,

       

      Thank you,

       

      yohann

        • 1. Re: flex applet in flash application, no sound
          yohann.martineau Level 1

          I isolated my issue, and the problem is just on microphone side. Usually, when I do the following (in a application directly loaded from browser):

           

          _microphone = Microphone.getMicrophone();

          _netConnection = new NetConnection();

          ...

          _netConnection.connect(parameters.url);

          ...

          // in callback

          _netStream = new NetStream(_netConnection);

          _netStream.attachAudio(_microphone); // displays authorization popup

          _netStream.publish("test");

           

          I have the security popup.

           

          But when I load the previous application in a application developed with Flash CS4 using URLRequest and Loader, no authorization popup is displayed, thus => no sound.

          • 2. Re: flex applet in flash application, no sound
            yohann.martineau Level 1

            here is the complete test application (test.mxml):

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                backgroundGradientColors="[0xffffff, 0xffffff]"
                creationComplete="creationComplete()">
                <mx:Script>
                    <![CDATA[

             

                      import flash.events.NetStatusEvent;
                      import flash.events.SecurityErrorEvent;
                      import flash.events.IOErrorEvent;
                      import flash.events.AsyncErrorEvent;
                      import flash.net.NetConnection;
                      import flash.net.NetStream;
                      import flash.net.ObjectEncoding;
                      import flash.media.Microphone;
                      import mx.controls.Alert;

             

                      private var _microphone:Microphone;
                      private var _netConnection:NetConnection;
                      private var _netStream:NetStream;

             

                      private function log(message:String):void
                      {
                        debug.text += message + "\n";
                      }

             

                        private function creationComplete():void
                        {
                          log("creationComplete");
                          _microphone = Microphone.getMicrophone();

             

                          if (!parameters.url) {
                            Alert.show("url parameter required");
                            return;
                          }
                          _netConnection = new NetConnection();
                    _netConnection.objectEncoding = ObjectEncoding.AMF0;
                    _netConnection.addEventListener(NetStatusEvent.NET_STATUS,
                      netStatusHandler);
                    _netConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
                      securityErrorHandler);
                    _netConnection.addEventListener(IOErrorEvent.IO_ERROR,
                      ioErrorHandler);
                    _netConnection.addEventListener(AsyncErrorEvent.ASYNC_ERROR,
                      asyncErrorHandler);
                    _netConnection.connect(parameters.url);
                        }

             

                        // Callbacks

             

                  private function netStatusHandler(netStatusEvent:NetStatusEvent):void
                  {
                    log("netStatusHandler(" + netStatusEvent + ")");
                    switch (netStatusEvent.info.code)
                    {
                      case "NetConnection.Connect.Success":
                        log("before new NetStream");
                        _netStream = new NetStream(_netConnection);
                        log("before attachAudio, microphone = " + _microphone);
                        _netStream.attachAudio(_microphone);
                        log("before publish");
                        _netStream.publish("test");
                        break;
                      case "NetConnection.Connect.Closed":
                        break;
                      default:
                        break;
                    }
                  }
             
                  private function securityErrorHandler(
                    securityErrorEvent:SecurityErrorEvent):void
                  {
                    log("securityErrorHandler(" + securityErrorEvent + ")");
                  }
             
                  private function ioErrorHandler(ioErrorEvent:IOErrorEvent):void
                  {
                    log("ioErrorHandler(" + ioErrorEvent + ")");
                  }
             
                  private function asyncErrorHandler(asyncErrorEvent:AsyncErrorEvent):void
                  {
                  }
                    ]]>
                </mx:Script>
                <mx:TextArea id="debug" width="640" height="480"/>
            </mx:Application>

             

             

             

            And here is CS4 code:

             

             

            import gs.TweenLite;


            import flash.filters.DropShadowFilter;


            var shadowTitre:DropShadowFilter = new DropShadowFilter();
            shadowTitre.distance = 1;
            shadowTitre.angle = 280;
            //shadow.alpha = 10;
            shadowTitre.blurX = 2;
            shadowTitre.blurY = 2;
            shadowTitre.color = 0x162541;
            var formatTitre:TextFormat = new TextFormat();
            formatTitre.font = "Arial";
            formatTitre.bold = true;
            formatTitre.size = 17;
            formatTitre.color = 0xFFFFFF;
            formatTitre.align = TextFormatAlign.CENTER;


            var titre:TextField = new TextField();
            titre.width = 310;
            titre.height = 35;
            titre.selectable=false;
            titre.defaultTextFormat = formatTitre;
            titre.y = 15;
            titre.text = "Visioconférence";
            mc_fenetre.mc_titre.addChild(titre);
            titre.filters = [shadowTitre];

             


            mc_icone:MovieClip;

             

            mc_fenetre.visible = false;
            var iconeActif:Number = 0;
            var iconeNews;       

             


            var containers2:Loader = new Loader();

             

            function conteneur2(elmt : *):void
            {
               
                containers2.load(elmt);

             

                mc_fenetre.addChild(containers2);
                containers2.x = 10;
                containers2.y = 85;
               
            }

             


            iconeVisio();


                    function iconeVisio() {

             

                        mc_icone.buttonMode = true;

             

                        mc_icone.addEventListener(MouseEvent.MOUSE_DOWN, clickIcone);
                       
                        mc_icone.x = 560
                        mc_icone.y = 623
                    }
                   
                    function clickIcone(e:MouseEvent):void{
                        if(iconeActif == 0){
                            mc_fenetre.visible=true;
                            iconeActif = 1;
                            TweenLite.to(e.currentTarget, .3, {alpha:0.5});
                           
                            //chargement de la visio
                            // url visioconf
                            var elmt:URLRequest = new URLRequest("http://mysite.com/test.swf?url=rtmp://abc.com/appli");
                            conteneur2(elmt);

             

                        }else{
                            mc_fenetre.visible=false;
                            iconeActif = 0;
                            TweenLite.to(e.currentTarget, .3, {alpha:1});
                        }
                    }
                   
                    mc_fenetre.bt_dragAndDrop.doubleClickEnabled = true ;
                    mc_fenetre.bt_dragAndDrop.addEventListener(MouseEvent.DOUBLE_CLICK, fonctionFermeFenetre) ;
                   
                    mc_fenetre.bt_fermeFenetre.addEventListener(MouseEvent.MOUSE_UP, fonctionFermeFenetre);
                   
                    function fonctionFermeFenetre(evt:MouseEvent):void{
                           mc_fenetre.visible = false;
                           iconeActif = 0;
                            TweenLite.to(mc_icone, .3, {alpha:1});
                    }

            stop();