0

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?

avenda
  • 503
  • 1
  • 5
  • 15

4 Answers4

0

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>

A--C
  • 35,565
  • 10
  • 102
  • 90
Mukund K Roy
  • 175
  • 1
  • 8
0

My guess that it's created in your Android app home directory, since you are using relative path.

You can check here how to find your home directory: Android Get Application's 'Home' Data Directory

However, I agree with Mukund. It's much better to specify absolute path in this case.

Community
  • 1
  • 1
Victor Ronin
  • 21,310
  • 16
  • 85
  • 171
0

If you do not specify a path then the Media.startRecord() method will default to putting your file at the location specified by Environment.getExternalStorageDirectory(). Check for it in /sdcard or /mnt/sdcard.

Simon MacDonald
  • 23,205
  • 5
  • 56
  • 73
0

you can find it in the sdcard and the path will be:

"/sdcard/myrecording.amr"

Manmohan Soni
  • 5,664
  • 1
  • 21
  • 25