Skip to main content
fengd9946600
Inspiring
March 6, 2017
Answered

App crash when attach microphone to a net stream

  • March 6, 2017
  • 2 replies
  • 825 views

Hi there,

An emergency issue not sure could someone help.

My app ran well before, but now it always crash at the point when I attache the microphone to a netstream, The app running on IOS 10.2.1 (I'm not sure if this related to  any iOS version update) and the app's development SDK is Flex4.15 Air25. The code is as bellow:

  private function getMicrophone(codec:String):Microphone {

       var mic:Microphone = null;

       mic = Microphone.getEnhancedMicrophone();

       if (mic) {

            var options:MicrophoneEnhancedOptions = new MicrophoneEnhancedOptions();

            options.mode = MicrophoneEnhancedMode.FULL_DUPLEX;

            options.autoGain = false;

            options.echoPath = 128;

            options.nonLinearProcessing = true;

            mic['enhancedOptions'] = options;

            mic.setUseEchoSuppression(true);

       } else {

            mic = Microphone.getMicrophone();

       }

       if (mic == null) {

            trace("No microphone! <o>");

       } else {

            mic.addEventListener(StatusEvent.STATUS, onMicStatusEvent);

            mic.setLoopBack(false);

            mic.setSilenceLevel(0, 20000);

            mic.gain = 60;

            if (codec == "SPEEX") {

                 mic.encodeQuality = 6;

                 mic.codec = SoundCodec.SPEEX;

                 mic.framesPerPacket = 1;

                 mic.rate = 16;

                 trace("Using SPEEX wideband codec");

            } else {

                 mic.codec = SoundCodec.NELLYMOSER;

                 mic.rate = 8;

                 trace("Using Nellymoser codec");

            }

        }

       return mic;

  }

  private function setupMicrophone(codec:String, pushToTalk:Boolean):void {

       if (noMicrophone()) {

            _mic = null;

            return;

       }

       _mic = getMicrophone(codec);

       _mic.gain = pushToTalk ? 0 : _defaultMicGain;

  }

  public function publish(connection:NetConnection, streamName:String, codec:String, pushToTalk:Boolean):void {

       _outgoingStream = new NetStream(connection);

       _outgoingStream.client = this;

       _outgoingStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatusEvent);

       _outgoingStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncErrorEvent);

       setupMicrophone(codec, pushToTalk);

       if (_mic) {

          _outgoingStream.attachAudio(_mic); <--- It Crash at this line

            _outgoingStream.publish(streamName, "live");

       }

  }

I tried to delete and reinstall the app and it even didn't prompt for mic access permission when call Microphone.getEnhancedMicrophone method. I've tried Microphone.getMicrophone(), but the problem is still there. The app just simply crash without any error message. Thanks in advance If someone knows the trick or can provide some bug tracing methodologies !

This topic has been closed for replies.
Correct answer krgupta

Hi,

To access microphone, you would need to use the permissions feature which was introduced with AIR 24.

To read more, Please refer to AIR 24 release notes and go through the section "Permissions on Android and iOS":

Release Notes Flash Player 24 AIR 24 

Note that on iOS you also need to add cocoa keys in your application descriptor.

Thanks,

Krati | Adobe AIR Engineering

2 replies

fengd9946600
Inspiring
March 7, 2017

Hi Krati,

Thanks!! The answer is what I need!

Regards,

David

krguptaCommunity ManagerCorrect answer
Community Manager
March 7, 2017

Hi,

To access microphone, you would need to use the permissions feature which was introduced with AIR 24.

To read more, Please refer to AIR 24 release notes and go through the section "Permissions on Android and iOS":

Release Notes Flash Player 24 AIR 24 

Note that on iOS you also need to add cocoa keys in your application descriptor.

Thanks,

Krati | Adobe AIR Engineering