2

The MediaRecorder works on other versions of Android but not on 2.3.3:

try {

    MediaRecorder mRecorder = new MediaRecorder();
    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
    mRecorder.setOutputFile( path + "r_" + FileName );

    int version = android.os.Build.VERSION.SDK_INT;
    Log.d("MP3Downloader", "V: " + version );

    if( version >= 8 ) {
        mRecorder.setAudioEncodingBitRate(16);
        mRecorder.setAudioSamplingRate(44100);
        mRecorder.setAudioChannels(2);
    }

    mRecorder.prepare();
    mRecorder.start();
} catch (Exception e) {
    Log.e("MP3Downloader", "MediaRecorder Failed: " + e.getMessage() );
}

I get error Start Failed: -2147483648 on version 2.3.3 only. I have not found this problem addressed anywhere else.

I also tried:

try {

    MediaRecorder mRecorder = new MediaRecorder();
    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

    FileOutputStream fos = new FileOutputStream( "r_" + FileName);

    mRecorder.setOutputFile( fos.getFD() );



    int version = android.os.Build.VERSION.SDK_INT;
    Log.d("MP3Downloader", "V: " + version );

    if( version >= 8 ) {
        mRecorder.setAudioEncodingBitRate(16);
        mRecorder.setAudioSamplingRate(44100);
        mRecorder.setAudioChannels(1);
    }

    mRecorder.prepare();
    mRecorder.start();
} catch (Exception e) {
    Log.e("MP3Downloader", "MediaRecorder Failed: " + e.getMessage() );
}

But, I get exception: "(Read-only file system)"

I have permissions:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Adam Cox
  • 21
  • 2
  • 4
  • 2
    The problem I believe was from using multiple instances of the MediaRecorder object...that was in a method which would be called multiple times and each time it would re-assign mRecorder to a new instance of a MediaRecorder. I guess the OS/Garbage Collector/Watchdog was taking care of the old MediaRecorder objects on most other versions of Android, but 2.3.3 did not like my poor programming habits...I fixed it be re-using the same instance of the MediaRecorder according to the diagram at http://developer.android.com/reference/android/media/MediaRecorder.html – Adam Cox Jul 31 '12 at 04:02
  • 1
    Your comment gave me hope again.. I have same problem and it's driving me nuts! WIll give it a try and if it works will sure do some upvoting here and there :). BTW android devs. could put their act together and document this sort of stuff better as at the moment this is nothing short of ridiculous – spirytus Aug 12 '12 at 23:06

1 Answers1

0

Try to change your output format to 3gpp.

אורי orihpt
  • 2,358
  • 2
  • 16
  • 41
Amrendra
  • 2,019
  • 2
  • 18
  • 36