Skip to content

Commit 71010f0

Browse files
committed
fix(init): stop previous camera if any
If a camera is requested after initilization the previous camera instance needs to be terminated or else this can cause errors. The camera might be already in use or the device only allows one active camera at a time. See #40
1 parent 3dc84f1 commit 71010f0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/components/QrcodeReader.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ export default {
167167
methods: {
168168
169169
async init () {
170+
if (this.camera !== null) {
171+
this.camera.stop()
172+
}
173+
170174
this.camera = await Camera(this.constraints, this.$refs.video)
171175
},
172176

0 commit comments

Comments
 (0)