我要在Android设备上录制音频。 这是代码。
curr_playing_file: MediaObject;
recordaudio(){
var nItem = localStorage.getItem('recordvoiceNum');
var numstr = 0;
if (nItem == null) {
numstr = 1;
}
else {
var numstr = parseInt(nItem, 10);
numstr = numstr + 1;
}
//Create media file
this.curfilename = 'audio' + numstr + '.3gp';
this.curr_playing_file = this.createAudioFile(this.curfilename);
localStorage.setItem('recordvoiceNum', numstr.toString());
try {
console.log('start Recording');
if (this.curr_playing_file == undefined)
console.log('dont start');
this.curr_playing_file.startRecord();
}
catch (e) {
console.log('record error');
console.log(e.message);
}
setTimeout(function () {
try {
console.log('stop recording');
//stop recording
if (this.curr_playing_file == undefined)
console.log('dont stop');
this.curr_playing_file.stopRecord();
}
catch (error) {
console.log('stoperror');
console.log(error.message);
}
}, 10000);
}
我得到“无法读取属性'stopRecord'未定义”错误。 媒体对象具有“stopRecord()”的功能。 但我不知道这个错误的原因。 请给我建议。 感谢。