compsci
09-12-2007, 09:11 PM
Hello all,
I am using mr-webcams code for recording from a webcam. I would like to add more features such as getting the recordings to be only for 30 seconds, i have tried to do this as you can see from the code below, but it doesn't record for exactly 30 seconds. I've tested it but it only records for 20 seconds, sometimes 24?!!! Can someone have a look and tell me whats wrong.
I think the mistake is in the function stopRecording():
//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);
}
Thanks all.
I am using mr-webcams code for recording from a webcam. I would like to add more features such as getting the recordings to be only for 30 seconds, i have tried to do this as you can see from the code below, but it doesn't record for exactly 30 seconds. I've tested it but it only records for 20 seconds, sometimes 24?!!! Can someone have a look and tell me whats wrong.
I think the mistake is in the function stopRecording():
//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);
}
Thanks all.