大家好! 我已经使用cordova-plugin-media成功创建了媒体列表,但是当我触发录制时,我收到错误;
{message: "Failed to start recording using AVAudioRecorder", code: 1}
我甚至无法想象会发生什么以及为什么会发生这种错误((
这是我的JS代码
(function() {
"use strict";
angular.module('app.services')
.factory('soundService', function($q) {
var fileDirectory = null,
mediasForPlay = [],
currentMedia = null;
return {
createDir: function(segments) {
//get dir
window.resolveLocalFileSystemURL(cordova.file.cacheDirectory, function (dir) { // create All segments for video at once
fileDirectory = dir;
segments = segments.map(function (elem) {
//here we create files for recording
return $q(function(resolve, reject) {
fileDirectory.getFile(elem.id + '.wav', {create: true, exclusive: false},
function (file) {resolve(file)},
function(err) {reject(err)});
});
});
$q.all(segments).then(function(data) {
//transform it to media
mediasForPlay = data.map(function(elem) {
var url = elem.nativeURL.replace('file://', ''),
media = new Media(url, function() {console.log('success'); media.release()}, function (err) {console.log(err)});
return media;
});
});
})
},
startRecord: function(segmentId, index) {
currentMedia = mediasForPlay[index];
//here we get an error
currentMedia.startRecord();
}
}
})
})();