Skip to content

Commit

Permalink
增加 GSYStateUiListener
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Jul 31, 2020
1 parent 0782cc5 commit e253dac
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.graphics.drawable.Drawable;
import android.view.View;

import com.shuyu.gsyvideoplayer.listener.GSYStateUiListener;
import com.shuyu.gsyvideoplayer.listener.GSYVideoProgressListener;
import com.shuyu.gsyvideoplayer.render.view.GSYVideoGLView;
import com.shuyu.gsyvideoplayer.render.effect.NoEffect;
Expand Down Expand Up @@ -160,6 +161,9 @@ public class GSYVideoOptionBuilder {
//滑动dialog进度条样式
protected Drawable mDialogProgressBarDrawable;

///状态监听
protected GSYStateUiListener mGSYStateUiListener;

//滤镜
protected GSYVideoGLView.ShaderInterface mEffectFilter = new NoEffect();

Expand Down Expand Up @@ -537,6 +541,7 @@ public GSYVideoOptionBuilder setEffectFilter(GSYVideoGLView.ShaderInterface effe

/**
* 是否需要覆盖拓展类型,目前只针对exoPlayer内核模式有效
*
* @param overrideExtension 比如传入 m3u8,mp4,avi 等类型
*/
public GSYVideoOptionBuilder setOverrideExtension(String overrideExtension) {
Expand Down Expand Up @@ -575,6 +580,14 @@ public GSYVideoOptionBuilder setFullHideStatusBar(boolean statusBar) {
return this;
}

/***
* 状态监听
*/
public GSYVideoOptionBuilder setGSYStateUiListener(GSYStateUiListener gsyStateUiListener) {
this.mGSYStateUiListener = gsyStateUiListener;
return this;
}

public void build(StandardGSYVideoPlayer gsyVideoPlayer) {
if (mBottomShowProgressDrawable != null && mBottomShowProgressThumbDrawable != null) {
gsyVideoPlayer.setBottomShowProgressBarDrawable(mBottomShowProgressDrawable, mBottomShowProgressThumbDrawable);
Expand Down Expand Up @@ -628,6 +641,9 @@ public void build(GSYBaseVideoPlayer gsyVideoPlayer) {
if (mGSYVideoProgressListener != null) {
gsyVideoPlayer.setGSYVideoProgressListener(mGSYVideoProgressListener);
}
if (mGSYStateUiListener != null) {
gsyVideoPlayer.setGSYStateUiListener(mGSYStateUiListener);
}
gsyVideoPlayer.setOverrideExtension(mOverrideExtension);
gsyVideoPlayer.setAutoFullWithSize(mAutoFullWithSize);
gsyVideoPlayer.setRotateViewAuto(mRotateViewAuto);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.shuyu.gsyvideoplayer.listener;

/**
* 状态变化监听
*/
public interface GSYStateUiListener {
void onStateChanged(int state);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.widget.TextView;

import com.shuyu.gsyvideoplayer.R;
import com.shuyu.gsyvideoplayer.listener.GSYStateUiListener;
import com.shuyu.gsyvideoplayer.listener.GSYVideoProgressListener;
import com.shuyu.gsyvideoplayer.listener.LockClickListener;
import com.shuyu.gsyvideoplayer.utils.CommonUtil;
Expand Down Expand Up @@ -173,6 +174,8 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
//点击锁屏的回调
protected LockClickListener mLockClickListener;

protected GSYStateUiListener mGsyStateUiListener;

protected GSYVideoProgressListener mGSYVideoProgressListener;

public GSYVideoControlView(@NonNull Context context) {
Expand Down Expand Up @@ -361,6 +364,9 @@ protected void setStateAndUi(int state) {
break;
}
resolveUIState(state);
if (mGsyStateUiListener != null) {
mGsyStateUiListener.onStateChanged(state);
}
}


Expand Down Expand Up @@ -1374,4 +1380,15 @@ public boolean isShowDragProgressTextOnSeekBar() {
public void setShowDragProgressTextOnSeekBar(boolean showDragProgressTextOnSeekBar) {
isShowDragProgressTextOnSeekBar = showDragProgressTextOnSeekBar;
}

/***
* 状态监听
*/
public GSYStateUiListener getGSYStateUiListener() {
return mGsyStateUiListener;
}

public void setGSYStateUiListener(GSYStateUiListener gsyStateUiListener) {
this.mGsyStateUiListener = gsyStateUiListener;
}
}

0 comments on commit e253dac

Please sign in to comment.