How to mute mic in iOS so that yellow mic icon disappears

563

It should work if you stop the tracks instead.

myStream.getAudioTracks().forEach((track){
   track.stop();
});

This will make the icon go away but it will also stop the stream. This is of course not so good in case you want to unmute the stream again. Luckily calling getUserMedia() with the same parameters normally works without triggering another user prompt. That's still not ideal since unmuting will then not be instant anymore but it currently seems to be the only workaround to get rid of the icon.

Share:
563
PotatoBoy
Author by

PotatoBoy

Updated on December 28, 2022

Comments

  • PotatoBoy
    PotatoBoy over 1 year

    I'm working on an flutter app that uses a Janus WebRTC server to create voicechat rooms. The app has buttons to mute and unmute the microphone. But on iOS, even though i've already muted the mic by disabling the audiotracks, the native icon is still present.

    My way of muting the mic is something like this.

    myStream.getAudioTracks().forEach((track){
       track.enabled = false;
    });
    

    I've also tried:

    myStream.getAudioTracks().forEach((track){
       track.setMicrophoneMute(true);
    });
    

    And even though it works and the mic is muted. The native microphone yellow icon keeps showing up. Screenshot Here

    I'm using a modified version of the package janus_client from this source: https://github.com/shivanshtalwar0/flutter_janus_client

    • Julia
      Julia about 3 years
      You can't. It's a privacy feature in iOS 14.
    • PotatoBoy
      PotatoBoy about 3 years
      @Julia But when i tried to mute on other apps (i.e. Zoom) the icon does disappear.
  • Philipp Hancke
    Philipp Hancke about 3 years
    probably worth mentioning that one can use RTCRtpSender.replaceTrack to re-enable sending the microphone
  • PotatoBoy
    PotatoBoy about 3 years
    My problem with this solution is that the MediaStreamTrack i get doesn´t have this stop() method. I can however dispose completely of the track with a dispose() method that sends a 'trackDispose' method through the Flutter Method Channel. I've already tried this approach as well and the icon still remains showing up
  • PotatoBoy
    PotatoBoy about 3 years
    I even went ahead and set my Stream audioTracks list as an empty list, but the icon still appears as if the microphone is being used.
  • chrisguttandin
    chrisguttandin about 3 years
    Thanks Philipp Hancke for adding that comment. I missed that part.
  • chrisguttandin
    chrisguttandin about 3 years
    Sorry PotatoBoy, I wasn't aware that there is a wrapper for WebRTC in Flutter. I thought it's just exposing the native implementation of the browser.