kill camera stream when unmouting

This commit is contained in:
brunobar79 2018-07-30 18:40:00 -04:00
parent 34617a21c3
commit b673a7a7fc
1 changed files with 4 additions and 1 deletions

View File

@ -33,6 +33,10 @@ export default class QrScanner extends Component {
} }
} }
componentWillUnmount () {
this.codeReader.reset()
}
initCamera () { initCamera () {
console.log('[QR-SCANNER]: initCamera') console.log('[QR-SCANNER]: initCamera')
this.codeReader = new BrowserQRCodeReader() this.codeReader = new BrowserQRCodeReader()
@ -50,7 +54,6 @@ export default class QrScanner extends Component {
this.codeReader.decodeFromInputVideoDevice(videoInputDevices[0].deviceId, 'video') this.codeReader.decodeFromInputVideoDevice(videoInputDevices[0].deviceId, 'video')
.then(content => { .then(content => {
console.log('[QR-SCANNER]: initCamera::decodeFromInputVideoDevice callback', content) console.log('[QR-SCANNER]: initCamera::decodeFromInputVideoDevice callback', content)
this.codeReader.reset()
const result = this.parseContent(content.text) const result = this.parseContent(content.text)
if (result.type !== 'unknown') { if (result.type !== 'unknown') {
this.props.qrCodeDetected(result) this.props.qrCodeDetected(result)