【发布时间】:2016-10-12 13:42:36
【问题描述】:
嗨,我是 android 新手,在我的应用程序中,我必须使用计时器来录制音频,如下图所示,使用我的下面我可以录制音频,但是如何在计时器的帮助下做到这一点,请帮我一些忙
我的代码:-
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.record_button:
startRecording()
break;
case R.id.stop_button:
break;
}
}
private void startRecording() {
try {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.prepare();
mRecorder.start();
} catch (Throwable t) {
t.printStackTrace();
}
}
private void stopRecording() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}
【问题讨论】:
标签: android audio-recording countdowntimer