Skip to content

Commit

Permalink
fix(rn-camera): set default captureAudio property value to true (reac…
Browse files Browse the repository at this point in the history
  • Loading branch information
arneson authored and n1ru4l committed Jan 8, 2019
1 parent 6cd79f5 commit 2940faf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 11 additions & 1 deletion docs/RNCamera.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ Setting this property causes the auto focus feature of the camera to attempt to

Coordinates values are measured as floats from `0` to `1.0`. `{ x: 0, y: 0 }` will focus on the top left of the image, `{ x: 1, y: 1 }` will be the bottom right. Values are based on landscape mode with the home button on the right—this applies even if the device is in portrait mode.

#### `captureAudio`

Values: boolean `true` (default) | `false`

Specifies if audio recording permissions should be requested.
Make sure to follow README instructions for audio recording permissions [here](../README.md).

#### `flashMode`

Values: `RNCamera.Constants.FlashMode.off` (default), `RNCamera.Constants.FlashMode.on`, `RNCamera.Constants.FlashMode.auto` or `RNCamera.Constants.FlashMode.torch`.
Expand Down Expand Up @@ -500,7 +507,10 @@ The promise will be fulfilled with an object with some of the following properti

- `maxFileSize` (int greater than 0). Specifies the maximum file size, in bytes, of the video to be recorded. For 1mb, for example, use 1\*1024\*1024. If nothing is specified, no size limit will be used.

- `mute` (any value). If this flag is given in the option with any value, the video to be recorded will be mute. If nothing is specified, video will NOT be muted.
- `mute` (any value). (*This value will automatically be set to true if the `captureAudio` has not been passed to the Camera component*) If this flag is given in the option with any value, the video to be recorded will be mute. If nothing is specified, video will NOT be muted.
**Note:** The recommended way of recording audio without sound passing captureAudio: false to the Camera component.
The `mute` parameter is likely to become deprecated in the near future.

- `path` (file path on disk). Specifies the path on disk to record the video to. You can use the same `uri` returned to continue recording across start/stops

The promise will be fulfilled with an object with some of the following properties:
Expand Down
8 changes: 7 additions & 1 deletion src/RNCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
<ActivityIndicator size="small" />
</View>
),
captureAudio: false,
captureAudio: true,
useCamera2Api: false,
playSoundOnCapture: false,
pictureSize: 'None',
Expand Down Expand Up @@ -338,6 +338,12 @@ export default class Camera extends React.Component<PropsType, StateType> {
}
}
}

const { captureAudio } = this.props

if (!captureAudio) {
options.mute = true
}
return await CameraManager.record(options, this._cameraHandle);
}

Expand Down

0 comments on commit 2940faf

Please sign in to comment.