var mic:Microphone;
mic = Microphone.getEnhancedMicrophone();
if(mic.muted){
mic.setLoopBack(true);//这里是触发系统的权限框,比Security.showSettings(SecurityPanel.PRIVACY)友好
mic.addEventListener(StatusEvent.STATUS,audio_statusHandler);
}
private function audio_statusHandler(evt:StatusEvent,type:int,uid:int):void {
printLog("audiostatus:"+evt.code);
if(mic.muted == false){//这里是关键,我们不依赖于系统给我们返回的怪异状态了,还好mic.muted是正常的,就用它了
//正常逻辑代码
mic.removeEventListener(StatusEvent.STATUS,audio_statusHandler);
return;
}
switch (evt.code) {
case "Microphone.Unmuted": //允许
正常逻辑代码
mic.removeEventListener(StatusEvent.STATUS,audio_statusHandler);
break;
case "Microphone.Muted": //拒绝
break;
}
}
|