olefirenko / vue-barcode-reader

A Vue.js set of components to scan barcodes and QR codes.
213 stars 75 forks source link

Stop camera after capturing #32

Closed Tommendes closed 2 years ago

Tommendes commented 2 years ago

Hi Olefirenko!

This is my first time issue and I do not know if her is the best place to do. But...

Could You add a stopCamera method after capturing codeBar? Example above:

start() {
  this.codeReader.decodeFromVideoDevice(
    undefined,
    this.$refs.scanner,
    (result, err) => {
      if (result) {
        this.$emit("decode", result.text);
        **this.stopCameraStream();**
      }
    }
  );
},
```
stopCameraStream() {
      let tracks = this.$refs.scanner.srcObject.getTracks();
      tracks.forEach((track) => {
        track.stop();
      });
    },
```
alirezaalavi87 commented 2 years ago

I fixed this in my PR https://github.com/olefirenko/vue-barcode-reader/pull/31#issue-1134212399 . but seems the maintainer hasn't checked up on this project in months. I've replaced this package with vue-qrcode-reader since barcodes weren't important for me.

olefirenko commented 2 years ago

@alirezaalavi87 Seems you are using Vue 2 where beforeUnmount is not available (it was added in Vue 3). For Vue 2 compatible version please use the vue-barcode-reader@0.0.3