Flash,AS3:有没有办法以编程方式获取麦克风/摄像机的当前安全设置/限制?

Joh*_*kya 4 security flash actionscript-3

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

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

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

当用户先前拒绝访问并将其决定记住时,这将特别有用.了解这一事实后,我们可以显示一条消息,告诉用户必须单击以打开安全面板,并在他想要使用该应用程序时允许访问.

xLi*_*ite 7

Flash可以轻松地检查当前的限制,并且非常详细地说明了它可以提供哪些信息.这些都可以在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
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)