有没有全球方法来检查是否已在Flash中授予麦克风访问权限?

Ste*_*ven 6 apache-flex flash actionscript-3 flash-builder

我目前正在建立一个需要麦克风互动的网站.我已经构建了处理声音及其外部接口的Flash组件.

正如您可能猜到的,外部接口的目的是允许UI完全由HTML/CSS/Javascript处理.除了几件事之外,它的效果很好.首先,如果Flash影片不可见,它将停止响应.我已经通过在视口中未使用的部分中将其作为1像素乘1像素来解决这个问题.

另一个问题是Flash有时会出现一个安全对话框,要求用户进行访问.现在,我已经想出如何强制导致安全对话框出现:

Security.showSettings(SecurityPanel.PRIVACY);
Run Code Online (Sandbox Code Playgroud)

很好(旁边的问题:当设置被触发时,我怎么能让这个回火?).

但这有两个缺点:

1. It doesn't theoretically catch the case where the user revokes privileges during the running of the application.
2. It doesn't detect if the user has already granted permission.
Run Code Online (Sandbox Code Playgroud)

我想办法解决这两个问题的方法是获得一个全局标志(或者更有帮助的是,一个可绑定的属性或事件)来获取当前的安全状态以及何时更改它.

任何见解将不胜感激.

更新

我已经戳了一下,并写了这个:

import flash.system.Security;
import flash.system.SecurityPanel;
import flash.external.ExternalInterface;
import flash.media.Microphone;
import flash.events.StatusEvent;

var m:Microphone = Microphone.getMicrophone();

m.addEventListener(StatusEvent.STATUS, function(e:StatusEvent){
    if(e.code == "Microphone.Unmuted") {
        ExternalInterface.call('window.SpeechWrapper.messenger.microphonePermissionGranted');
    } else {
        ExternalInterface.call('window.SpeechWrapper.messenger.microphonePermissionDenied');
    }
});

if(m.muted) {
    Security.showSettings(SecurityPanel.PRIVACY);
} else {
    ExternalInterface.call('window.SpeechWrapper.messenger.microphonePermissionGranted');
}
Run Code Online (Sandbox Code Playgroud)

但问题是,由于似乎没有办法弄清楚用户是否要求在安全域中记住选择,我无法提供一个独立的轻量级swf,旨在请求权限.

cso*_*akk 1

该属性称为静音。史蒂文·徐在评论中回答。