Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #37 from hullalex-tek/master
Browse files Browse the repository at this point in the history
Call stop in beforeDestroy lifecycle hook
  • Loading branch information
VinceG authored Aug 27, 2019
2 parents 98c8f4e + d4f4794 commit 02bee78
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/webcam.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export default {
mounted() {
this.setupMedia();
},
beforeDestroy(){
this.stop();
},
methods: {
legacyGetUserMediaSupport() {
return constraints => {
Expand Down Expand Up @@ -182,7 +185,14 @@ export default {
navigator.mediaDevices
.getUserMedia(constraints)
.then(stream => this.loadCameras())
.then(stream => {
//Make sure to stop this MediaStream
let tracks = stream.getTracks();
tracks.forEach(track => {
track.stop();
});
this.loadCameras();
})
.catch(error => this.$emit("error", error));
},
/**
Expand Down

0 comments on commit 02bee78

Please sign in to comment.