質問

I am trying to capture my web cam and then try to save it to the red5 server ,and then i want to retrieve it back(thats the next part).I am able to play the web cam on my web page using the Flash but i am not able to record the video to the red5 server.Every time i am getting the exception

ArgumentError: Error #2126: NetConnection object must be connected.
    at flash.net::NetStream/flash.net:NetStream::construct()
    at flash.net::NetStream$iinit()
    at WebCam_fla::MainTimeline/click1()
onBWDone

My AS3 is as follows:

BtnStart.addEventListener(MouseEvent.CLICK, click1);
BtnStop.addEventListener(MouseEvent.CLICK, click2);
var camera;
var video;
var bandwidth:int = 100;
var quality:int = 100;
var nc:NetConnection;
var ns:NetStream;
function click1(event:MouseEvent):void 
{

camera=Camera.getCamera();
camera.setMode(320,240,10000);
video = new Video(camera.width, camera.height);
video.attachCamera(camera);
video.smoothing;
txtCameraName.text=camera.name;
nc = new NetConnection();
nc.client = { onBWDone: function():void{ trace("onBWDone") } };
addChild(video);


nc.connect("rtmp://localhost/oflaDemo");
ns = new NetStream(nc); 
ns.attachCamera(camera);
ns.publish( "file1", "record" );

}   

function click2(event:MouseEvent):void
{

    if(video)
    {
    video.visible=false;
    }
}

Can anyone please tell me that what mistake i am committing here.Please guys help me.Do i have to do any other stuff to make this happen.Do i have to changed the link which i am giving in the line nc.connect("rtmp://localhost/oflaDemo");.This is the line which is giving me the error.Please help.Any help will be appreciated.

役に立ちましたか?

解決

I was doing the mistake of creating the stream before the connection was established.So made a slight change in the code to check if the connection is made then only creating the stream with the connection.That solved my problem.Cheers :)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top