Created
September 15, 2015 02:44
-
-
Save wehlutyk/eff0a904fb25ae38afb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/js/directives.js b/app/js/directives.js | |
index dcf758f..8d79172 100755 | |
--- a/app/js/directives.js | |
+++ b/app/js/directives.js | |
@@ -1356,6 +1356,7 @@ angular.module('myApp.directives', ['myApp.filters']) | |
var stickerImageCompiled = $compile('<a class="composer_sticker_btn" data-sticker="{{::document.id}}" my-load-sticker document="document" thumb="true" img-class="composer_sticker_image"></a>'); | |
var cachedStickerImages = {}; | |
var audioRecorder = null; | |
+ var audioPromise = null; | |
var audioStream = null; | |
var emojiTooltip = new EmojiTooltip(emojiButton, { | |
@@ -1456,6 +1457,7 @@ angular.module('myApp.directives', ['myApp.filters']) | |
navigator.getUserMedia = ( navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia); | |
voiceRecord.on('touchstart', function(e) { | |
+ if ($scope.$parent.$parent.voiceRecorder.processing) { return; } | |
navigator.getUserMedia({audio : true}, function(stream){ | |
var start = Date.now(); | |
var touch = null; | |
@@ -1491,7 +1493,7 @@ angular.module('myApp.directives', ['myApp.filters']) | |
if (audioRecorder) { | |
$scope.$parent.$parent.voiceRecorder.processing = true; | |
- audioRecorder.ondataavailable = function(e){ | |
+ audioPromise.then(function(e) { | |
var blob = e.data; | |
console.log(blob); | |
@@ -1500,12 +1502,16 @@ angular.module('myApp.directives', ['myApp.filters']) | |
audioRecorder = null; | |
$scope.$parent.$parent.voiceRecorder.processing = false; | |
- } | |
+ }); | |
} | |
}); | |
$($window).on('touchend', function(){ | |
if (audioRecorder) { | |
+ audioPromise = new Promise(function(resolve) { | |
+ audioRecorder.ondataavailable = resolve; | |
+ }); | |
+ | |
audioRecorder.stop(); | |
audioStream.stop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
L17 also prevents a new recording from being started when previous audio is being processed.