If you want to detect whether the user allowed or denied access to the camera, you can listen for the camera's status
event (StatusEvent.STATUS
), as seen in the following code:
var cam:Camera = Camera.getCamera();
if (cam != null){
cam.addEventListener(StatusEvent.STATUS, statusHandler);
var vid:Video = new Video();
vid.attachCamera(cam);
addChild(vid);
}
function statusHandler(event:StatusEvent):void{
switch (event.code){
case "Camera.Muted":
trace("User clicked Deny.");
break;
case "Camera.Unmuted":
trace("User clicked Accept.");
break;
}
}
The event parameter of the statusHandler()
function contains a code property which contains the string "Camera.Muted"
or "Camera.Unmuted"
. If the value is "Camera.Muted" the user clicked the Deny button and Flash Player is unable to access the camera.
No comments:
Post a Comment