After creating a function that combines two separate functions (recorder.start() and recorder.stop()), I encountered a problem where the program could only fire one of the functions at a time when they were added to one ng-click. This meant that in order for the second function to be executed, I had to press the button again. Is there a way to get both functions to execute after pressing the button just once?
Here is the JavaScript code:
$scope.record = function() {
recorder.start($scope.recordConfig).then(function() {
var test = $scope.recordConfig.captureSource;
recorder.stop();
})
},
n.start = function(e) {
return t.postMessage("start", e)
},
n.stop = function() {
t.postMessage("stop")
},
c.postMessage = function(e, t) {
return c.getPort().then(function(n) {
return n.postMessage({
type: e,
data: t
})
})
},
And here is the HTML code:
<md-button ng-click="record()" class="md-primary md-raised">Start Recording</md-button>
=======================================================================
- Further question: I attempted to control the two functions with a piece of code in popup.html.js, but ran into an issue where the popup window closed when the user changed tabs in Chrome. The Chrome documentation explained that "popups automatically close when the user focuses on some portion of the browser outside of the popup." Do you have any suggestions on how to keep the popup window open at all times, or enable the stop() function to run even when the popup window is closed?
Here is the code from popup.html.js:
$scope.recordStart = function() {
// recorder is an angular module which can postMessage such as start/stop/pause... ...
recorder.start($scope.recordConfig)
.then(function() {
var test = $scope.recordConfig.captureSource;
"tab" !== test && "desktop" !== test || a.IS_E2E;
})
$scope.stop = function() {
recorder.stop();
},
$scope.record = function() {
$scope.recordStart();
$timeout(function(){$scope.stop(); },4000)
}