0
我試圖用phoneGap(cordova 1.7.0)錄製示例音頻,但它不工作。PhoneGap:mediaRec.startRecord();不工作在cordova-1.7.0
這裏是我在Xcode模擬器及其工作得很好嘗試這種代碼
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');
}
,但不是在iphone 任何人都可以請幫我嗎?