在Android中播放视频时的时间跟踪

时间:2017-01-18 09:46:23

标签: android

我想在Android studio中播放视频时在特定时间点显示按钮,那么我将如何跟踪视频播放时间

1 个答案:

答案 0 :(得分:0)

  public void onPrepared(MediaPlayer mediaPlayer) {
                mVideoView2.start();
                loadJSONFromAsset();
                duration = mVideoView2.getDuration();
                current = mVideoView2.getCurrentPosition();
                // TextView textView = (TextView) findViewById(R.id.textView_currentPosion);
                textCurrentPosition.setText(String.valueOf(current));
                //textCurrentPosition.setText(duration);
                Log.d("Current Location", String.valueOf(current));
                if (current > 2000 && current < 9000) {

                    buttonPause.setVisibility(View.VISIBLE);


                } else {
                    buttonPause.setVisibility(View.GONE);
                }
            }
        });