Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ The options passed to the `Blob` constructor, including specifying the MIMEType

The options passed to the `MediaRecorder` constructor. Defaults to `{}`.

### constraints

The constraints passed to `navigator.getUserMedia`. Defaults to `{audio: true}`.

### command

Useful for Redux-like environments where changes in state are communicated via props. When the `command` prop is changed, the corresponding method is called. Allowed values are the method name strings (`['start', 'stop', 'resume', 'pause']`) as well as `'none'`, representing no method call. Developers can also call these methods directly by accessing the component's `ref`.
Expand Down
8 changes: 4 additions & 4 deletions src/Recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ const Recorder = React.createClass({
navigator.webkitGetUserMedia)

if (navigator.getUserMedia && window.MediaRecorder) {
const constraints = {audio: true}
this.chunks = []
const { blobOpts, onStop, onError, mediaOpts, onPause, onResume, onStart, gotStream } = this.props
const { constraints, blobOpts, onStop, onError, mediaOpts, onPause, onResume, onStart, gotStream } = this.props

const onErr = err => {
console.warn(err)
Expand Down Expand Up @@ -56,7 +55,7 @@ const Recorder = React.createClass({
if (gotStream) gotStream(stream)
}

navigator.getUserMedia(constraints, onSuccess, onErr)
navigator.getUserMedia(constraints || {audio: true}, onSuccess, onErr)
} else {
console.warn('Audio recording APIs not supported by this browser')
const { onMissingAPIs } = this.props
Expand Down Expand Up @@ -93,7 +92,8 @@ const Recorder = React.createClass({
onUnmount: PropTypes.func,
gotStream: PropTypes.func,
blobOpts: PropTypes.object,
mediaOpts: PropTypes.object
mediaOpts: PropTypes.object,
constraints: PropTypes.object
}
})

Expand Down