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 df9bb414f802db5cc2f6d29e670fd953303902c9..7bd8bf5cbfca4e82a300921d65cb1eda5a9cbfd4 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 @@ -3,6 +3,7 @@ package com.shuyu.gsyvideoplayer.builder; 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; @@ -160,6 +161,9 @@ public class GSYVideoOptionBuilder { //滑动dialog进度条样式 protected Drawable mDialogProgressBarDrawable; + ///状态监听 + protected GSYStateUiListener mGSYStateUiListener; + //滤镜 protected GSYVideoGLView.ShaderInterface mEffectFilter = new NoEffect(); @@ -537,6 +541,7 @@ public class GSYVideoOptionBuilder { /** * 是否需要覆盖拓展类型,目前只针对exoPlayer内核模式有效 + * * @param overrideExtension 比如传入 m3u8,mp4,avi 等类型 */ public GSYVideoOptionBuilder setOverrideExtension(String overrideExtension) { @@ -575,6 +580,14 @@ public class GSYVideoOptionBuilder { 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); @@ -628,6 +641,9 @@ public class GSYVideoOptionBuilder { if (mGSYVideoProgressListener != null) { gsyVideoPlayer.setGSYVideoProgressListener(mGSYVideoProgressListener); } + if (mGSYStateUiListener != null) { + gsyVideoPlayer.setGSYStateUiListener(mGSYStateUiListener); + } gsyVideoPlayer.setOverrideExtension(mOverrideExtension); gsyVideoPlayer.setAutoFullWithSize(mAutoFullWithSize); gsyVideoPlayer.setRotateViewAuto(mRotateViewAuto); diff --git a/gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/listener/GSYStateUiListener.java b/gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/listener/GSYStateUiListener.java new file mode 100644 index 0000000000000000000000000000000000000000..1d3ceea868ea07e446e851ea7b60c8dd5b09da0c --- /dev/null +++ b/gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/listener/GSYStateUiListener.java @@ -0,0 +1,8 @@ +package com.shuyu.gsyvideoplayer.listener; + +/** + * 状态变化监听 + */ +public interface GSYStateUiListener { + void onStateChanged(int state); +} 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 43b771d879d3e33579280387cdb1397a6e35518b..2c864e555c7ba10112293eb4c37b9687e93fb2b5 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 @@ -25,6 +25,7 @@ import android.widget.SeekBar; 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; @@ -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) { @@ -361,6 +364,9 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O break; } resolveUIState(state); + if (mGsyStateUiListener != null) { + mGsyStateUiListener.onStateChanged(state); + } } @@ -1374,4 +1380,15 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O public void setShowDragProgressTextOnSeekBar(boolean showDragProgressTextOnSeekBar) { isShowDragProgressTextOnSeekBar = showDragProgressTextOnSeekBar; } + + /*** + * 状态监听 + */ + public GSYStateUiListener getGSYStateUiListener() { + return mGsyStateUiListener; + } + + public void setGSYStateUiListener(GSYStateUiListener gsyStateUiListener) { + this.mGsyStateUiListener = gsyStateUiListener; + } }