开发者

Is there a global way to check whether microphone access has been granted in Flash?

开发者 https://www.devze.com 2023-03-31 08:46 出处:网络
I\'m currently building an website that requires microphone interaction. I have already built the Flash component that handles the sound and its external interfaces.

I'm currently building an website that requires microphone interaction. I have already built the Flash component that handles the sound and its external interfaces.

The purpose of the external interfaces, as you might guess, is to allow for the UI to be entirely handled by HTML/CSS/Javascript. It works great, except for a couple of things. The first is that the Flash movie stops being responsive if it's not visible. I have kludged together a solution to this by just having it be 1 pixel by 1 pixel in an otherwise unused part of the viewport.

The other issue is that Flash sometimes presents a security dialog asking the user for access. Now, I've figured out how to forcefully cause the security dialog to appear:

Security.showSettings(SecurityPanel.PRIVACY);

Fine (side question: how can I have this fire a callback when the setting is tripped?).

But this has two downsides:

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.

I figure a way around both of these is to have a single global flag (or more helpfully, a bindable attribute or event) to get what the security status currently is and when it's been changed.

Any insights would be greatly appreciated.

Update

I've poked around a bit more and wrote up this:

import flash.system.Security;
import flash.system.SecurityPanel;
import flash.external.ExternalInterface;
import flash.media.Microphone;
import flash.events.St开发者_StackOverflow社区atusEvent;

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');
}

However, the trouble is that since there doesn't appear to be a way to figure out whether the user has asked for the choice to be remembered across the security domain, I am not able to present a standalone lightweight swf designed to ask for permission.


the property is called muted. answered by Steven Xu in comments.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号