Search code examples
androidcordovamediarecord

Can't find the recorded file using Media.startRecord


i am using the Media class to record from device mic, is sucessful recorded but i can't find the audio file(myrecording.amr) on my android device.

function recordAudio() {
    var src = "myrecording.amr";
    var mediaRec = new Media(src, onSuccess, onError);
    // Record audio
    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);
            mediaRec.stopRecord();
        }
    }, 1000);
}

function onDeviceReady() {
    app.enabled("btnRecord", true);//IDE widget

}
// onSuccess Callback
//
function onSuccess() {
    app.alert("recordAudio():Audio Success");//IDE widget
    //app.setValue("labelmobile1", mediaRec.); IDE widget
}

// onError Callback 
//
function onError(error) {
    alert('code: '    + error.code    + '\n' + 
          'message: ' + error.message + '\n');
}

// Set audio position
// 
function setAudioPosition(position) {
    app.setValue("label1", position);//IDE widget
}

Where i can find it?


Solution

  • Try this

    var filepath = Environment.getExternalStorageDirectory().getPath();     
    File file = new File(filepath,<directoryName>);        
    var src=file.getAbsolutePath()+""myrecording.amr"     
    

    Your file will be created inside <directoryName>