Reputation: 13819
Basically what I'm trying to do is check the microphone access is granted or not, if not, show the Security dialog box and let the user to choose "Allow" access in the dialog, so that next time the user clicks the recording button, it won't show up the Security box, and recording should work immediately.
In some buttonClick
event handler, I put this code to check if the Microphone access has been unmuted or not
var mic:Microphone = Microphone.getMicrophone();
if (mic == null) {
return;
}
if (mic.muted) {
Security.showSettings(SecurityPanel.PRIVACY);
return;
}
//... Start recording using a library
If the microphone access is denied (or muted) at the beginning, the Security box will show up when buttonClick
event handler is executed, which is expected;
After the user select "Allow", which will make mic.muted = false
, so when the user clicks the button again, the box will not show up, which is also expected;
However, sometimes, the recording feature in the library won't work any more. sometimes it will still work, but if you right click the Flash app, and select "Setting" to pop up the Security box, and click "Deny", and then repeat Step 1 & 2, you will always see the behavior in Step 3: the recording feature not working.
I checked the source code of the library for recording, it also uses var mic:Microphone = Microphone.getMicrophone();
to get and setup the microphone.
Please help.
Upvotes: 0
Views: 388
Reputation: 13819
This does NOT make any sense: if I move the var mic:Microphone = Microphone.getMicrophone();
out of the handler, it works:
var mic:Microphone = Microphone.getMicrophone();
private function buttonClickHandler():void
{
if (mic == null) {
return;
}
if (mic.muted) {
Security.showSettings(SecurityPanel.PRIVACY);
return;
}
//... Start recording using a library
}
This does NOT make sense, because http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Microphone.html
Multiple calls to Microphone.getMicrophone() reference the same microphone. Thus, if your code contains the lines mic1 = Microphone.getMicrophone() and mic2 = Microphone.getMicrophone() , both mic1 and mic2 reference the same (default) microphone.
Upvotes: 1