我正在用MediaRecorder做申请,我想显示录制音频的时间限制。MediaRecorder仅用于录制语音。任何人都知道如何在做MediaRecorder时显示时间。
发布于 2012-02-24 11:43:14
如果您已经为录制和停止编写了MediaRecorder的音频奠定了基础,那么获取录制的时长并不是太难。
显示持续时间只是在记录开始时设置为System.currentTimeMillis();的start_time。
然后,通过使用Runnable,我们可以执行一个循环,直到记录停止。
final Handler handler = new Handler();
Runnable update_runnable = new Runnable() {
public void run() {
updateTextView();
}
};然后使用updateTextView(),你可以这样做:
long duration = (int) ((System.currentTimeMillis() - start_time) / 1000);
// ... set TextView with duration value
handler.postDelayed(update_runnable, 1000); // handler re-executes the Runnable
// every second; which calls
// updateTextViewhttps://stackoverflow.com/questions/7308070
复制相似问题