farhadnowzari / easy-vue-camera

11 stars 11 forks source link

The camera stays on (on Vuetify dialog) #2

Open farhadnowzari opened 3 years ago

farhadnowzari commented 3 years ago

If the camera component is loaded inside a Vuetify dialog and the dialog is closed it will stay on.

samputer commented 2 years ago

Thanks for this library!

For anyone else experiencing the same issue, I found a quick and easy fix:

Add a ref to the camera as follows:

<v-easy-camera ref="cam" v-model="picture"></v-easy-camera>

Watch the v-model (in my case value) of the dialogue to identify when it opens/closes and call the stop() function explicitly upon modal close

watch: {
    async value(opened) {
      if (opened) {
         // dialogue was opened
      } else {
         // dialogue was closed
        this.$refs.cam.stop()
      }
    }
  }
farhadnowzari commented 2 years ago

I found the actual issue specially when it was used like in a modal with vuetify. I have to stop it on "unmounted" but this will be in the next release with Vue 3 support