I'm doing this on both the emulator and a G1.
I create the mediarecorder object as a public variable in my main
class:
public MediaRecorder recorder = new MediaRecorder();
After looking around, I think my problem was the filename I gave. When
I changed it to "/sdcard/test.3gpp", I was able to get it to
successfully record. When I look in the filesystem, I see the file
exists.
Now I can't successfully stop though. I get a "reset failed" message
when I try. I tried creating the mediarecorder object when I hit the
record button, but that doesn't seem to help either.
On Nov 12, 9:35 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> How are you creating yourMediaRecorderobject? After you call release
> (), you can no longer use theMediaRecorderobject. 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
-~----------~----~----~----~------~----~------~--~---