6

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

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.

Steven
  • 17,796
  • 13
  • 66
  • 118
  • 1
    Can you check http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Microphone.html#isSupported ? I'm not sure if, in this case, "supported" is the same as "allowed" though. – JeffryHouser Aug 29 '11 at 20:40
  • 1
    Thank you for the reference. It appears that `muted` is the property I'm looking for. – Steven Aug 29 '11 at 20:45
  • You can detect if it is across the entire domain by adding a second flash file and having them communicate by JavaScript. But anybody with flashblock or similar will need to enable both, and you shouldn't *require* your users to do that anyway. – Dave Apr 01 '13 at 18:07
  • FYI, if you'd like to show a simple Yes/No prompt for mic-access you could replace this line... Security.showSettings(SecurityPanel.PRIVACY); ...with this line... Microphone.setLoopBack( true ); – bvaughn Apr 12 '13 at 19:56

1 Answers1

1

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

csomakk
  • 5,369
  • 1
  • 29
  • 34