Skip to content

Commit

Permalink
fix: [Android][expo-camera] - Recording video with {mute: true} optio…
Browse files Browse the repository at this point in the history
…n without audio permission throws exception (expo#23145)
  • Loading branch information
hirbod authored Jun 27, 2023
1 parent b89e350 commit b876b73
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/expo-camera/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### 🐛 Bug fixes

- Resolved an issue on Android where recording a video, even with the mute: true option, would still result in an audio permission exception. Furthermore, the mute flag was incorrectly referred to as muteValue, causing it to be consistently ignored ([#23145](https://github.com/expo/expo/pull/23145) by [@hirbod](https://github.com/hirbod))

### 💡 Others

## 13.4.0 — 2023-06-13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CameraViewModule : Module() {
}.runOnQueue(Queues.MAIN)

AsyncFunction("record") { options: RecordingOptions, viewTag: Int, promise: Promise ->
if (!permissionsManager.hasGrantedPermissions(Manifest.permission.RECORD_AUDIO)) {
if (!options.mute && !permissionsManager.hasGrantedPermissions(Manifest.permission.RECORD_AUDIO)) {
throw Exceptions.MissingPermissions(Manifest.permission.RECORD_AUDIO)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class ExpoCameraView(
val path = FileSystemUtils.generateOutputPath(cacheDirectory, "Camera", ".mp4")
val profile = getCamcorderProfile(cameraView.cameraId, options.quality)
options.videoBitrate?.let { profile.videoBitRate = it }
if (cameraView.record(path, options.maxDuration * 1000, options.maxFileSize, !options.muteValue, profile)) {
if (cameraView.record(path, options.maxDuration * 1000, options.maxFileSize, !options.mute, profile)) {
videoRecordedPromise = promise
} else {
promise.reject("E_RECORDING_FAILED", "Starting video recording failed. Another recording might be in progress.", null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ class RecordingOptions : Record {
@Field val maxDuration: Int = -1
@Field val maxFileSize: Int = -1
@Field val quality: Int = CamcorderProfile.QUALITY_HIGH
@Field val muteValue: Boolean = false
@Field val mute: Boolean = false
@Field val videoBitrate: Int? = null
}

0 comments on commit b876b73

Please sign in to comment.