나는 VideoView을 사용하여 Android를 사용하여 동영상 플레이어를 구성하고 있습니다. 저는 비디오 플레이어를 사용할 수있게되었습니다. 이제는 파일을 선택했을 때 크로노을 사용하여 카운터를 설정하고 있습니다.
그러나 클립이 시작될 때 타이머가 이미 몇 초 계산되기 시작하면서 비디오 클립은 실행을 시작하는 데 몇 초가 걸립니다.타이머가있는 Android Sync 동영상
어떻게하면 카운터를 미디어 파일과 동기화 할 수 있습니까?
주변을 살펴 보았지만 답변을 찾지 못하는 것 같습니다.
video = (VideoView) findViewById(R.id.video);
play = (Button) findViewById(R.id.play);
pause = (Button) findViewById(R.id.pause);
stop = (Button) findViewById(R.id.stop);
reset = (Button) findViewById(R.id.reset);
Chronometer counter = (Chronometer) findViewById(R.id.chrono);
startTime = SystemClock.elapsedRealtime();
time = (TextView) findViewById(R.id.time);
try {
video.setVideoPath(link);
video.start();
video.requestFocus();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
}
play.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
video.start();
video.requestFocus();
}
});
pause.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
video.pause();
}
});
stop.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
video.stopPlayback();
video.setVideoPath(link);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
reset.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
video.seekTo(0);
video.start();
video.requestFocus();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
counter.setOnChronometerTickListener(new OnChronometerTickListener(){
public void onChronometerTick(Chronometer arg0) {
countUp = (SystemClock.elapsedRealtime() - arg0.getBase())/1000;
duration = video.getDuration();
if (countUp % 60 <= 9) {
countText = (countUp/60) + ":0" + (countUp % 60);
} else {
countText = (countUp/60) + ":" + (countUp % 60);
}
if (duration % 60000 <= 9) {
durationText = (duration/60000) + ":0" + (duration % 60000);
} else {
durationText = (duration/60000) + ":" + (duration % 60000);
}
time.setText(countText + "/" + durationText);
}
});
counter.start();