Problem with MediaRecorder.start()

All your problems with Audio, Video and Images.

Problem with MediaRecorder.start()

Postby pawegio » Fri Nov 19, 2010 9:21 pm

I received an error in my App.

This is report:

Code: Select all
java.lang.RuntimeException: start failed.
at android.media.MediaRecorder.start(Native Method)
at com.pawegio.recandsave.RecordingSession.startRec(RecordingSession.java:149)
at com.pawegio.recandsave.RecordingSession.access$1(RecordingSession.java:104)
at com.pawegio.recandsave.RecordingSession$1.onClick(RecordingSession.java:94)
at android.view.View.performClick(View.java:2408)
at android.view.View$PerformClick.run(View.java:8817)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)


and here is my code:
Code: Select all
   private void startRec() {
      
      ...
      
      try {
         File storageDir = new File("/sdcard/Rec and Save");
         
         NumberFormat df = new DecimalFormat("000"); // fileId format
         
         for(int i = 1; i < 999; i++) {
            outfile = new File(storageDir + "/" + recordTitle + "_" + df.format(i) + ".3gp");
            if(!outfile.exists()) {
               
               fileId = df.format(i);
               break;
            }
         }
         
         outfile = new File(storageDir + "/" + recordTitle + "_" + fileId + ".3gp");
         
         toastText = "Saved as " + outfile.getName();
         
         recorder = new MediaRecorder();
         recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
         recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
         recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
         recorder.setOutputFile(outfile.getPath());
      } catch (Exception e) {
         Log.w(TAG, "File not accessible ", e);
      }
      
      Log.d(TAG, "start recording..");
      try {
         recorder.prepare();
      } catch (IllegalStateException e) {
         Log.w(TAG, "Invalid recorder state .. reset/release should have been called");
      } catch (IOException e) {
         Log.w(TAG, "Could not write to sd card");
      }
      recorder.start();
      recording = true;
   }
pawegio
Freshman
Freshman
 
Posts: 5
Joined: Mon Jun 21, 2010 10:17 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 13 guests