Hi!

I am using the navigator.getUserMedia method to get camera access. I have 
different templateUrls and I would like the camera to switch off when I go 
back to a previous templateUrl. So I create a reference to the media stream 
in the onSuccess callback function of getUserMedia() in a .js file, and 
then I use this reference in my testController.js by binding it to $scope. 
I am watching the change in the URL to conditionally switch off the camera 
via .stop() method.My .js file looks like this:

var localStream
if (navigator.getUserMedia) {
headtrackerStatus("getUserMedia");
var videoSelector = {video: true};
navigator.getUserMedia(videoSelector, function (stream) {
                    headtrackerStatus("camera found");
                    if (video.mozCaptureStream) {
                        video.mozSrcObject = stream;
                    } else {
                        video.src = (window.URL && 
window.URL.createObjectURL(stream)) || stream;
                    }
                    this.localStream = stream;
                    video.play();
                }, function () {
                    headtrackerStatus("no camera");
                    insertAltVideo(video);
                });
}

And my testController.js looks like this:

$scope.localStream;
$scope.location = $location;
$scope.$watch( 'location.url()', function( url ) {
            if($location.path() == '/introduction') {
                localStream.stop();
     }
});

Is there a better way to access the localStream reference in the 
controller? Also, when I try to get camera access again after stopping the 
stream, I get the last frozen frame of the previous stream and I can't 
proceed forward. If I were to use video.src="", would I have to bind that 
to $scope as well? Any help would be greatly appreciated.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to