0

我正在使用计时器在我的应用程序中录制视频,它基于 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));
}
4

1 回答 1

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();
        }
    };
于 2014-08-18T08:50:04.503 回答