Skip to content

Commit b7a9a9d

Browse files
committed
Merge pull request #6 from exocom/develop
Angular 1.2.0 updates
2 parents 0e1ffd8 + cb5ff93 commit b7a9a9d

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.js
22
!Gruntfile.js
33
!dist/*.js
4-
node_modules/
4+
node_modules/
5+
.idea

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-camera",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"homepage": "https://github.com/onemightyroar/angular-camera",
55
"authors": [
66
"Zach Dunn <[email protected]>"
@@ -14,7 +14,7 @@
1414
"video"
1515
],
1616
"dependencies": {
17-
"angular": "1.0.7"
17+
"angular": "~1.2.0"
1818
},
1919
"license": "GNU"
2020
}

dist/angular-camera.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
'use strict';
33
angular.module('omr.directives', []).directive('ngCamera', [
44
'$timeout',
5-
function ($timeout) {
5+
'$sce',
6+
function ($timeout, $sce) {
67
return {
78
require: 'ngModel',
89
template: '<div class="ng-camera clearfix"> <p ng-hide="isLoaded">Loading Camera...</p> <p ng-show="noCamera">Couldn\'t find a camera to use</p> <div class="ng-camera-stack" ng-hide="!isLoaded"> <div class="ng-camera-countdown" ng-show="activeCountdown"> <p class="tick">{{countdownText}}</p> </div> <img class="ng-camera-overlay" ng-hide="!overlaySrc" ng-src="{{overlaySrc}}" width="{{width}}" height="{{height}}"> <video id="ng-camera-feed" autoplay width="{{width}}" height="{{height}}" src="{{videoStream}}">Install Browser\'s latest version</video> <canvas id="ng-photo-canvas" width="{{width}}" height="{{height}}" style="display:none;"></canvas> </div> <div class="ng-camera-controls" ng-hide="hideUI"> <button class="btn ng-camera-take-btn" ng-click="takePicture()">Take Picture</button> </div> </div>',
@@ -24,14 +25,20 @@
2425
scope.activeCountdown = false;
2526
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
2627
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
28+
scope.$on('$destroy', function () {
29+
if (scope.stream && typeof scope.stream.stop === 'function') {
30+
scope.stream.stop();
31+
}
32+
});
2733
scope.enableCamera = function () {
2834
return navigator.getUserMedia({
2935
audio: false,
3036
video: true
3137
}, function (stream) {
3238
return scope.$apply(function () {
39+
scope.stream = stream;
3340
scope.isLoaded = true;
34-
return scope.videoStream = window.URL.createObjectURL(stream);
41+
return scope.videoStream = $sce.trustAsResourceUrl(window.URL.createObjectURL(stream));
3542
});
3643
}, function (error) {
3744
return scope.$apply(function () {

dist/angular-camera.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/directives/angular-camera.coffee

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
angular.module('omr.directives', [])
4-
.directive 'ngCamera', ($timeout) ->
4+
.directive 'ngCamera', ($timeout, $sce) ->
55
require: 'ngModel'
66
template: '<div class="ng-camera clearfix">
77
<p ng-hide="isLoaded">Loading Camera...</p>
@@ -38,7 +38,11 @@ angular.module('omr.directives', [])
3838
# Remap common references
3939
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia
4040
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL
41-
41+
scope.$on('$destroy', () ->
42+
if scope.stream and typeof scope.stream.stop == 'function'
43+
scope.stream.stop()
44+
return
45+
)
4246
###*
4347
* @description Set mediastream source and notify camera
4448
###
@@ -48,8 +52,9 @@ angular.module('omr.directives', [])
4852
video: true
4953
, (stream) ->
5054
scope.$apply ->
55+
scope.stream = stream
5156
scope.isLoaded = true
52-
scope.videoStream = window.URL.createObjectURL(stream)
57+
scope.videoStream = $sce.trustAsResourceUrl(window.URL.createObjectURL(stream))
5358
, (error) ->
5459
scope.$apply ->
5560
scope.isLoaded = true

0 commit comments

Comments
 (0)