.Hi, I'm trying to get audio recording to work in ngCordova.
I'm running this on an Android 4.4, and the debugger is showing successes and no failures.
I can't find the files in ES File Explorer (any suggestions for tools)?
I'm familiar with Angular, but not mobile dev. .play() does not play the file back. I found a temp file on my phone with my recorded voice.
Why isn't this working? Is there a demo app somewhere? Thanks!
'use strict';
angular.module('app')
.controller('StaticController', function($scope, $ionicPlatform, $cordovaFile, Audio) {
$scope.suggestion = "Hello World";
$scope.slug = "HelloWord.amr";
$ionicPlatform.ready(function() {
$scope.audioFile = $cordovaMedia.newMedia(Audio.getFilePath($scope.slug));
});
$scope.isRecording = false;
// WRITE
$scope.writeFile = function() {
$cordovaFile.writeFile(cordova.file.dataDirectory, "file.txt", "text", true)
.then(function (success) {
console.log('success');
console.log(success);
}, function (error) {
console.log('error');
console.log(error);
});
};
$scope.play = function() {
$scope.audioFile.play();
console.log('play');
};
$scope.startRecord = function() {
$scope.isRecording = true;
$scope.audioFile.startRecord();
console.log('startRecord');
};
$scope.stopRecord = function() {
$scope.isRecording = false;
$scope.audioFile.stopRecord();
$scope.audioFile = $cordovaMedia.newMedia(Audio.getFilePath($scope.slug));
console.log('stopRecord');
};
});