我正在寻找一种方法来在VideoView
正在播放时收到回调,表明视频进度。类似于描述here,但是VideoView
。每隔固定时间轮询当前进度似乎是一个糟糕的解决方案......
我错过了是否有任何听众存在?
答案 0 :(得分:7)
您可以使用线程来获取进度。
mRunnable = new Runnable() {
public void run() {
Log.i(TAG, "::run: getCurrentPosition = " + mVideoView.getCurrentPosition());
if(mVideoView.isPlaying()){
mHandler1.postDelayed(this, 250);
}
}
};
mHandler1.post(mRunnable);
答案 1 :(得分:1)
Runnable onEverySecond=new Runnable() {
public void run() {
if(seekbar != null) {
seekbar.setProgress(mPlayer.getCurrentPosition());
}
if(mPlayer.isPlaying()) {
System.out.println("inside runnable :::::: is playing ");
seekbar.postDelayed(onEverySecond, 10);
}
}
};
seekbar.postDelayed(onEverySecond, 10);