In my application playing music, the user should say at this time into the microphone. Can you please tell me how to make a record? Music and top path from the microphone. I looked through MediaRecorder, but there is not, in my opinion, an appropriate recording source.
Asked
Active
Viewed 1,701 times
1 Answers
0
For Recording Through Mic
Start and stop recording through Mic....
Start Recording
static MediaRecorder recorder = new MediaRecorder();
static String path, filename, time;
static int duration;
public void startRecording() {
try {
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
System.currentTimeMillis();
filename = ListenCallState.number + "_" + time + ".amr";
File f = new File(getBaseURL());
f.mkdirs();
path = getBaseURL() + filename;
recorder.setOutputFile(path);
recorder.prepare();
recorder.start();
} catch (Exception {
}
}
Stop Recording
public static void stopRecording() {
recorder.stop();
recorder.release();
try {
MediaPlayer p = new MediaPlayer();
p.setDataSource(path);
p.prepare();
duration = p.getDuration();
} catch (Exception e) {
}
}

Nikunj Paradva
- 15,332
- 5
- 54
- 65
-
I know how to record from the microphone. But how to write music that is playing on your phone and microphone in one track ... – Fox Sep 02 '16 at 17:15
-
1). song is Playing in background 2).in Your Application Record Through Mic. That is Simple... If You are Talking...Loudly then your voice is also recorded...... – Nikunj Paradva Sep 03 '16 at 05:43
-
Yes, but the sound quality of the music will be bad ( – Fox Sep 03 '16 at 06:05
-
Nooo, I can not find the answer – Fox Sep 05 '16 at 10:40
-
I think If you make your own player then that is Possible to record!! – Nikunj Paradva Sep 05 '16 at 11:42