i'm working on an ionic App and i need to record audio files , so i used the cordova-plugin-media , it worked fine for android but when i tried it on ios i get this error :
{"message":"Failed to start recording using AVAudioRecorder","code":1}
here is my code :
var extension = '.wav';
var name = 'filename';
var audio = null;
var filepath;
$scope.startRecording = function() {
name = Utils.generateFilename();
if(device.platform == "iOS")
{
//var path = "documents://";
//var path = cordova.file.documentsDirectory;
//var path = cordova.file.cacheDirectory;
var path = cordova.file.dataDirectory;
path = path.replace("file:///", "cdvfile://");
}
else if(device.platform == "Android")
{
var path = cordova.file.externalApplicationStorageDirectory;
}
var filename = name + extension;
filepath = path + filename;
audio = new Media(filepath, function(e){console.log(e, "success Media");},function(e){console.log(e, "error");});
audio.startRecord();
};
$scope.sendAudioMsg = function() {
audio.stopRecord();
audio.release();
};
when i console log the path i get this :
cdvfile://var/mobile/Containers/Data/Application/F47A76AD-E776-469F-8EFA-85B0A0F14754/Library/NoCloud/dJzSapEU6k16hV7EGrD06L29NjZcOCVzHCUTrcjEDiTCF7uUNGmCHchEcwfGls3V88p85ij0NUkv0KVagevbgh3lwWsEfmAO8uNq.wav
can any one help me??