4/29/2010 4:06:12 AM
Title:
How to detect Camera Detachment
Hi,
If I have connected to webcam and if in between I remove its wire then how can we detect that webcam is removed.
please help me for this.
Thanks
Anuradha
Rayan
Points: 700
Posts:0
4/29/2010 6:45:06 AM
There is no property of method that tells us whether the camera is disconnected. However there is a workaround to this . You can keep checking the activity of camera and if there is no activity in the camera , it can be assumed that the camera is not working.
4/29/2010 6:54:55 AM
Hi Anuradha,
When flash picks up a device from flash settings, flash settings doesn't recognize whether Web Camera is attached or not, it simply picks up the device it gets eg: Creative Vista plus.
/**
* Video device change Handle.
*/
private function VideoDeviceChange(evt:Event):void{
cam = Camera.getCamera(videoDevices.selectedIndex.toString());
videoDisp.attachCamera(cam);
}
For Example:
1. If you are publishing a video stream through a Web Camera and in between you remove the camera then the video stream size goes on increasing, which indicates that the stream has not stopped, its running.
2. Use VHScrCap from google and get publish stream from this device, u ll get to know on the basis of this device, stream is going on, but not from WebCamera.
Regards:
ANKUSH
4/29/2010 9:51:58 PM
look at the code below , The below code will throw event if activity level of more than 5 was not detected for 5 seconds. Means the camera is either disconnected or there is no activity in the camera. You can adjust the settings of activity level 5 and time 5000 seconds according to your requirements
private var camera:Camera
private function videoDisplay_creationComplete():void {
camera = Camera.getCamera();
if (camera) {
videoDisplay.attachCamera(camera);
//if atleast 5 activity level not detected for 5 seconds then throw event to tell user that camera is not available
camera.setMotionLevel(5,5000);
camera.addEventListener(ActivityEvent.ACTIVITY, camera_activity);
} else {
Alert.show("You don't seem to have a camera.");
}
}
private function camera_activity(evt:ActivityEvent):void {
if(evt.type =="activity" && evt.activating==false ){
Alert.show("Camera may not be attached. No activity detected in camera.");
}
}
4/29/2010 11:48:19 PM
Hi,
Thanks a lot. The code is really very useful. It really solved the issue.
Sincerely,
Anuradha
9/21/2011 12:07:34 AM
Hi this thought is not working for me.
My Scenario is in an ongoing conference if i unplug Camera, i found Conference Window is Hanged displaying webcam images both participants.
in my case: Activity Event is not getting fired in the above scenario.
Activity Event is getting fired while establishing conference and also while ending the Conference window.
Please Help.
Thanks:)