|
|
@ -1562,10 +1562,12 @@ angular.module('myApp.directives', ['myApp.filters']) |
|
|
|
|
|
|
|
|
|
|
|
voiceRecord.on('touchstart', function(e) { |
|
|
|
voiceRecord.on('touchstart', function(e) { |
|
|
|
if ($scope.$parent.$parent.voiceRecorder.processing) { return; } |
|
|
|
if ($scope.$parent.$parent.voiceRecorder.processing) { return; } |
|
|
|
|
|
|
|
|
|
|
|
navigator.getUserMedia({audio : true}, function(stream){ |
|
|
|
navigator.getUserMedia({audio : true}, function(stream){ |
|
|
|
var start = Date.now(); |
|
|
|
var start = Date.now(); |
|
|
|
var touch = null; |
|
|
|
var touch = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
audioPromise = null; |
|
|
|
audioStream = stream; |
|
|
|
audioStream = stream; |
|
|
|
audioRecorder = new MediaRecorder(stream); |
|
|
|
audioRecorder = new MediaRecorder(stream); |
|
|
|
|
|
|
|
|
|
|
@ -1594,7 +1596,7 @@ angular.module('myApp.directives', ['myApp.filters']) |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
voiceRecord.on('click', function(){ |
|
|
|
voiceRecord.on('click', function(){ |
|
|
|
if (audioRecorder) { |
|
|
|
if (audioPromise) { |
|
|
|
$scope.$parent.$parent.voiceRecorder.processing = true; |
|
|
|
$scope.$parent.$parent.voiceRecorder.processing = true; |
|
|
|
|
|
|
|
|
|
|
|
audioPromise.then(function(e) { |
|
|
|
audioPromise.then(function(e) { |
|
|
@ -1604,14 +1606,15 @@ angular.module('myApp.directives', ['myApp.filters']) |
|
|
|
$scope.draftMessage.files = [blob]; |
|
|
|
$scope.draftMessage.files = [blob]; |
|
|
|
$scope.draftMessage.isMedia = true; |
|
|
|
$scope.draftMessage.isMedia = true; |
|
|
|
|
|
|
|
|
|
|
|
audioRecorder = null; |
|
|
|
|
|
|
|
$scope.$parent.$parent.voiceRecorder.processing = false; |
|
|
|
$scope.$parent.$parent.voiceRecorder.processing = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
audioPromise = null; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$($window).on('touchend', function(){ |
|
|
|
$($window).on('touchend', function(){ |
|
|
|
if (audioRecorder) { |
|
|
|
if (audioStream && audioRecorder) { |
|
|
|
audioPromise = new Promise(function(resolve) { |
|
|
|
audioPromise = new Promise(function(resolve) { |
|
|
|
audioRecorder.ondataavailable = resolve; |
|
|
|
audioRecorder.ondataavailable = resolve; |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1619,6 +1622,9 @@ angular.module('myApp.directives', ['myApp.filters']) |
|
|
|
audioRecorder.stop(); |
|
|
|
audioRecorder.stop(); |
|
|
|
audioStream.stop(); |
|
|
|
audioStream.stop(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
audioRecorder = null; |
|
|
|
|
|
|
|
audioStream = null; |
|
|
|
|
|
|
|
|
|
|
|
clearInterval($scope.$parent.$parent.voiceRecorder.recording); |
|
|
|
clearInterval($scope.$parent.$parent.voiceRecorder.recording); |
|
|
|
|
|
|
|
|
|
|
|
$scope.$apply(function(){ |
|
|
|
$scope.$apply(function(){ |
|
|
|