Saturday, May 7, 2011

Webcam recording in Action script 3

I am using mr-webcams code for recording from a webcam. This is the source code of main functions.
//functions for recording
function doRecord() {
 if (Record_btn.getLabel() == "Record" && archiveName_tx.text != "") {
  archiveName_tx.type = "dynamic"
  // show live video feed.
  Live_video.attachVideo(client_cam);
  Live_video.attachAudio(client_mic);
  // Start publishing the camera output as a recorded stream
  record_ns.attachVideo(client_cam);
  record_ns.attachAudio(client_mic);
  record_ns.publish(archiveName_tx.text, "record");// record stream
  // Change the button label
  Record_btn.setLabel("Stop");
  nTimer = setInterval(stopRecording, 30000);//does it WORK???
 } else if (Record_btn.getLabel() == "Stop") {
  // Close output stream
  record_ns.close();
  //
  record_ns.attachVideo(null);
  record_ns.attachAudio(null) 
  //
  Live_video.attachVideo(null)
  Live_video.attachAudio(null) 
  //
  liveStreamInfo_so.data.broadcastStatus = null
  liveStreamInfo_so.data.currentBroadcast = ""
  // Change the button label
  Record_btn.setLabel("Record");
  editList(archiveName_tx.text, "newOne")
  archiveName_tx.text = ""
  archiveName_tx.type = "input"
 }
}
function playArchive(){
 if(Record_btn.getLabel() != "Record"){return;}
 Live_video.clear()
 Live_video.attachVideo(live_ns)
 live_ns.play(archiveView_tx.text)
}
// deletes archive flv and shared object reference
function deleteArchive(){
 editList(archiveView_tx.text, "removeOne")
 // calls the function on the ASC called delStream, send over the name of the flv
 client_nc.call("delStream", null, archiveView_tx.text)
 archiveView_tx.text = ""
}


function stopRecording():Void{ //may own code
   // Close output stream
  record_ns.close();
  //
  record_ns.attachVideo(null);
  record_ns.attachAudio(null) 
  //
  Live_video.attachVideo(null)
  Live_video.attachAudio(null) 
  //
  liveStreamInfo_so.data.broadcastStatus = null
  liveStreamInfo_so.data.currentBroadcast = ""
  // Change the button label
  Record_btn.setLabel("Record");
  editList(archiveName_tx.text, "newOne")
  archiveName_tx.text = ""
  archiveName_tx.type = "input"
  clearInterval(nTimer);
 
} 

2 comments:

  1. Hi,

    Thanks for the code.

    Do you have a working project that we can download and see how it's made ?

    Would be nice to have some link so we can see how it's done in the source.

    Thanks

    ReplyDelete
  2. This is a good post. This post gives truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. Thank you so much. Keep up the good works. schlüsseldienst in der nähe

    ReplyDelete