I am new to Flash programming. All I wanted to do is stream my local webcam to my red5 server and receive the data in another video.
Therefore I wrote the following code:
NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
client_nc = new NetConnection();
client_nc.objectEncoding = flash.net.ObjectEncoding.AMF0;
client_nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
client_nc.connect("rtmp://localhost/myApp/");
function netStatusHandler(e:NetStatusEvent):void
{
var code:String = e.info.code;
//log.info("code = " + code);
if (code == "NetConnection.Connect.Success")
{
cam_ns = new NetStream(client_nc);
cam_ns.attachCamera(camera);
cam_ns.attachAudio(mic);
cam_ns.publish("user_2", "live");
in_ns2 = new NetStream(client_nc);
in_ns2.play("user_2");
video2 = new Video(640, 480);
video2.attachNetStream(in_ns2);
//in_ns2.play("rtmp://localhost/myApp/user_2");
//in_ns2.play("user_2");
video2.x = 200;
video2.y = 10;
video2.width = 100;
video2.height = 100;
addChild(video2);
}
else
{
trace(code);
}
}
I use 2 NetStreams on 1 NetConnections and then attach a cam+mic on the first. After that I play this NetStream and try to attach this playback on the 2nd Netstream and play it in a new Video. However, this doesnt work.
I use flashdevelop for as3 and eclipse for the red5 server. Can anyone help me?