cordova 1.7 iOS录音插件

cordova 1.7 iOS录音插件,ios,cordova,phonegap-plugins,avaudiorecorder,Ios,Cordova,Phonegap Plugins,Avaudiorecorder,我已经使用phonegap/cordova 1.7在IOS上实现了音频录制插件。第5.1条 我通过标准的media.startrecord()函数使用它,因为我想更改比特率以减小文件的大小 它在模拟器中运行良好 在真正的iphone上,它成功录制了一次,但随后拒绝了。。它似乎可以工作,但在播放时,我得到一个错误4 MediaError.MEDIA\u ERR\u NONE\u受支持 我已经创建了一个新项目,只有一个简单的记录和回放,我仍然遇到同样的问题 这是测试代码——非常基本——只需几个链接就

我已经使用phonegap/cordova 1.7在IOS上实现了音频录制插件。第5.1条

我通过标准的media.startrecord()函数使用它,因为我想更改比特率以减小文件的大小

它在模拟器中运行良好

在真正的iphone上,它成功录制了一次,但随后拒绝了。。它似乎可以工作,但在播放时,我得到一个错误4 MediaError.MEDIA\u ERR\u NONE\u受支持

我已经创建了一个新项目,只有一个简单的记录和回放,我仍然遇到同样的问题

这是测试代码——非常基本——只需几个链接就可以记录两个单独的文件并播放它们。setTimeout每次只录制几秒钟的音频

我一直在谷歌上搜索,直到我的指纹磨坏了,但还没有找到解决方案

如果您能提供任何见解,我们将不胜感激

我想知道我是否未能正确关闭录音/播放?或者sim v和iPhone上的文件引用方式不同

非常感谢

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta charset="utf-8">
<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css" type="text/css" />       

<script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script>
    <script type="text/javascript">
       var fs,mediaRec=null, recInterval,recordSettings = {"FormatID": "kAudioFormatULaw","SampleRate": 16000.0,"NumberOfChannels": 1,"LinearPCMBitDepth": 16};

    function recfile1() {recordAudio("test.wav");}
    function recfile2() {recordAudio("test2.wav");}
    function success(){console.log("ok");}
    function recordAudio(fname) {
        fs.root.getFile(fname, {create: true, exclusive: false}, function(entry){            
            mediaRec = new Media(entry.fullPath, success, function(){alert("failed");});
            mediaRec.startRecordWithSettings(recordSettings);
            recInterval = setTimeout(function() {
                mediaRec.stopRecordWithSettings();
            }, 2000);
        }, function(){console.log("error");});
    }

    function playfile(fname) {
        var my_media;
        fs.root.getFile(fname, {create: false, exclusive: false}, 
            function success(entry) {
                my_media = new Media(entry.fullPath,function(){console.log("ok");},function(err){alert(err.code+" "+err.message);});
                my_media.play();
            }, 
            function() {
                console.log("not found file");
            }
        );
    }

    function onBodyLoad() {     
    document.addEventListener("deviceready", onDeviceReady, false);
}

function onDeviceReady(){
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem){fs=fileSystem;}, function(){console.log("failed");});
    Media.prototype.startRecordWithSettings = function(options) {
        Cordova.exec(null, null, "AudioRecord","startAudioRecord", [this.id, this.src, options]);
    };
    Media.prototype.stopRecordWithSettings = function() {
        Cordova.exec(null, null, "AudioRecord","stopAudioRecord", [this.id, this.src]);
    };
}
</script>
</head>
<body onload="onBodyLoad()">
<a onclick="playfile('test.wav');">play</a>
    <a style='margin-top:100px;' onclick="recfile1();">record 1</a>
    <a style='margin-top:100px;' onclick="recfile2();">record 2</a>
    <a onclick="playfile('test2.wav');">play2</a>
</body>
</html>

变量fs,mediaRec=null,recInterval,recordSettings={“FormatID”:“kAudioFormatULaw”,“SampleRate”:16000.0,“NumberOfChannels”:1,“LinearPCMBitDepth”:16};
函数recfile1(){recordAudio(“test.wav”);}
函数recfile2(){recordAudio(“test2.wav”);}
函数success(){console.log(“ok”);}
功能录制音频(fname){
getFile(fname,{create:true,exclusive:false},函数(entry){
mediaRec=新媒体(entry.fullPath,success,function(){alert(“failed”);});
mediaRec.StartRecords带设置(记录设置);
recInterval=setTimeout(函数(){
mediaRec.stopRecordWithSettings();
}, 2000);
},函数(){console.log(“error”);});
}
函数播放文件(fname){
var my_media;
getFile(fname,{create:false,exclusive:false},
功能成功(条目){
my_media=new media(entry.fullPath,function(){console.log(“ok”);},function(err){alert(err.code+“”+err.message);});
我的媒体播放();
}, 
函数(){
log(“未找到文件”);
}
);
}
函数onBodyLoad(){
文件。添加的监听器(“deviceready”,OnDeviceraddy,false);
}
函数ondevicerady(){
requestFileSystem(LocalFileSystem.PERSISTENT,0,函数(fileSystem){fs=fileSystem;},函数(){console.log(“failed”);});
Media.prototype.startRecordWithSettings=功能(选项){
Cordova.exec(null,null,“AudioRecord”,“startAudioRecord”,“this.id,this.src,options]);
};
Media.prototype.stopRecordWithSettings=函数(){
Cordova.exec(null,null,“AudioRecord”,“stopAudioRecord”,“this.id,this.src]);
};
}
玩
记录1
记录2
剧本2

进一步测试表明,我可以成功录制任意数量的文件。然后,此代码将回放任何文件,但一旦回放一个文件,就无法回放任何其他文件,并且出现错误4 MediaError.MEDIA\u ERR\u NONE\u SUPPORTED\u您是否发现了这一点?我在WP7和Android上使用Cordova 2.0.0时也遇到了同样的问题……不幸的是没有,目前我已经恢复到iPhone上的本地CD质量录制。仍在努力,我会发布进展