我使用计时器在我的应用程序中录制视频,它基于JavaCvRecorder应用程序。 当我按下屏幕时,录制开始,我们可以看到屏幕左侧的时间。 现在,我没有显示计时器,我必须显示一个进度条,根据时间加载任何人可以帮我这个,因为我不知道在哪里显示进度条。以下是录制视频时显示时间的代码。请帮帮我朋友
private void initiateRecording(boolean isActionDown) {
isRecordingStarted = true;
firstTime = System.currentTimeMillis();
recording = true;
totalPauseTime = 0;
pausedTime = 0;
txtTimer.setVisibility(View.VISIBLE);
// Handler to show recoding duration after recording starts
mHandler.removeCallbacks(mUpdateTimeTask);
mHandler.postDelayed(mUpdateTimeTask, 100);
btnRecorderControl.setVisibility(View.VISIBLE);
btnRecorderControl.setText(getResources().getString(R.string.stop));
}
答案 0 :(得分:0)
Use AsynkcTask method
private void call_timerprogressbar() { //......call this method first
try {
callprogressbar sessionrunner = new callprogressbar(getActivityTaskHandler);
sessionrunner.execute();
} catch (Exception ex) {
}
}
public class callprogressbar extends AsyncTask<String, String, String> {
Handler statushandler;
public callprogressbar(Handler getActivityTaskHandler) {
statushandler = getActivityTaskHandler;
}
@Override
protected String doInBackground(String... params) {
//........call your timer function
}
@Override
protected void onPreExecute() {
super.onPreExecute();
progressBar.setMessage("Please wait... ");
progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressBar.setIndeterminate(true);
progressBar.setCanceledOnTouchOutside(false);
progressBar.setTitle(" ");
progressBar.setCancelable(false);
progressBar.show();
}
@Override
protected void onPostExecute(String result) {
try
{
super.onPostExecute(result);
Message msg = new Message();
msg.obj = result;
statushandler.sendMessage(msg);
progressBar.dismiss();
}catch(Exception ex){
}
}
}
public Handler getActivityTaskHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
progressBar.dismiss();
}
};