Skip to content

Commit

Permalink
[microphone] Add debug for missing config call
Browse files Browse the repository at this point in the history
  • Loading branch information
knolleary committed May 3, 2020
1 parent 478e692 commit b2cefb5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion node-red-node-ui-microphone/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-node-ui-microphone",
"version": "0.1.2",
"version": "0.1.3",
"description": "A Node-RED ui node to record audio on a dashboard.",
"author": "Nick O'Leary",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion node-red-node-ui-microphone/ui_microphone.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}},
height: {value: 0},
name: {value: ''},
maxLength: { value: 3 },
maxLength: { value: 5 },
timeslice: { value: 0 }
},
inputs:0,
Expand Down
25 changes: 13 additions & 12 deletions node-red-node-ui-microphone/ui_microphone.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ module.exports = function(RED) {
function HTML(config) {
var configAsJson = JSON.stringify(config);
var html = String.raw`
<style>
</style>
<md-button id="microphone_control_{{$id}}" class="nr-ui-microphone-button" ng-disabled="!enabled" ng-click="toggleMicrophone()"><i ng-if="enabled" class="fa fa-2x fa-microphone" /><i ng-if="!enabled" class="fa fa-2x fa-microphone-slash" /></md-button>
<md-button aria-label="capture audio" id="microphone_control_{{$id}}" class="nr-ui-microphone-button" ng-disabled="!enabled" ng-click="toggleMicrophone()"><i ng-if="enabled" class="fa fa-2x fa-microphone" /><i ng-if="!enabled" class="fa fa-2x fa-microphone-slash" /></md-button>
<input type='hidden' ng-init='init(` + configAsJson + `)'>
`;
return html;
Expand Down Expand Up @@ -84,6 +82,7 @@ module.exports = function(RED) {
initController: function($scope) {

$scope.init = function (config) {
console.log("ui_microphone: initialised config:",config);
$scope.config = config;
}

Expand Down Expand Up @@ -139,22 +138,24 @@ module.exports = function(RED) {
}
};
// Timeslice is not current exposed.
var timeslice = 0;
if ($scope.config.timeslice) {
timeslice = parseInt($scope.config.timeslice)*1000;
}
if (timeslice) {
mediaRecorder.start(timeslice);
} else {
// var timeslice = 0;
// if ($scope.config.timeslice) {
// timeslice = parseInt($scope.config.timeslice)*1000;
// }
// if (timeslice) {
// mediaRecorder.start(timeslice);
// } else {
mediaRecorder.start();
}
// }

if ($scope.config.maxLength) {
if ($scope.config && $scope.config.maxLength) {
stopTimeout = setTimeout(function() {
if (active) {
mediaRecorder.stop();
}
},$scope.config.maxLength*1000)
} else if (!$scope.config) {
console.warn("Microphone node not initialised with user configuration. Using defaults")
}
};

Expand Down

0 comments on commit b2cefb5

Please sign in to comment.