Search code examples
javascriptandroidaudiotitaniumrecorder

How can I record small size voice files in Android using Titanium?


Please help me! I want to record small size voice files in Android using Titanium.

I am using Titanium.Media.AudioRecorder() to record voice files, but the size of the generated files are too large.

I would like to generate small size voice files. It doesn't matter to have low quality.

What format and what compression type should I use to get better results (small size files)? Thank you

I am using the code below:

var audioRecorder = Ti.Media.createAudioRecorder({
    format: Titanium.Media.AUDIO_FILEFORMAT_MP3,
    compression: Titanium.Media.AUDIO_FORMAT_ULAW
});

function startRecord() {
    audioRecorder.start();
}

function stopRecord() {
    record = audioRecorder.stop();
    var audioName = "some_name.mp3";
    var audioFile = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, audioName);
    audioFile.write(record);
}

Solution

  • If you look at the documentation you'll see that the compression and format parameters are iOS only. Android will always record default audio settings.

    You either have to

    You might be able to convert this navitve MediaRecorder example to Hyperloop.