Skip to content

Commit

Permalink
add isShowDragProgressTextOnSeekBar
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Jan 17, 2020
1 parent 93bb8bc commit 4397cf1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ public class GSYVideoOptionBuilder {
//是否需要在利用window实现全屏幕的时候隐藏statusbar
protected boolean mStatusBar = false;

//拖动进度条时,是否在 seekbar 开始部位显示拖动进度
protected boolean isShowDragProgressTextOnSeekBar = false;

//播放的tag,防止错误,因为普通的url也可能重复
protected String mPlayTag = "";

Expand Down Expand Up @@ -547,6 +550,10 @@ public GSYVideoOptionBuilder setOnlyRotateLand(boolean onlyRotateLand) {
return this;
}

public GSYVideoOptionBuilder setShowDragProgressTextOnSeekBar(boolean isShowDragProgressTextOnSeekBar) {
this.isShowDragProgressTextOnSeekBar = isShowDragProgressTextOnSeekBar;
return this;
}

/**
* 在播放前才真正执行setup
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 4397cf1

Please sign in to comment.