闪存,AS3 : Is there a way to obtain the current security settings/restrictions for mic/camera programmatically?

标签 flash actionscript-3 security

在 Flash 应用程序中使用麦克风或摄像头时,用户必须在安全设置面板中授予对设备的访问权限。通过选中“记住”复选框,可以将允许访问或拒绝访问的决定设置为在应用程序下次运行时记住。

当用户设置为“记住”他的选择时,安全面板在尝试访问所述设备时不会弹出。但是我们如何知道访问权限是否被授予?

那么有没有办法检查用户是否允许或拒绝访问麦克风,以及检查这个决定是设置为一次性还是下次记住?

当用户先前拒绝访问并将其决定设置为记住时,这将特别有用。意识到这一事实后,我们会显示一条消息,告诉用户他必须单击才能打开安全面板并允许访问,例如,如果他想使用该应用程序。

最佳答案

Flash 可以轻松地让您检查当前的限制,并且非常详细地说明它可以让您拥有哪些信息。一切尽在 Camera Adobe 网站上的文档,但我在下面发布了一个示例,希望对您有所帮助。

package 
{
    import flash.display.Sprite;
    import flash.events.StatusEvent;
    import flash.media.Camera;
    import flash.system.Security;
    import flash.system.SecurityPanel;

    public class CameraExample extends Sprite
    {
        private var _cam:Camera;

        public function CameraExample()
        {
            if (Camera.isSupported)
            {
                this._cam = Camera.getCamera();

                if (!this._cam)
                {
                    // no camera is installed
                }
                else if (this._cam.muted)
                {
                    // user has disabled the camera access in security settings

                    Security.showSettings(SecurityPanel.PRIVACY); // show security settings window to allow them to change camera security settings

                    this._cam.addEventListener(StatusEvent.STATUS, this._statusHandler, false, 0, true); // listen out for their new decision
                }
                else
                {
                    // you have access, do what you like with the cam object
                }
            }
            else
            {
                // camera is not supported on this device (iOS/Android etc)
            }
        }

        private function _statusHandler(e:StatusEvent):void
        {
            if (e.code == "Camera.Unmuted")
            {
                this._cam.removeEventListener(StatusEvent.STATUS, this._statusHandler);

                // they have allowed access to the camera, do what you like the cam object
            }
        }
    }
}

关于闪存,AS3 : Is there a way to obtain the current security settings/restrictions for mic/camera programmatically?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6947927/

相关文章:

flash - 从不规则数量的 x,y 点制作平滑路径以模拟手写

javascript - 页面刷新后 ExternalInterface 在 IE 中不起作用

c# - WCF - 在 CMS 中使用 Web 控制的客户端安全

c++ - 是否可以模拟进程的访问 token ?

android - Eclipse 找不到 android.webkit.WebSettings.PluginState;

silverlight - 如何在零间隙的浏览器中循环播放 mp3?

ios - ActionScript3.0 - 如何获取坐标处像素的颜色 (uint)? (Stage3D, Flare3D)

javascript - 如何访问 AS3 或 JavaScript 中类的静态成员的名称

security - 这是什么类型的SQL注入(inject)?

actionscript-3 - 如何防止某些外语字体的文本位移?