|
|
|
@ -27,6 +27,17 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct |
|
|
|
|
|
|
|
|
|
|
|
var controller = ['$scope', 'safeApply', '$timeout', '$q', "mediaDevices", "userMedia", function($scope, safeApply, $timeout, $q, mediaDevices, userMedia) { |
|
|
|
var controller = ['$scope', 'safeApply', '$timeout', '$q', "mediaDevices", "userMedia", function($scope, safeApply, $timeout, $q, mediaDevices, userMedia) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var localStream = null; |
|
|
|
|
|
|
|
var delayToTakePicture = 3000; |
|
|
|
|
|
|
|
var countDownFrom = 3; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var takePictureCountDown; |
|
|
|
|
|
|
|
var writeVideoToCanvas; |
|
|
|
|
|
|
|
var writePreviewPic; |
|
|
|
|
|
|
|
var makePicture; |
|
|
|
|
|
|
|
var videoStop; |
|
|
|
|
|
|
|
var videoStart; |
|
|
|
|
|
|
|
|
|
|
|
// Buddy picutre capture size.
|
|
|
|
// Buddy picutre capture size.
|
|
|
|
$scope.captureSize = { |
|
|
|
$scope.captureSize = { |
|
|
|
width: 128, |
|
|
|
width: 128, |
|
|
|
@ -41,12 +52,8 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct |
|
|
|
$scope.canvasPic = null; |
|
|
|
$scope.canvasPic = null; |
|
|
|
$scope.canvasPrev = null; |
|
|
|
$scope.canvasPrev = null; |
|
|
|
|
|
|
|
|
|
|
|
var localStream = null; |
|
|
|
|
|
|
|
var delayToTakePicture = 3000; |
|
|
|
|
|
|
|
var countDownFrom = 3; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Counts down from start to 1
|
|
|
|
// Counts down from start to 1
|
|
|
|
var takePictureCountDown = function(start, delayTotal) { |
|
|
|
takePictureCountDown = function(start, delayTotal) { |
|
|
|
$scope.countingDown = true; |
|
|
|
$scope.countingDown = true; |
|
|
|
$scope.countdown = {}; |
|
|
|
$scope.countdown = {}; |
|
|
|
$scope.countdown.num = start; |
|
|
|
$scope.countdown.num = start; |
|
|
|
@ -63,7 +70,7 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var writeVideoToCanvas = function(canvas) { |
|
|
|
writeVideoToCanvas = function(canvas) { |
|
|
|
|
|
|
|
|
|
|
|
var videoWidth = $scope.video.videoWidth; |
|
|
|
var videoWidth = $scope.video.videoWidth; |
|
|
|
var videoHeight = $scope.video.videoHeight; |
|
|
|
var videoHeight = $scope.video.videoHeight; |
|
|
|
@ -89,12 +96,12 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var writePreviewPic = function() { |
|
|
|
writePreviewPic = function() { |
|
|
|
writeVideoToCanvas($scope.canvasPrev); |
|
|
|
writeVideoToCanvas($scope.canvasPrev); |
|
|
|
$scope.preview = $scope.canvasPrev.toDataURL("image/jpeg"); |
|
|
|
$scope.preview = $scope.canvasPrev.toDataURL("image/jpeg"); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var makePicture = function(stream, cntFrom, delayTotal) { |
|
|
|
makePicture = function(stream, cntFrom, delayTotal) { |
|
|
|
takePictureCountDown(cntFrom, delayTotal); |
|
|
|
takePictureCountDown(cntFrom, delayTotal); |
|
|
|
$timeout(function() { |
|
|
|
$timeout(function() { |
|
|
|
$scope.flash.addClass("flash"); |
|
|
|
$scope.flash.addClass("flash"); |
|
|
|
@ -107,7 +114,7 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct |
|
|
|
}, delayTotal); |
|
|
|
}, delayTotal); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var videoStop = function(stream, video) { |
|
|
|
videoStop = function(stream, video) { |
|
|
|
if (stream) { |
|
|
|
if (stream) { |
|
|
|
video.pause(); |
|
|
|
video.pause(); |
|
|
|
userMedia.stopUserMediaStream(stream); |
|
|
|
userMedia.stopUserMediaStream(stream); |
|
|
|
@ -115,7 +122,7 @@ define(['jquery', 'underscore', 'text!partials/buddypicturecapture.html'], funct |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var videoStart = function() { |
|
|
|
videoStart = function() { |
|
|
|
$scope.waitingForPermission = true; |
|
|
|
$scope.waitingForPermission = true; |
|
|
|
var videoConstraints = true; |
|
|
|
var videoConstraints = true; |
|
|
|
var videoAllowed = $q.defer(); |
|
|
|
var videoAllowed = $q.defer(); |
|
|
|
|