I am new in flex.I have created dynamic web project. Run it. It accessible on http://localhost:5080/myApp. Now I want to create connection to that application but I got NetConnection.Connect.Rejected. This is my code:
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);
}
Long story short – you need the second parameter in
connection.connect()call. But you want to read the server logs (red5/jvm) for more details. If you don’t see logs, here it explains how to make the server write them: http://avchathq.com/blog/missing-red5-log-files-where-are-they/