Skip to content

[camerax] enableAudio has no effect on video recording, can not mute video recording if microphone permission granted #168551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mzdm opened this issue May 8, 2025 · 4 comments · Fixed by flutter/packages#9264
Assignees
Labels
found in release: 3.29 Found to occur in 3.29 found in release: 3.32 Found to occur in 3.32 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: camera The camera plugin P1 High-priority issues at the top of the work list platform-android Android applications specifically team-android Owned by Android platform team triaged-android Triaged by Android platform team

Comments

@mzdm
Copy link
Contributor

mzdm commented May 8, 2025

Steps to reproduce

  1. Clone camerax example app https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
  2. Enable camera and microphone permission via app settings
  3. Also observe that enableAudio in example has no effect, as its value does not get passed to CameraController's MediaSettings. Default is false.

So it always records audio when mic enabled, even though it is set to false. I tested on Android.

Expected results

Should not record audio if enableAudio is set to false

Actual results

Records microphone audio

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.4, on macOS 15.3.1 24D70 darwin-arm64, locale en-CZ)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.2.3)
[✓] VS Code (version 1.93.1)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!
@mzdm mzdm changed the title [camerax] enableAudio has no effect, can not mute video recording if microphone permission granted [camerax] enableAudio has no effect on video recording, can not mute video recording if microphone permission granted May 8, 2025
@bparrishMines
Copy link
Contributor

bparrishMines commented May 8, 2025

@darshankawar darshankawar added the in triage Presently being triaged by the triage team label May 9, 2025
@darshankawar
Copy link
Member

Thanks for the report. I was able to replicate the reported behavior with latest sdk versions.


stable : 3.29.3
master : 3.32.0-1.0.pre.463

@darshankawar darshankawar added platform-android Android applications specifically p: camera The camera plugin has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.29 Found to occur in 3.29 found in release: 3.32 Found to occur in 3.32 team-android Owned by Android platform team and removed in triage Presently being triaged by the triage team labels May 9, 2025
@camsim99
Copy link
Contributor

The original implementation doesn't seem to include PendingRecording.withAudioEnabled: https://github.com/flutter/packages/blob/4a36dc63f7197f5cf4f0d0b9b670492b8848c502/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/PendingRecordingHostApiImpl.java#L20.

Does this need to be added in or was audio disabled another way?

Or does this setting only affect the permission request: https://github.com/flutter/packages/blob/main/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart#L352

Oh interesting. Yeah I think we need to use withAudioEnabled to support the enableAudio setting!

@gmackall gmackall added P1 High-priority issues at the top of the work list triaged-android Triaged by Android platform team labels May 13, 2025
@reidbaker
Copy link
Contributor

Thank you so much for this well written issue sorry this feature slipped through.

auto-submit bot pushed a commit to flutter/packages that referenced this issue May 23, 2025
…9264)

> [!NOTE]  
> This should land after #9241, which should safely bumps the AGP version of this plugin's example app higher than this PR does.

Fixes flutter/flutter#168551 by implementing the `enableAudio` camera setting for video recording. Also:
- Bumps CameraX library version to the latest version,`1.5.0-beta01` (to use a new CameraX method in this implementation)
- Bumps the plugin AGP version to that which `1.5.0-beta01` requires (`8.6.0`)
- Bumps the plugin's example app AGP version to that which `1.5.0-beta01` requires (`8.6.0`) -- will be overridden by #9241
- Corrects the example app to use the `enableAudio` setting just as the app-facing camera widget does
- Adds lint errors caused by the **pigeon generated** `CameraXLibrary.g.kt` file caused by the `1.5.0-beta01` bump to a `lint-baseline.xml` file (all the errors are [`UnsageOptInUsage`](https://googlesamples.github.io/android-custom-lint-rules/checks/UnsafeOptInUsageError.md.html) lints caused by the plugin's [`ExperimentalCamera2Interop`](https://developer.android.com/reference/androidx/camera/camera2/interop/ExperimentalCamera2Interop) usage which is unrelated to this PR)

## Pre-Review Checklist

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
found in release: 3.29 Found to occur in 3.29 found in release: 3.32 Found to occur in 3.32 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: camera The camera plugin P1 High-priority issues at the top of the work list platform-android Android applications specifically team-android Owned by Android platform team triaged-android Triaged by Android platform team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants