SGG SGG - 9 months ago 127
AngularJS Question

Turn ON/OFF Webcam using AngularJS

I'm using

directive for capturing photos. I'm able to turn OFF the camera. But I'm not able ON it again. Any help would be appreciated.

Here is my current code to stop the camera.

var mStream = null;

$scope.onStream = function (stream) {
// You could do something manually with the stream.
mStream = stream;
$scope.stopCamera = function() {
// mStream.stop(); didn't work.
$scope.startCamera = function() {
//; didn't work
// ToDo

Thank you

Answer Source

in webcam directive we have following events

$scope.$on('$destroy', onDestroy);
$scope.$on('START_WEBCAM', startWebcam);
$scope.$on('STOP_WEBCAM', stopWebcam);

in your controller you can use something like this

  $scope.destroyWebcam = function () {

 $scope.stopWebcam = function () {