Skip to content

How can I mute the microphone but not the incoming audio? #221

Open
@zPy52

Description

@zPy52

Describe the bug

I'm trying to have a timed conversation in which you can always listen but not always talk. The problem is that when I do the following:

if (localStream != null) {
  for (MediaStreamTrack track in localStream!.getAudioTracks()) {
    track.enabled = false; 
  }
}

Both the speaker and the microphone shut down and I can't hear anything. I've tried with #110 but it says that the method setMicrophoneMute does not exist.

Intended behaviour

I can listen to the incoming audio but not speak; aka, send audio streams to the other endpoint.

Platform

I'm trying this on my physical iOS 18.1.1 device, an iPhone 14. This is the info provided by flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.0, on macOS 15.3.1 24D70 darwin-x64, locale
    es-ES)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] IntelliJ IDEA Community Edition (version 2023.3.3)
[✓] VS Code (version 1.97.2)
[✓] Connected device (2 available)
    ! Error: Browsing on the local area network for iPhone de Antonio. Ensure
      the device is unlocked and attached with a cable or associated with the
      same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code
      -27)
[✓] Network resources

• No issues found!
antoniopenapena@MacBook-Pro-de-Antonio ~ % flutter doctor -v
[✓] Flutter (Channel stable, 3.29.0, on macOS 15.3.1 24D70 darwin-x64, locale
    es-ES) [1.268ms]
    • Flutter version 3.29.0 on channel stable at
      /Users/anton/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 35c388afb5 (2 weeks ago), 2025-02-10 12:48:41 -0800
    • Engine revision f73bfc4522
    • Dart version 3.7.0
    • DevTools version 2.42.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    [4,3s]
    • Android SDK at /Users/anton/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on
      this machine.
      To manually set the JDK path, use: `flutter config
      --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build
      17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [2,5s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [254ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2) [252ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.9+0-17.0.9b1087.7-11185874)

[✓] IntelliJ IDEA Community Edition (version 2023.3.3) [250ms]
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 78.4.2
    • Dart plugin version 233.15123

[✓] VS Code (version 1.97.2) [51ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.104.0

[✓] Connected device (2 available) [7,5s]
    • macOS (desktop) • macos  • darwin-x64     • macOS 15.3.1 24D70 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 133.0.6943.127

[✓] Network resources [574ms]
    • All expected network resources are available.

• No issues found!

Plugin version

flutter_webrtc: ^0.12.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions