Flash,AS3:有没有办法以编程方式获取麦克风/摄像机的当前安全设
发布时间:2020-12-15 07:24:30 所属栏目:百科 来源:网络整理
导读:在Flash应用程序中使用麦克风或摄像头时,用户必须在安全设置面板中授予对设备的访问权限.通过选中“记
在Flash应用程序中使用麦克风或摄像头时,用户必须在安全设置面板中授予对设备的访问权限.通过选中“记住”复选框,可以设置在下次运行应用程序时记住允许访问或拒绝它的决定.
当用户设置为“记住”他的选择时,安全面板在尝试访问所述设备时不会弹出.但我们如何知道是否授予访问权限? 那么有没有办法检查用户是允许还是拒绝访问麦克风,以及检查此决定是设置为一次还是下一次记住? 当用户先前拒绝访问并将其决定记住时,这将特别有用.知道这一事实后,我们就会显示一条消息,告诉用户他必须点击打开安全面板,并允许访问,如果他想要使用该应用程序,例如. 解决方法
Flash可以轻松地检查当前的限制,并且非常详细地说明了它可以提供哪些信息.这些都可以在Adobe网站上的
Camera文档中找到,但我在下面发布了一个示例,希望它有所帮助.
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,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 } } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |