我正在尝试使用 phoneGap(cordova 1.7.0) 录制示例音频,但它无法正常工作。
这是代码
function startRecord() {
var src = "testrecord.wav";
alert("startRecord: "+src);
navigator.mediaRec = new Media(src, onSuccessRecord, onErrorRecord);
// Record audio
navigator.mediaRec.startRecord();
// Stop recording after 10 sec
var recTime = 0;
var recInterval = setInterval(function() {
recTime = recTime + 1;
//setAudioPosition(recTime + " sec");
if (recTime >= 10) {
clearInterval(recInterval);
navigator.mediaRec.stopRecord();
}
}, 1000);
}
function onSuccessRecord() {
//alert("recordAudio():Audio Success");
var src = "testrecord.wav";
playRecordedAudio(src);
}
function playRecordedAudio(src) {
// Create Media object from src
//alert("play: "+src);
navigator.my_media = new Media(src, onSuccessPlay, onErrorRecord);
// Play audio
navigator.my_media.play();
}
// onError Callback
//
function onSuccessPlay() {
console.log("playAudio():Audio Success");
}
function onErrorRecord(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
我已经在 xcode 模拟器中尝试过,它运行良好,但在 iphone 中没有,有人可以帮帮我吗?