diff --git a/gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/builder/GSYVideoOptionBuilder.java b/gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/builder/GSYVideoOptionBuilder.java index 1abbaafa3..df9bb414f 100644 --- a/gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/builder/GSYVideoOptionBuilder.java +++ b/gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/builder/GSYVideoOptionBuilder.java @@ -113,6 +113,9 @@ public class GSYVideoOptionBuilder { //是否需要在利用window实现全屏幕的时候隐藏statusbar protected boolean mStatusBar = false; + //拖动进度条时,是否在 seekbar 开始部位显示拖动进度 + protected boolean isShowDragProgressTextOnSeekBar = false; + //播放的tag,防止错误,因为普通的url也可能重复 protected String mPlayTag = ""; @@ -547,6 +550,10 @@ public GSYVideoOptionBuilder setOnlyRotateLand(boolean onlyRotateLand) { return this; } + public GSYVideoOptionBuilder setShowDragProgressTextOnSeekBar(boolean isShowDragProgressTextOnSeekBar) { + this.isShowDragProgressTextOnSeekBar = isShowDragProgressTextOnSeekBar; + return this; + } /** * 在播放前才真正执行setup @@ -635,6 +642,7 @@ public void build(GSYBaseVideoPlayer gsyVideoPlayer) { gsyVideoPlayer.setStartAfterPrepared(mStartAfterPrepared); gsyVideoPlayer.setReleaseWhenLossAudio(mReleaseWhenLossAudio); gsyVideoPlayer.setFullHideActionBar(mActionBar); + gsyVideoPlayer.setShowDragProgressTextOnSeekBar(isShowDragProgressTextOnSeekBar); gsyVideoPlayer.setFullHideStatusBar(mStatusBar); if (mEnlargeImageRes > 0) { gsyVideoPlayer.setEnlargeImageRes(mEnlargeImageRes); diff --git a/gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoControlView.java b/gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoControlView.java index 6f0bf2325..7b6189928 100644 --- a/gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoControlView.java +++ b/gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoControlView.java @@ -132,6 +132,7 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O protected boolean mPostProgress = false; protected boolean mPostDismiss = false; + protected boolean isShowDragProgressTextOnSeekBar = false; //播放按键 protected View mStartButton; @@ -570,10 +571,7 @@ public boolean setUp(String url, boolean cacheWithPlay, File cachePath, String t @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { - if (fromUser) { - int duration = getDuration(); - mCurrentTimeTextView.setText(CommonUtil.stringForTime(progress * duration / 100)); - } + showDragProgressTextOnSeekBar(fromUser, progress); } @Override @@ -667,6 +665,14 @@ protected void touchSurfaceDown(float x, float y) { mFirstTouch = true; } + protected void showDragProgressTextOnSeekBar(boolean fromUser, int progress) { + if (fromUser && isShowDragProgressTextOnSeekBar) { + int duration = getDuration(); + if (mCurrentTimeTextView != null) + mCurrentTimeTextView.setText(CommonUtil.stringForTime(progress * duration / 100)); + } + } + protected void touchSurfaceMove(float deltaX, float deltaY, float y) { int curWidth = 0; int curHeight = 0; @@ -1344,4 +1350,16 @@ public int getDismissControlTime() { public void setGSYVideoProgressListener(GSYVideoProgressListener videoProgressListener) { this.mGSYVideoProgressListener = videoProgressListener; } + + public boolean isShowDragProgressTextOnSeekBar() { + return isShowDragProgressTextOnSeekBar; + } + + /** + * 拖动进度条时,是否在 seekbar 开始部位显示拖动进度 + * 默认 false + */ + public void setShowDragProgressTextOnSeekBar(boolean showDragProgressTextOnSeekBar) { + isShowDragProgressTextOnSeekBar = showDragProgressTextOnSeekBar; + } }