Today again the project detection camera this piece rewrite, remember something in flex inside, jump out of the security window for
The code is as follows |
Copy Code |
Security.showsettings (securitypanel.privacy);
|
This code is non-blocking, so we need to monitor the camera and microphone.
The code is as follows |
Copy Code |
Mic = Microphone.getenhancedmicrophone (); Mic.addeventlistener (Statusevent.status,eventargextend.create (AUDIO_STATUSHANDLER,PAR1,PAR2)); |
We can use the mic.muted mic. Unmuted Judge Authorization status
The code is as follows |
Copy Code |
Camera = Camera.getcamera () Camera.addeventlistener (Statusevent.status, Eventargextend.create (CAMERA_STATUSHANDLER,PAR1,PAR2)); |
Camera.muted instructs the user to deny access to the camera; camera.unmuted instructs the user to allow access to the camera
The eventargextend.create in the code is a class that is used to pass a reference to a listening event, and the code can baidu,google itself
Use the following examples, as well as some of the ways you can view the as file yourself. Among them, the function of detecting microphone is not perfect.
The code is as follows |
Copy Code |
Import cn.mediasky.media.*; Create a Selecter instance that must be created using the Main method. Four parameters are, Selecter superior movie clip, depth,x position, y position var my_selecter = selecter.main (_root, 0, 50,20); Registering as a listener My_selecter.addlistener (_root); Detecting camera status My_selecter.checkcam (); Handling Camera Status function Oncamstatus (iinfo:info): void{ if (Iinfo.code = = "Unmuted") { _root.my_video.attachvideo (Iinfo.cam); }else{ _root.my_video.clear (); } } |
Where the code return value in Statusevent G Official document is:
The
is scheduled when the microphone reports its status. If the value of the Code property is "Microphone.muted", the user denies the SWF file access microphone. If the value of the Code property is "Microphone.unmuted", the user is allowed to access the microphone by the SWF file. The
is assigned when the camera reports its status. If the value of the Code property is "Camera.muted", the user has denied the SWF file access to its camera. If the value of the Code property is "Camera.unmuted", the user is allowed to access its camera by the SWF file.