As your journal says it means "Failed to get audio input for recording source 1". The Android device did not detect any sound recording equipment.
So, if you are testing the application from the emulator, make sure that you have successfully connected the mice during sound recording, or if you are debugging or running it from the device, then make sure the microphone is turned on to record sound.
Hope this helps you.
Or
If the above does not solve your problem, use the code below to record sound, as it works great for me.
code:
record.setOnClickListener(new View.OnClickListener() { boolean mStartRecording = true; public void onClick(View v) { if (mStartRecording==true) { //startRecording(); haveStartRecord=true; String recordWord = wordValue.getText().toString(); String file = Environment.getExternalStorageDirectory().getAbsolutePath(); file = file+"/"+recordWord+".3gp"; System.out.println("Recording Start"); //record.setText("Stop recording"); record.setBackgroundDrawable(getResources().getDrawable( R.drawable.rec_on)); mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); mRecorder.setOutputFile(file); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
//mRecorder.setAudioChannels(1); //mRecorder.setAudioSamplingRate(8000);
try { mRecorder.prepare(); } catch (IOException e) { Log.e(LOG_TAG, "prepare() failed"); } mRecorder.start(); } else { //stopRecording(); System.out.println("Recording Stop"); record.setBackgroundDrawable(getResources().getDrawable( R.drawable.rec_off)); mRecorder.stop(); mRecorder.release(); mRecorder = null; haveFinishRecord=true; } mStartRecording = !mStartRecording; } });
Hope this answer helps you.
Enjoy. :)
source share