Copy link to clipboard
Copied
I have an app I created several years ago that accesses the user's microphone. It's worked perfectly until recently. Upon a long overdue updating of the app, I discovered I had to begin using Microphone.permissionStatus in order to access the mic, (since around the release of AIR 28, I believe).
Unfortunately, the recording feature now works intermittently at best. It seems to work fine at first, but a while later, the first second or two of audio is no longer recorded, if I get any audio recorded at all.
I first thought it might be an internet speed issue, but upon further testing, it doesn't seem to be the issue. It almost seems like it's more related to relocating to another location, (even just out to the parking lot.) Speedtest tests shows roughly the same speed of LTE signal, but once I leave the area, regardless of internet speed available, the recorder stops performing well. Upon returning to my desk, where it worked well before, it no longer does. Not until I delete the app from my phone and install a fresh version does it work properly again.
Does anyone know of issues with the (relatively) new Microphone.permissionStatus we need to implement in our recorder apps?
Is there a way to renew the permission? It only asks once, regardless of restarting the app or the device. (iPhone/iPad in this case.)
I'm using AIR 32.0.0.116.
In case it helps, relevant code follows:
import flash.media.Microphone;
import flash.system.Security;
import org.bytearray.micrecorder.*;
import org.bytearray.micrecorder.events.RecordingEvent;
import org.bytearray.micrecorder.encoder.WaveEncoder;
import org.as3wavsound.WavSound;
mic = Microphone.getMicrophone();
//NEW MIC PERMISSION CODE 2019
if (Microphone.permissionStatus != PermissionStatus.GRANTED) {
mic.addEventListener(PermissionEvent.PERMISSION_STATUS,
function (e: PermissionEvent): void {
if (e.status == PermissionStatus.GRANTED) {
trace("Permission granted!");
mic.setSilenceLevel(0);
mic.gain = 100;
mic.setLoopBack(false);
mic.setUseEchoSuppression(true);
Security.showSettings('2');
} else {
trace("Permission denied.");
}
});
try {
mic.requestPermission();
} catch (e: Error) {
// another request is in progress
}
} else {
trace("Is permission granted?");
}
Copy link to clipboard
Copied
I use pretty much the same code - but without flash.system.Security - I don't think Security.showSettings() is implemented in AIR but could be wrong....
...I guess you're adding a NSMicrophoneUsageDescription key to your application descriptor xml - I just prompt the user informing them they have blocked access to the mic if I get anything but a PermissionEvent.GRANTED on initialisation - assuming they have refused the initial system prompt on first use - which isn't particularly elegant.
Next time I update I'll probably use this though!
GitHub - distriqt/ANE-AudioRecorder: Audio Recorder Native Extension
Copy link to clipboard
Copied
Hi Simon, thanks for your input!
So, you're not including the import flash.system.Security into your actionscript?
I was under the impression it was now required, but maybe I'm wrong. (That would be great if leaving that out resolved this issue.)
I'll have to try it without it.
Do you still get the permission screen that pops up asking for permission to use the mic?
I appreciate your input, because this issue where the recording feature works great at times and is delayed at others is really stumping me.
Also, a million thanks for the link to the Adobe Air native extension recorder! That looks like a promising path to explore when I can carve out the time to start from scratch!
Copy link to clipboard
Copied
mrwizzer2 wrote
So, you're not including the import flash.system.Security into your actionscript?
I was under the impression it was now required, but maybe I'm wrong. (That would be great if leaving that out resolved this issue.)
I'll have to try it without it.
Do you still get the permission screen that pops up asking for permission to use the mic?
You'll still get the iOS system prompt on the first use. Unless something has changed recently flash.system.Security showSettings() and SecurityPanel() etc relate to the Flash Player panel only.
Copy link to clipboard
Copied
Simon, thanks for your link above, but I'm disappointed to find that the ANE-AudiorRecorder doesn't seem to work on iOS. : /
Copy link to clipboard
Copied
Simon, since it sounds like we're using pretty much the same code, are you still seeing good performance from your audio recorder? On mine, it works fine at times; at others, the first 1.5 seconds of audio don't get recorded.
Are you seeing any such issues?