我目前正在构建一个需要麦克风交互的网站。我已经构建了处理声音及其外部接口(interface)的 Flash 组件。
正如您可能猜到的那样,外部接口(interface)的目的是允许 UI 完全由 HTML/CSS/Javascript 处理。它工作得很好,除了几件事。第一个是如果 Flash 电影不可见,它就会停止响应。我已经通过在视口(viewport)的其他未使用部分中将其设置为 1 像素 x 1 像素来解决此问题。
另一个问题是 Flash 有时会显示一个安全对话框,要求用户访问。现在,我想出了如何强制导致 security dialog出现:
Security.showSettings(SecurityPanel.PRIVACY);
很好(附带问题:当设置被触发时,我怎样才能让这个触发回调?)。
但这有两个缺点:
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.
我想解决这两种情况的方法是使用一个全局标志(或者更有用的是,一个可绑定(bind)的属性或事件)来获取当前的安全状态以及何时更改。
任何见解将不胜感激。
更新
我又摸索了一下,写了这个:
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');
}
然而,问题在于,由于似乎没有办法确定用户是否要求在整个安全域中记住选择,因此我无法提供一个独立的轻量级 swf,旨在请求许可.
最佳答案
该属性称为静音。 Steven Xu 在评论中回答。
关于flash - 是否有一种全局方法来检查是否已在 Flash 中授予麦克风访问权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7235417/