Android的MediaRecorder怎么显示音频记录的时间期限

2025-03-07 02:19:21
推荐回答(1个)
回答1:

解决方法 :
在记录开始的 System.currentTimeMillis(); 方法中设置 start_time 方法。
然后使用 Runnable 可以执行一个循环,直到停止记录。

final Handler handler = new Handler();
Runnable update_runnable = new Runnable() {
public void run() {
updateTextView();
}
};
Then with the updateTextView() you'd do something like this:

long duration = (int) ((System.currentTimeMillis() - start_time) / 1000);
// ... set TextView with duration value
handler.postDelayed(update_runnable, 1000); /