Flex detects camera and microphone methods

Source: Internet
Author: User

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.

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.