MediaRecorder Exeption, wo liegt der Grund?

Dieses Thema im Forum "Android App Entwicklung" wurde erstellt von computer_freak, 04.04.2011.

  1. computer_freak, 04.04.2011 #1
    computer_freak

    computer_freak Threadstarter Gewerbliches Mitglied

    Beiträge:
    156
    Erhaltene Danke:
    7
    Registriert seit:
    14.12.2010
    Hallo!

    Ich versuche seit einigen Tagen verzweifelt den MediaRecorder zum laufen zu bringen. Habe schon umfangreich gegoogelt, aber keine passende Antwort gefunden.

    Nun zum eigentlichen Problem:
    Code:
    04-04 21:12:29.758: ERROR/audio_input(2357): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
    04-04 21:12:29.758: ERROR/audio_input(2357): VerifyAndSetParameter failed
    04-04 21:12:30.020: ERROR/AuthorDriver(2357): Command 13 completed with error -17
    04-04 21:12:30.020: ERROR/MediaRecorder(31285): prepare failed: -17
    04-04 21:12:30.020: WARN/System.err(31285): java.io.IOException: prepare failed.
    04-04 21:12:30.035: WARN/System.err(31285):     at android.media.MediaRecorder._prepare(Native Method)
    04-04 21:12:30.039: WARN/System.err(31285):     at android.media.MediaRecorder.prepare(MediaRecorder.java:530)
    04-04 21:12:30.039: WARN/System.err(31285):     at com.testApp.Record.onCreate(Record.java:77)
    04-04 21:12:30.039: WARN/System.err(31285):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    04-04 21:12:30.039: WARN/System.err(31285):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    04-04 21:12:30.043: WARN/System.err(31285):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    04-04 21:12:30.043: WARN/System.err(31285):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    04-04 21:12:30.043: WARN/System.err(31285):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    04-04 21:12:30.043: WARN/System.err(31285):     at android.os.Handler.dispatchMessage(Handler.java:99)
    04-04 21:12:30.047: WARN/System.err(31285):     at android.os.Looper.loop(Looper.java:123)
    04-04 21:12:30.047: WARN/System.err(31285):     at android.app.ActivityThread.main(ActivityThread.java:4627)
    04-04 21:12:30.047: WARN/System.err(31285):     at java.lang.reflect.Method.invokeNative(Native Method)
    04-04 21:12:30.051: WARN/System.err(31285):     at java.lang.reflect.Method.invoke(Method.java:521)
    04-04 21:12:30.051: WARN/System.err(31285):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
    04-04 21:12:30.055: WARN/System.err(31285):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
    04-04 21:12:30.055: WARN/System.err(31285):     at dalvik.system.NativeStart.main(Native Method)
    04-04 21:12:30.375: INFO/ActivityManager(2464): Displayed activity com.testApp/.Record: 782 ms (total 782 ms)
    04-04 21:12:32.540: WARN/PowerManagerService(2464): Timer 0x7->0x3|0x1
    04-04 21:12:32.540: INFO/PowerManagerService(2464): Ulight 7->3|0
    04-04 21:12:32.942: VERBOSE/WindowManager(2464): Dsptch > Window{484e3d08 InputMethod paused=false}
    04-04 21:12:32.942: VERBOSE/InputDevice(2464): ID[0]=0(0) Dn(0=>1)
    04-04 21:12:33.051: DEBUG/dalvikvm(2563): GC_EXPLICIT freed 6369 objects / 350352 bytes in 33ms
    04-04 21:12:33.821: VERBOSE/WindowManager(2464): Dsptch > Window{484e3d08 InputMethod paused=false}
    04-04 21:12:33.821: VERBOSE/InputDevice(2464): ID[0]=0(0) Up(1=>0)
    04-04 21:12:34.746: VERBOSE/InputDevice(2464): ID[0]=0(0) Dn(0=>1)
    04-04 21:12:34.750: VERBOSE/WindowManager(2464): Dsptch > Window{4858c4a0 com.testApp/com.testApp.Record paused=false}
    04-04 21:12:34.856: VERBOSE/WindowManager(2464): Dsptch > Window{4858c4a0 com.testApp/com.testApp.Record paused=false}
    04-04 21:12:34.856: VERBOSE/InputDevice(2464): ID[0]=0(0) Up(1=>0)
    04-04 21:12:34.903: ERROR/MediaRecorder(31285): start called in an invalid state: 0
    04-04 21:12:34.903: DEBUG/AndroidRuntime(31285): Shutting down VM
    04-04 21:12:34.903: WARN/dalvikvm(31285): threadid=1: thread exiting with uncaught exception (group=0x4001d7d0)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285): FATAL EXCEPTION: main
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285): java.lang.IllegalStateException: Could not execute method of the activity
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at android.view.View$1.onClick(View.java:2082)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at android.view.View.performClick(View.java:2461)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at android.view.View$PerformClick.run(View.java:8890)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at android.os.Handler.handleCallback(Handler.java:587)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at android.os.Handler.dispatchMessage(Handler.java:92)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at android.os.Looper.loop(Looper.java:123)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at android.app.ActivityThread.main(ActivityThread.java:4627)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at java.lang.reflect.Method.invokeNative(Native Method)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at java.lang.reflect.Method.invoke(Method.java:521)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at dalvik.system.NativeStart.main(Native Method)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285): Caused by: java.lang.reflect.InvocationTargetException
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at com.testApp.Record.recClicked(Record.java:106)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at java.lang.reflect.Method.invokeNative(Native Method)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at java.lang.reflect.Method.invoke(Method.java:521)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at android.view.View$1.onClick(View.java:2077)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     ... 11 more
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285): Caused by: java.lang.IllegalStateException
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     at android.media.MediaRecorder.start(Native Method)
    04-04 21:12:34.914: ERROR/AndroidRuntime(31285):     ... 15 more
    

    Und Hier meine Klasse, in der das Problem verursacht wird:
    Code:
    package com.testApp;
    
    import java.io.File;
    import java.io.IOException;
    
    import android.app.Activity;
    import android.content.res.Configuration;
    import android.media.MediaPlayer;
    import android.media.MediaRecorder;
    import android.media.MediaRecorder.OnInfoListener;
    import android.os.Bundle;
    import android.os.Environment;
    import android.util.Log;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    
    public class Record extends Activity
    {
    
    	private boolean IsRecording = false;
    	
    	private MediaRecorder recorder;
    	
    	private String tempFilePath = Environment.getExternalStorageDirectory().getAbsolutePath()+ "/Android/data/testApp/" ;
    	public void onCreate(Bundle savedInstanceState)
    	{
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.record);
    		tempFilePath += String.valueOf(System.currentTimeMillis()) + ".3gp";
    
    		Log.d(RECORD_LOG, "onCreate done");
    		
    		recorder = new MediaRecorder();
    		//recorder.reset();
    		recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    		recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); // THREE_GPP = .3gp, RAW_AMR 
    		recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    		Log.d(RECORD_LOG, "onCreate|tempFilePath=" + tempFilePath);
    		recorder.setOutputFile(tempFilePath);
    		recorder.setMaxDuration(6000);
    		recorder.setOnInfoListener(new OnInfoListener()
    		{
    			@Override
    			public void onInfo(MediaRecorder mr, int what, int extra)
    			{
    				if(what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED)
    				{
    					Log.d(RECORD_LOG, "recorder.onInfo called");
    				}
    			}			
    		});
    		
    		try
    		{
    			recorder.prepare();
    		}
    		catch (IllegalStateException e)
    		{
    			e.printStackTrace();
    		}
    		catch (IOException e)
    		{
    			e.printStackTrace();
    		}
    	}
    	
    	public void recClicked()
    	{
    		
    		if(IsRecording)
    		{
    			Log.d(RECORD_LOG, "recClicked entered, IsRecording = true, so we stop that thing");
    			recorder.stop();
    			recorder.reset();
    			recorder = null;
    			
    			btn_play.setEnabled(true);
    		}
    		else
    		{
    			Log.d(RECORD_LOG, "recClicked entered, IsRecording = false, so we start that thing");
    			btn_record.setText(R.string.record_rec2);
    						
    			recorder.start();
    		}
    
    		IsRecording = !IsRecording;
    		
    	}
    
    	
    	
    }

    Ich hoffe, jemand kann mich hier etwas aufklären:laugh:!
     
    Zuletzt bearbeitet: 04.04.2011

Diese Seite empfehlen