Back

AudioRecorder

The AudioRecorder object can be used to listen for sound and record it to a file.

Create an AudioRecorder object using the CreateAudioRecorder method of the app object:

 rec = app.CreateAudioRecorder();

Use the SetFile method to tell the object where to store the sound:

 rec.SetFile("/sdcard/demo.wav");

The Start method tells it to start recording:

 rec.Start();

And the Stop method is for when you have finished recording:

 rec.Stop();

Example


function OnStart()
{
    rec = app.CreateAudioRecorder();
    rec.SetFile( "/sdcard/test.wav" );
    rec.Start();
    app.ShowPopup("Please speak");
    setTimeout(stopit,5000);
}

function stopit()
{
    app.ShowPopup("Finished recording");
    rec.Stop();
}
    Copy     Copy All      Run     

See 'CreateAudioRecorder for more informations and a complete function list