Skip to content

Commit

Permalink
feat: try fallback constraints after NotReadableError and Overconstra…
Browse files Browse the repository at this point in the history
…inedError
  • Loading branch information
fbaiodias committed Oct 16, 2019
1 parent 40d9f9d commit d590834
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/video-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,28 @@ export default class VideoRecorder extends Component {
error: null
})

const fallbackContraints = {
audio: true,
video: true
}

navigator.mediaDevices
.getUserMedia(this.props.constraints)
.catch(err => {
// there's a bug in chrome in some windows computers where using `ideal` in the constraints throws a NotReadableError
if (
err.name === 'NotReadableError' ||
err.name === 'OverconstrainedError'
) {
console.warn(
`Got ${
err.name
}, trying getUserMedia again with fallback constraints`
)
return navigator.mediaDevices.getUserMedia(fallbackContraints)
}
throw err
})
.then(this.handleSuccess)
.catch(this.handleError)
}
Expand Down

0 comments on commit d590834

Please sign in to comment.