开发者

Detecting user's camera settings

开发者 https://www.devze.com 2023-02-14 03:58 出处:网络
I am having a problem with correctly detecting a user\'s camera settings. If the user has selected \"allow\" and \"remember\", then the camera.muted setting is false (not muted)

I am having a problem with correctly detecting a user's camera settings.

If the user has selected "allow" and "remember", then the camera.muted setting is false (not muted)

However, if the user has selected "deny" and "remember", then the camera.muted setting is true. (camera has been muted by the user)

BUT, if the user hasn't selected anything and the "remember" checkbox is unchecked, the camera.muted setting is ALSO TRUE (the camera is again muted, but it's only because someone hasn't "allowed" the camera yet)

Is there a way to differentiate between whe开发者_StackOverflow中文版n a user has chosen to deny a camera forever for a particular site (by checking the "remember" check box) OR when they just haven't allowed the camera in the first place?


As far as I can tell, there is no way to detect if the "remember" checkbox has been checked before. The workaround is to detect if the camera is muted or not when requested. Such as:

camera = Camera.getCamera();
if (camera.muted) {
    // "remember" checkbox was not checked, or user needs to allow access
}
else {
    // "remember" checkbox was checked, access is already granted
}


Having done battle with webcams in flash, I would suggest that everyone use this library.

https://github.com/cataclysmicrewind/CameraDetection/

Flash + webcam should = easy + awesome. Unfortunately, it is pain + suffering.


You might be able to use this workaround which can detect whether the security dialog is open.

https://gist.github.com/1266104 referenced in https://bugbase.adobe.com/index.cfm?event=bug&id=2993848

Then you could do something like:

var camera:Camera = Camera.getCamera();
if (camera.muted) {
    if (securityPanelIsClosed()) {
        // "remember" was checked and deny radio button is selected
    } else {
        // "remember" was not checked
    }
} else {
    // "remember" checkbox was checked, access is already granted
}


For all those that use the CameraDetection class be cautious... This only works because of a workaround that tries to draw the stage while the security panel is open. You will run into problems if you try to draw the stage while it has certain elements on it that present a security sandbox problem(loaded images from other locations, or even videos thats that are currently streaming). Basically the workaround will automatically continue to fail and give false results.

In my case I was stuck trying to use the CameraDetection while I had a video on the stage that was being streamed. The try/catch happens regardless of the security panel being open.

0

精彩评论

暂无评论...
验证码 换一张
取 消