Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[camera_android_camerax] Implement enableAudio for video recording #9264

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

Merged
merged 14 commits into from
May 23, 2025
Merged
Prev Previous commit
Next Next commit
self review
  • Loading branch information
camsim99 committed May 20, 2025
commit 5b8f2cea3e0e9c5841751a06b43da9d82c5c4b22
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public ProxyApiRegistrar getPigeonRegistrar() {
@NonNull
@Override
public PendingRecording withAudioEnabled(PendingRecording pigeonInstance, boolean initialMuted) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, withAudioEnabled(true) disables audio and withAudioEnabled(false) enables audio? I'm confused by the parameter name being initialMuted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol yeah it's confusing.

I made this mirror PendingRecording.withAudioEnabled where initialMuted == true means that you want to initialize the recording as being muted/audio disabled, so withAudioEnabled(true) disables audio, withAudioEnabled(false) enables audio.

if (!initialMuted) {
if (ContextCompat.checkSelfPermission(
getPigeonRegistrar().getContext(), Manifest.permission.RECORD_AUDIO)
== PackageManager.PERMISSION_GRANTED) {
return pigeonInstance.withAudioEnabled(false);
}
if (!initialMuted
&& ContextCompat.checkSelfPermission(
getPigeonRegistrar().getContext(), Manifest.permission.RECORD_AUDIO)
== PackageManager.PERMISSION_GRANTED) {
return pigeonInstance.withAudioEnabled(false);
}

return pigeonInstance.withAudioEnabled(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void withAudioEnabled_doesNotEnableAudioWhenRequestedAndPermissionNotGran
}

@Test
public void withAudioEnabled_doesNotEnableAudioWhenNotRequested() {
public void withAudioEnabled_doesNotEnableAudioWhenAudioNotRequested() {
final PigeonApiPendingRecording api =
new TestProxyApiRegistrar().getPigeonApiPendingRecording();
final PendingRecording instance = mock(PendingRecording.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ class AndroidCameraCameraX extends CameraPlatform {
/// This is expressed in terms of one of the [Surface] rotation constant.
late int _initialDefaultDisplayRotation;

/// Whether or not audio should attempt to be enabled for recording video.
/// Whether or not audio should be enabled for recording video if permission is
/// granted.
@visibleForTesting
late bool enableRecordingAudio;

Expand Down Expand Up @@ -1108,7 +1109,9 @@ class AndroidCameraCameraX extends CameraPlatform {
);
pendingRecording = await recorder!.prepareRecording(videoOutputPath!);

// Attempt to enable/disable recording audio as requested.
// Enable/disable recording audio as requested. If enabling audio is requested
// and permission was not granted when the camera was created, then recording
// audio will be disabled to respect the denied permission.
pendingRecording =
await pendingRecording!.withAudioEnabled(enableRecordingAudio);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ abstract class VideoRecordEventListener {
),
)
abstract class PendingRecording {
/// Enables audio to be recorded for this recording.
/// Enables/disables audio to be recorded for this recording.
PendingRecording withAudioEnabled(bool initialMuted);

/// Starts the recording, making it an active recording.
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.