How are you creating your MediaRecorder object? After you call release
(), you can no longer use the MediaRecorder object. From this code
fragment, it looks like it will only record once.
Are you testing in emulation or on a G1? I think you may have to add a
command-line arg to the emulator to enable audio input.
On Nov 12, 2:23 pm, ste <[EMAIL PROTECTED]> wrote:
> I've been trying this for over a day and haven't found anyone who
> seems to know, so I'm hoping someone can help.
>
> Every time I try to record, I get the following error:
> java.lang.RuntimeException: start failed.
>
> I've added the following to my manifest file:
> <uses-permission android:name="android.permission.RECORD_AUDIO"/>
> My code is below:
>
> ImageButton btnRec = (ImageButton) findViewById( R.id.btnRec );
> if( btnRec != null ){
> btnRec.setOnClickListener( new OnClickListener(){
> public void onClick( View viewParam ) {
> try{
> /*Create an Intent that will start your Activity
> */
> recorder.setAudioSource
> (MediaRecorder.AudioSource.MIC);
> recorder.setOutputFormat
> (MediaRecorder.OutputFormat.THREE_GPP);
> recorder.setAudioEncoder
> (MediaRecorder.AudioEncoder.AMR_NB);
> recorder.setOutputFile("TesterPath");
> recorder.prepare();
> recorder.start(); // Recording is now started
> tvStatus.setText("Recording now");
> } catch (IllegalStateException e) {
> tvError.setText("IllegealState Error found: " + e);
> } catch (Exception e) {
> tvError.setText("Generic Error found: " + e);
> }
> }
>
> });
> }
>
> ImageButton btnStop = (ImageButton) findViewById
> ( R.id.btnStop);
> if( btnStop != null ){
> btnStop.setOnClickListener( new OnClickListener(){
> public void onClick( View viewParam ) {
> try{
> recorder.stop();
> recorder.reset(); // You can reuse the object by
> going back to setAudioSource() step
> recorder.release(); // Now the object cannot be
> reused
> tvStatus.setText("Recording stopped");
> } catch (IllegalStateException e) {
> tvError.setText("IllegealState Error found: " + e);
> } catch (Exception e) {
> tvError.setText("Generic Error found: " + e);
> }
>
> }
> });
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---