[Flash Development Notes] Flash checks whether cameras are occupied

Source: Internet
Author: User
In the process of FMS programming, we often perform camera detection before using a camera to detect whether a camera or camera is available.
Generally, we use this method to check whether the camera is busy: VaR Temp_cam =  Camera. Get();
If (Temp_cam =   - 1 ){
Trace('Video Device Busy ');
}

But I do not know why, such a detection method is always unable to pass during my testing, I intend to make anotherProgramUse the camera and then run this sectionCode. The results show that the camera is still available, not as I imagined "the video device is busy ".
Later, I found another detection method, which is effective. The method is to attachvideo A user_cam (CAMERA object) to a video_vid (video object, then judge whether user_cam.currentfps is greater than 0. If the camera is occupied, user_cam.currentfps is definitely not greater than 0, but equal to 0. The Code is as follows:

Function Checkcambusy (user_cam:Camera):Void{
VaR Chktime:Number  =   0 ;
VaR Intervalid:Number;
Function Callback (){
Trace(User_cam.Currentfps);
If (User_cam.Currentfps > 0 ){
// Available video devices
Clearinterval(Intervalid );
} Else {
Chktime ++ ;
If (Chktime > 30 ){
// Video Device Busy
_ Root. Video_vid.Clear ();
Clearinterval(Intervalid );
}
}
}
Intervalid =  Setinterval(Callback, 50 );
}< P>

var user_cam = camera. get ();
_ root. video_vid. attachvideo (user_cam);
checkcambusy (user_cam );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.