Phonegap 3.5媒体插件在iOS上的错误“无法使用AvAudioRecorder开始录制” [英] Phonegap 3.5 Media Plugin Error on iOS "Failed to start recording using AvAudioRecorder"
问题描述
我想让使用者在Phonegap应用程式中录制音讯档案。它在Android上运行良好,但在iOS上,我在录制开始时收到以下错误:
I am trying to let users record an audio file in a Phonegap app. It works well on Android, but on iOS I get the following error when the recording should start:
无法使用AvAudioRecorder开始录制。
"Failed to start recording using AvAudioRecorder".
我使用.wav文件名,我首先创建了文件,我遵循了我发现的所有指令,我一直得到错误。
I use a .wav filename, I create the file first, I have followed all instructions I have found and I keep getting the error.
这是一段代码:
theFileSystem.root.getFile(filename,{create:true},function(fileEntry){
mediaFileURL = fileEntry.toURL();
console.log('Created file ' + mediaFileURL);
mediaRec = new Media(mediaFileURL, function(){
//console.log('Media File created');
}, function(err){
alert('Error creating the media file: ' + err.message);
console.log(mediaFileURL);
for(k in err){
console.log(k + ': ' + err[k]);
}
stopRecordingFile();
});
mediaRec.startRecord();
},function(err){
alert("Error setting audio file");
});
我看到控制台消息创建文件...,因此文件已成功创建。然后我得到的错误。
I see the console message 'Created file ...' so the file is successfully created. Then I get the error.
媒体插件版本是0.2.11
Media plugin version is 0.2.11
我不知道还有什么要尝试。非常感谢您的帮助。
I don't know what else to try. Thanks for any help.
推荐答案
我自己解决了这个问题。
I solved this myself.
对于iOS,这需要更改:
For iOS, this needs to be changed:
mediaFileURL = fileEntry.toURL();
:
mediaFileURL = fileEntry.fullPath;
此外,即使我请求持久文件系统,iOS将文件保存在tmp文件夹中。所以,以后使用FileTransfer上传文件,我用这个来引用文件(我尝试了不同的方法,这是一个工作):
Also, even though I was requesting the Persistent filesystem, iOS saved the file in the tmp folder. So to upload the file afterwards using FileTransfer, I used this to refer to the file (I tried different approaches and this was the one that worked):
sendFileURL = cordova.file.tempDirectory + filename;
这篇关于Phonegap 3.5媒体插件在iOS上的错误“无法使用AvAudioRecorder开始录制”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!