Dear all
I am trying to create a simple online recording via FMS2
Here is my coding:
NetConnection.defaultObjectEncoding = ObjectEncoding.AMF0;
var nc:NetConnection = new NetConnection();
var ns:NetStream;
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect("rtmp://localhost/test");
btnRec.addEventListener(MouseEvent.CLICK, clickRecord);
btnStop.addEventListener(MouseEvent.CLICK, clickStop);
btnStop.enabled = false;
function netStatusHandler(e:NetStatusEvent):void {
if (e.info.code == "NetConnection.Connect.Success") {
trace("Connect success");
getCamera();
ns = new NetStream(nc);
}
}
function getCamera():void {
var cam:Camera = Camera.getCamera();
if (cam != null) {
var video:Video = new Video(320,240);
video.attachCamera(cam);
addChild(video);
}
}
function clickRecord(e:MouseEvent):void {
btnRec.enabled = false;
btnStop.enabled = true;
ns.publish("videoName","record");
}
function clickStop(e:MouseEvent):void {
btnRec.enabled = true;
btnStop.enabled = false;
ns.publish("false");
nc.close();
}
WHen I try to record a video via my cam (click the button “btnRec”), … no error message comes up,
but there is no FLV file (it should be “videoName.flv”) has been generated in rtmp://localhost/test ???
Do I miss anything or do something wrong in the script ???
Please help ~~
THanks ~~