Issue with Microphone.permissionStatus
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?");
}
