Android 多媒体录制

try {
String path = "/sdcard/recorder.amr";
MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path+name);
recorder.prepare();
recorder.start();
try {
Runnable.wait(10000);
} catch (Exception exp) {
exp.printStackTrace();
}
recorder.stop();
recorder.release();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
10秒钟哦,等也得等,不等也得等,不用线程怎么行。

录像就是Audio+Video,所以还要加点东西,看代码:
path = "/sdcard/v.3gp";
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setVideoSize(176, 144);
recorder.setVideoFrameRate(15);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);

你可能感兴趣的:(android,exception,String,video,Path,audio)