第一百二十二章(2 / 2)

camcheckcount = 5;

FindCamera(camList.seletctedIndex);

camtimer.Start();

}

catch(e:Error)

{

if(e.Message == "No Drivers Found")

{

camStatus = "Failed to find driver. ";

}

else

{

camStatus = "Unknown Error";

}

}

}

對於Microphone,也是類似的邏輯,代碼如下:

var micStatus:String;

var mic:Microphone;

var curMicActivity = 0;

//Previous activityLevel.

var prevMicActivity = curMicActivity;

//How many times fps test failed.

var micfpsfailedcount = 0;

//How many times activity test failed.

var micactivityfailedcount = 0;

//Define how many times we are going to check.

var miccheckcount:int = 5;

private function FindMicrophone(micIndex:int):void

{

mic:Microphone = Microphone.getMicrophone(micIndex);

//If no drivers were found.

if(cam ==null)

{

throw new Error("No Drivers Found");

}

mic.addEventListener(StatusEvent.STATUS, onmicStatus);

cam.addEventListener(ActivityEvent.ACTIVITY, onCamActivity);

Security.showSettings(SecurityPanel.**PRIVACY**);

}

function onmicStatus(e:StatusEvent)

{

switch (e.code)

{

case "Microphone.Muted":

trace("User clicked Deny.");

break;

case "Microphone.Unmuted":

trace("User clicked Accept.");

break;

}

}

function onCamActivity(e:ActivityEvent)

{

curMicActivity = cam.activityLevel;

}