每个人!我已经使用 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();
}
}
})
})();