尝试使用starttrim和endtrim修剪和合并临时文件中保存的音频。但是无法找到有关cordova的任何资源。任何科尔多瓦用户在那里?即时通讯使用cordova-media-plugin录制音频。
function onDeviceReady(){ document.getElementById(" btnRecord")。addEventListener(' click',recordAudio,false); document.getElementById(" btnStop")。addEventListener(' click',stopRecording,false); 的document.getElementById(" btnCut&#34)的addEventListener('单击',cutRecording,假)。 } function cutRecording(){ var AudioEditor = new Audio() AudioEditor.trim(){ fileUri:src, trimStart:3, trimEnd:5, 成功:功能(结果){alert(result)} }
}
///// START RECORING ////
function recordAudio(){
var rec = document.getElementById("btnRecord").innerHTML
if (rec== "START RECORDING"){
initializeRecord()
mediaRec.startRecord();
var recTime = 0;
var recMin = 0;
recInterval = setInterval(function () {
if (!isPaused){
recTime = recTime + 1;
if(recTime == 60){
recMin = recMin + 1
recTime = 1
}
time = (pad+recMin).slice(-pad.length)+ ":" + (pad+recTime).slice(-pad.length)
setAudioPostion(time);
}
},1000);
document.getElementById("btnRecord").innerHTML="PAUSE RECORDING"
document.getElementById("btnStop").style.backgroundColor="#e74c3c"
}
if (rec== "PAUSE RECORDING"){
mediaRec.pauseRecord();
isPaused= true;
document.getElementById("btnRecord").innerHTML="RESUME RECORDING"
document.getElementById("btnRecord").style.backgroundColor="#e74c3c"
}
if (rec== "RESUME RECORDING"){
mediaRec.resumeRecord()
isPaused = false;
document.getElementById("btnRecord").innerHTML="PAUSE RECORDING"
document.getElementById("btnRecord").style.backgroundColor="#024699"
}
}
function initializeRecord(){
fileName = stringGen(9) + Date.now()
src = "cdvfile://localhost/temporary/" + fileName.toString() + ".wav"
mediaRec = new Media(src, onSuccess, onError);
}