2012-03-23 168 views
0

我是flex中的新成员。我创建了动态Web项目。运行。它可通过http://localhost:5080/myApp访问。现在我想创建连接到该应用程序,但我得到了NetConnection.Connect.Rejected。这是我的代码:连接到red5服务器时出现NetConnection.Connect.Rejected错误

import mx.core.UIComponent; 
     import mx.events.FlexEvent; 

     private var connection:NetConnection; 
     private var inStream:NetStream; 
     private var outStream:NetStream; 


     private var camera:Camera; 
     private var microphone:Microphone; 


     private var inVideo:Video; 
     private var outVideo:Video; 


     private var inVideoWrapper:UIComponent; 
     private var outVideoWrapper:UIComponent; 



     protected function application1_creationCompleteHandler(event:FlexEvent):void 
     { 
      connection = new NetConnection(); 
      connection.connect("rtmp://localhost/myApp"); 
      connection.addEventListener(NetStatusEvent.NET_STATUS, onConnected); 

     } 

     private function onConnected(event:NetStatusEvent):void 
     { 
      if(event.info.code == "NetConnection.Connect.Success") 
      { 
       setupVideo(); 
      } 
     } 

     private function setupVideo():void 
     { 
      camera = Camera.getCamera(); 
      microphone = Microphone.getMicrophone(); 

      outStream = new NetStream(connection); 
      outStream.attachCamera(camera); 
      outStream.attachAudio(microphone); 
      outStream.publish("Radislav"); 

      outVideo = new Video(); 
      outVideo.attachCamera(camera); 

      inStream = new NetStream(connection); 
      inStream.play("Radislav"); 

      inVideo = new Video(); 
      inVideo.attachNetStream(inStream); 


      outVideoWrapper = new UIComponent; 
      outVideoWrapper.addChild(outVideo); 
      addElement(outVideoWrapper); 


      inVideoWrapper = new UIComponent; 
      inVideoWrapper.addChild(inVideo); 
      addElement(inVideoWrapper); 

      inVideoWrapper.move(400,0); 

     } 

回答

1

长话短说 - 您需要拨打connection.connect()的第二个参数。但是您想要读取服务器日志(red5/jvm)以获取更多详细信息。如果您没有看到日志,请在此解释如何让服务器编写它们:http://avchathq.com/blog/missing-red5-log-files-where-are-they/

+0

是的,我明白了。我昨天找到解决方案。它完全如你所说。谢谢! – Radislav 2012-03-24 11:22:53

相关问题