jonashartmann/webcam-directive

video stream is not stopped

sumanthreddy-a opened this issue · 2 comments

$scope.closed = function stopWebcam() {
onDestroy()
$scope.$broadcast('STOP_WEBCAM', stopWebcam);
$scope.$broadcast('$destroy', onDestroy);
}
var onDestroy = function onDestroy() {

    if (!!_video ) {
      var checker = typeof _video.getVideoTracks === 'function';
      if(_video.getVideoTracks && checker) {
        videoStream.stop();

        // get video track to call stop in it
        // videoStream.stop() is deprecated and may be removed in the
        // near future
        // ENSURE THIS IS CHECKED FIRST BEFORE THE FALLBACK
        // videoStream.stop()
        var tracks = _video.getVideoTracks();
        if (tracks && tracks[0] && tracks[0].stop) {
          tracks[0].stop();
        }
      } else if (_video.stop) {
        // deprecated, may be removed in the near future
        videoStream.stop();
      }
    }
    if (!!_video) {
      delete _video.src;
    }
  };

Camera doesn't stop after clicking image

Duplicate of #43