video record
Hi,
Am trying to record video from my webcam.
here is my code
var nc:NetConnection;
var ns:NetStream;
var nsPlayer:NetStream;
var vid:Video;
var vidPlayer:Video;
var cam:Camera;
var mic:Microphone;
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS,onNetStatus);
nc.connect("rtmp://localhost/publishlive");
function onNetStatus(event:NetStatusEvent):void{
trace(event.info.code);
if(event.info.code == "NetConnection.Connect.Success"){
}
}
function publishCamera(e:Event) {
cam = Camera.getCamera();
mic = Microphone.getMicrophone();
ns = new NetStream(nc);
ns.attachCamera(cam);
ns.attachAudio(mic);
ns.publish("myCamera", "live");
displayPublishingVideo();
}
function displayPublishingVideo() {
vid = new Video();
vid.x = 10;
vid.y = 10;
vid.attachCamera(cam);
addChild(vid);
}
function displayPlaybackVideo(e:Event){
nsPlayer = new NetStream(nc);
nsPlayer.play("myCamera");
vidPlayer = new Video();
vidPlayer.x = cam.width + 20;
vidPlayer.y = 10;
vidPlayer.attachNetStream(nsPlayer);
addChild(vidPlayer);
}
record_btn.addEventListener(MouseEvent.CLICK , publishCamera)
play_btn.addEventListener(MouseEvent.CLICK , displayPlaybackVideo)
When i click record_btn, flash asks me permission to access my webcam.
If i alow in the screen i am able to see live video.
But I want to store the video and replay it.
Please help to complete this.
Thanks,
Shanthi
