我怎样才能改变一个进度条的位置,videoView的时间后? [英] How can i change the position of a progressBar, after the duration of a videoView?
本文介绍了我怎样才能改变一个进度条的位置,videoView的时间后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下code:
final SeekBar videoBar = (SeekBar) findViewById(R.id.videoBar);
final VideoView videoView = (VideoView) findViewById(R.id.videoViewPaint);
videoView.setVideoPath(videoPath);
videoView.start();
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
long duration = videoView.getDuration();
videoBar.setMax((int) duration);
LogService.log("in runnable", "videoView duration= " + videoView.getDuration());
}
});
videoBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (isVideo) {
videoView.seekTo(progress);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
playBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
if (isPlaying) {
// Button is ON
videoView.pause();
playBtn.setImageResource(R.drawable.play);// Do Something
isPlaying = false;
} else if (!isPlaying) {
// Button is OFF
videoView.start(); // Do Something
playBtn.setImageResource(R.drawable.pause);
isPlaying = true;
}
}
});
现在,如果我移动进度(videoBar),它需要的视频,视频的一部分,但如果在视频播放,它不会移动到进度条,并肩作战。我怎样才能做到,而播放视频时移动进度条?
Now if i move the progressBar (videoBar), it takes the the video to that part of the video, but if the video plays, it does not move to progress bar, alongside. How can I make it, move the progress bar while the video is playing?
推荐答案
这让我得到它的权利,现在的作品。第一个答案
This helped me get it right, now it works. The first answer
<一个href=\"http://stackoverflow.com/questions/7731354/how-to-use-a-seekbar-in-android-as-a-seekbar-as-well-as-a-progressbar-simultaneo\">How使用搜索栏在Android作为一个搜索栏,以及同时一个进度条?
这篇关于我怎样才能改变一个进度条的位置,videoView的时间后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文