package com.shuyu.gsyvideoplayer.video; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.shuyu.gsyvideoplayer.R; import com.shuyu.gsyvideoplayer.listener.GSYVideoShotListener; import com.shuyu.gsyvideoplayer.listener.GSYVideoShotSaveListener; import com.shuyu.gsyvideoplayer.utils.Debuger; import com.shuyu.gsyvideoplayer.utils.NetworkUtils; import com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer; import com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer; import java.io.File; import moe.codeest.enviews.ENDownloadView; import moe.codeest.enviews.ENPlayView; /** * 标准播放器,继承之后实现一些ui显示效果,如显示/隐藏ui,播放按键等 * Created by shuyu on 2016/11/11. */ public class StandardGSYVideoPlayer extends GSYVideoPlayer { //亮度dialog protected Dialog mBrightnessDialog; //音量dialog protected Dialog mVolumeDialog; //触摸进度dialog protected Dialog mProgressDialog; //触摸进度条的progress protected ProgressBar mDialogProgressBar; //音量进度条的progress protected ProgressBar mDialogVolumeProgressBar; //亮度文本 protected TextView mBrightnessDialogTv; //触摸移动显示文本 protected TextView mDialogSeekTime; //触摸移动显示全部时间 protected TextView mDialogTotalTime; //触摸移动方向icon protected ImageView mDialogIcon; protected Drawable mBottomProgressDrawable; protected Drawable mBottomShowProgressDrawable; protected Drawable mBottomShowProgressThumbDrawable; protected Drawable mVolumeProgressDrawable; protected Drawable mDialogProgressBarDrawable; protected int mDialogProgressHighLightColor = -11; protected int mDialogProgressNormalColor = -11; /** * 1.5.0开始加入,如果需要不同布局区分功能,需要重载 */ public StandardGSYVideoPlayer(Context context, Boolean fullFlag) { super(context, fullFlag); } public StandardGSYVideoPlayer(Context context) { super(context); } public StandardGSYVideoPlayer(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void init(Context context) { super.init(context); //增加自定义ui if (mBottomProgressDrawable != null) { mBottomProgressBar.setProgressDrawable(mBottomProgressDrawable); } if (mBottomShowProgressDrawable != null) { mProgressBar.setProgressDrawable(mBottomProgressDrawable); } if (mBottomShowProgressThumbDrawable != null) { mProgressBar.setThumb(mBottomShowProgressThumbDrawable); } } /** * 继承后重写可替换为你需要的布局 * * @return */ @Override public int getLayoutId() { return R.layout.video_layout_standard; } /** * 显示wifi确定框 */ @Override public void startPlayLogic() { if (mVideoAllCallBack != null) { Debuger.printfLog("onClickStartThumb"); mVideoAllCallBack.onClickStartThumb(mOriginUrl, mTitle, StandardGSYVideoPlayer.this); } prepareVideo(); startDismissControlViewTimer(); } /** * 显示wifi确定框,如需要自定义继承重写即可 */ @Override protected void showWifiDialog() { if (!NetworkUtils.isAvailable(mContext)) { //Toast.makeText(mContext, getResources().getString(R.string.no_net), Toast.LENGTH_LONG).show(); startPlayLogic(); return; } AlertDialog.Builder builder = new AlertDialog.Builder(getActivityContext()); builder.setMessage(getResources().getString(R.string.tips_not_wifi)); builder.setPositiveButton(getResources().getString(R.string.tips_not_wifi_confirm), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); startPlayLogic(); } }); builder.setNegativeButton(getResources().getString(R.string.tips_not_wifi_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); } /** * 触摸显示滑动进度dialog,如需要自定义继承重写即可,记得重写dismissProgressDialog */ @Override @SuppressWarnings("ResourceType") protected void showProgressDialog(float deltaX, String seekTime, int seekTimePosition, String totalTime, int totalTimeDuration) { if (mProgressDialog == null) { View localView = LayoutInflater.from(getActivityContext()).inflate(getProgressDialogLayoutId(), null); if (localView.findViewById(getProgressDialogProgressId()) instanceof ProgressBar) { mDialogProgressBar = ((ProgressBar) localView.findViewById(getProgressDialogProgressId())); if (mDialogProgressBarDrawable != null) { mDialogProgressBar.setProgressDrawable(mDialogProgressBarDrawable); } } if (localView.findViewById(getProgressDialogCurrentDurationTextId()) instanceof TextView) { mDialogSeekTime = ((TextView) localView.findViewById(getProgressDialogCurrentDurationTextId())); } if (localView.findViewById(getProgressDialogAllDurationTextId()) instanceof TextView) { mDialogTotalTime = ((TextView) localView.findViewById(getProgressDialogAllDurationTextId())); } if (localView.findViewById(getProgressDialogImageId()) instanceof ImageView) { mDialogIcon = ((ImageView) localView.findViewById(getProgressDialogImageId())); } mProgressDialog = new Dialog(getActivityContext(), R.style.video_style_dialog_progress); mProgressDialog.setContentView(localView); mProgressDialog.getWindow().addFlags(Window.FEATURE_ACTION_BAR); mProgressDialog.getWindow().addFlags(32); mProgressDialog.getWindow().addFlags(16); mProgressDialog.getWindow().setLayout(getWidth(), getHeight()); if (mDialogProgressNormalColor != -11 && mDialogTotalTime != null) { mDialogTotalTime.setTextColor(mDialogProgressNormalColor); } if (mDialogProgressHighLightColor != -11 && mDialogSeekTime != null) { mDialogSeekTime.setTextColor(mDialogProgressHighLightColor); } WindowManager.LayoutParams localLayoutParams = mProgressDialog.getWindow().getAttributes(); localLayoutParams.gravity = Gravity.TOP; localLayoutParams.width = getWidth(); localLayoutParams.height = getHeight(); int location[] = new int[2]; getLocationOnScreen(location); localLayoutParams.x = location[0]; localLayoutParams.y = location[1]; mProgressDialog.getWindow().setAttributes(localLayoutParams); } if (!mProgressDialog.isShowing()) { mProgressDialog.show(); } if (mDialogSeekTime != null) { mDialogSeekTime.setText(seekTime); } if (mDialogTotalTime != null) { mDialogTotalTime.setText(" / " + totalTime); } if (totalTimeDuration > 0) if (mDialogProgressBar != null) { mDialogProgressBar.setProgress(seekTimePosition * 100 / totalTimeDuration); } if (deltaX > 0) { if (mDialogIcon != null) { mDialogIcon.setBackgroundResource(R.drawable.video_forward_icon); } } else { if (mDialogIcon != null) { mDialogIcon.setBackgroundResource(R.drawable.video_backward_icon); } } } @Override protected void dismissProgressDialog() { if (mProgressDialog != null) { mProgressDialog.dismiss(); mProgressDialog = null; } } /** * 触摸音量dialog,如需要自定义继承重写即可,记得重写dismissVolumeDialog */ @Override protected void showVolumeDialog(float deltaY, int volumePercent) { if (mVolumeDialog == null) { View localView = LayoutInflater.from(getActivityContext()).inflate(getVolumeLayoutId(), null); if (localView.findViewById(getVolumeProgressId()) instanceof ProgressBar) { mDialogVolumeProgressBar = ((ProgressBar) localView.findViewById(getVolumeProgressId())); if (mVolumeProgressDrawable != null && mDialogVolumeProgressBar != null) { mDialogVolumeProgressBar.setProgressDrawable(mVolumeProgressDrawable); } } mVolumeDialog = new Dialog(getActivityContext(), R.style.video_style_dialog_progress); mVolumeDialog.setContentView(localView); mVolumeDialog.getWindow().addFlags(8); mVolumeDialog.getWindow().addFlags(32); mVolumeDialog.getWindow().addFlags(16); mVolumeDialog.getWindow().setLayout(-2, -2); WindowManager.LayoutParams localLayoutParams = mVolumeDialog.getWindow().getAttributes(); localLayoutParams.gravity = Gravity.TOP | Gravity.LEFT; localLayoutParams.width = getWidth(); localLayoutParams.height = getHeight(); int location[] = new int[2]; getLocationOnScreen(location); localLayoutParams.x = location[0]; localLayoutParams.y = location[1]; mVolumeDialog.getWindow().setAttributes(localLayoutParams); } if (!mVolumeDialog.isShowing()) { mVolumeDialog.show(); } if (mDialogVolumeProgressBar != null) { mDialogVolumeProgressBar.setProgress(volumePercent); } } @Override protected void dismissVolumeDialog() { if (mVolumeDialog != null) { mVolumeDialog.dismiss(); mVolumeDialog = null; } } /** * 触摸亮度dialog,如需要自定义继承重写即可,记得重写dismissBrightnessDialog */ @Override protected void showBrightnessDialog(float percent) { if (mBrightnessDialog == null) { View localView = LayoutInflater.from(getActivityContext()).inflate(getBrightnessLayoutId(), null); if (localView.findViewById(getBrightnessTextId()) instanceof TextView) { mBrightnessDialogTv = (TextView) localView.findViewById(getBrightnessTextId()); } mBrightnessDialog = new Dialog(getActivityContext(), R.style.video_style_dialog_progress); mBrightnessDialog.setContentView(localView); mBrightnessDialog.getWindow().addFlags(8); mBrightnessDialog.getWindow().addFlags(32); mBrightnessDialog.getWindow().addFlags(16); mBrightnessDialog.getWindow().setLayout(-2, -2); WindowManager.LayoutParams localLayoutParams = mBrightnessDialog.getWindow().getAttributes(); localLayoutParams.gravity = Gravity.TOP | Gravity.RIGHT; localLayoutParams.width = getWidth(); localLayoutParams.height = getHeight(); int location[] = new int[2]; getLocationOnScreen(location); localLayoutParams.x = location[0]; localLayoutParams.y = location[1]; mBrightnessDialog.getWindow().setAttributes(localLayoutParams); } if (!mBrightnessDialog.isShowing()) { mBrightnessDialog.show(); } if (mBrightnessDialogTv != null) mBrightnessDialogTv.setText((int) (percent * 100) + "%"); } @Override protected void dismissBrightnessDialog() { if (mBrightnessDialog != null) { mBrightnessDialog.dismiss(); mBrightnessDialog = null; } } @Override protected void cloneParams(GSYBaseVideoPlayer from, GSYBaseVideoPlayer to) { super.cloneParams(from, to); StandardGSYVideoPlayer sf = (StandardGSYVideoPlayer) from; StandardGSYVideoPlayer st = (StandardGSYVideoPlayer) to; if (st.mProgressBar != null && sf.mProgressBar != null) { st.mProgressBar.setProgress(sf.mProgressBar.getProgress()); st.mProgressBar.setSecondaryProgress(sf.mProgressBar.getSecondaryProgress()); } if (st.mTotalTimeTextView != null && sf.mTotalTimeTextView != null) { st.mTotalTimeTextView.setText(sf.mTotalTimeTextView.getText()); } if (st.mCurrentTimeTextView != null && sf.mCurrentTimeTextView != null) { st.mCurrentTimeTextView.setText(sf.mCurrentTimeTextView.getText()); } } /** * 将自定义的效果也设置到全屏 * * @param context * @param actionBar 是否有actionBar,有的话需要隐藏 * @param statusBar 是否有状态bar,有的话需要隐藏 * @return */ @Override public GSYBaseVideoPlayer startWindowFullscreen(Context context, boolean actionBar, boolean statusBar) { GSYBaseVideoPlayer gsyBaseVideoPlayer = super.startWindowFullscreen(context, actionBar, statusBar); if (gsyBaseVideoPlayer != null) { StandardGSYVideoPlayer gsyVideoPlayer = (StandardGSYVideoPlayer) gsyBaseVideoPlayer; gsyVideoPlayer.setLockClickListener(mLockClickListener); gsyVideoPlayer.setNeedLockFull(isNeedLockFull()); initFullUI(gsyVideoPlayer); //比如你自定义了返回案件,但是因为返回按键底层已经设置了返回事件,所以你需要在这里重新增加的逻辑 } return gsyBaseVideoPlayer; } /********************************各类UI的状态显示*********************************************/ /** * 点击触摸显示和隐藏逻辑 */ @Override protected void onClickUiToggle() { if (mIfCurrentIsFullscreen && mLockCurScreen && mNeedLockFull) { setViewShowState(mLockScreen, VISIBLE); return; } if (mCurrentState == CURRENT_STATE_PREPAREING) { if (mBottomContainer != null) { if (mBottomContainer.getVisibility() == View.VISIBLE) { changeUiToPrepareingClear(); } else { changeUiToPreparingShow(); } } } else if (mCurrentState == CURRENT_STATE_PLAYING) { if (mBottomContainer != null) { if (mBottomContainer.getVisibility() == View.VISIBLE) { changeUiToPlayingClear(); } else { changeUiToPlayingShow(); } } } else if (mCurrentState == CURRENT_STATE_PAUSE) { if (mBottomContainer != null) { if (mBottomContainer.getVisibility() == View.VISIBLE) { changeUiToPauseClear(); } else { changeUiToPauseShow(); } } } else if (mCurrentState == CURRENT_STATE_AUTO_COMPLETE) { if (mBottomContainer != null) { if (mBottomContainer.getVisibility() == View.VISIBLE) { changeUiToCompleteClear(); } else { changeUiToCompleteShow(); } } } else if (mCurrentState == CURRENT_STATE_PLAYING_BUFFERING_START) { if (mBottomContainer != null) { if (mBottomContainer.getVisibility() == View.VISIBLE) { changeUiToPlayingBufferingClear(); } else { changeUiToPlayingBufferingShow(); } } } } @Override protected void hideAllWidget() { setViewShowState(mBottomContainer, INVISIBLE); setViewShowState(mTopContainer, INVISIBLE); setViewShowState(mBottomProgressBar, VISIBLE); setViewShowState(mStartButton, INVISIBLE); } @Override protected void changeUiToNormal() { Debuger.printfLog("changeUiToNormal"); setViewShowState(mTopContainer, VISIBLE); setViewShowState(mBottomContainer, INVISIBLE); setViewShowState(mStartButton, VISIBLE); setViewShowState(mLoadingProgressBar, INVISIBLE); setViewShowState(mThumbImageViewLayout, VISIBLE); setViewShowState(mBottomProgressBar, INVISIBLE); setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? VISIBLE : GONE); updateStartImage(); if (mLoadingProgressBar instanceof ENDownloadView) { ((ENDownloadView) mLoadingProgressBar).reset(); } } @Override protected void changeUiToPreparingShow() { Debuger.printfLog("changeUiToPreparingShow"); setViewShowState(mTopContainer, VISIBLE); setViewShowState(mBottomContainer, VISIBLE); setViewShowState(mStartButton, INVISIBLE); setViewShowState(mLoadingProgressBar, VISIBLE); setViewShowState(mThumbImageViewLayout, INVISIBLE); setViewShowState(mBottomProgressBar, INVISIBLE); setViewShowState(mLockScreen, GONE); if (mLoadingProgressBar instanceof ENDownloadView) { ENDownloadView enDownloadView = (ENDownloadView) mLoadingProgressBar; if (enDownloadView.getCurrentState() == ENDownloadView.STATE_PRE) { ((ENDownloadView) mLoadingProgressBar).start(); } } } @Override protected void changeUiToPlayingShow() { Debuger.printfLog("changeUiToPlayingShow"); setViewShowState(mTopContainer, VISIBLE); setViewShowState(mBottomContainer, VISIBLE); setViewShowState(mStartButton, VISIBLE); setViewShowState(mLoadingProgressBar, INVISIBLE); setViewShowState(mThumbImageViewLayout, INVISIBLE); setViewShowState(mBottomProgressBar, INVISIBLE); setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? VISIBLE : GONE); if (mLoadingProgressBar instanceof ENDownloadView) { ((ENDownloadView) mLoadingProgressBar).reset(); } updateStartImage(); } @Override protected void changeUiToPauseShow() { Debuger.printfLog("changeUiToPauseShow"); setViewShowState(mTopContainer, VISIBLE); setViewShowState(mBottomContainer, VISIBLE); setViewShowState(mStartButton, VISIBLE); setViewShowState(mLoadingProgressBar, INVISIBLE); setViewShowState(mThumbImageViewLayout, INVISIBLE); setViewShowState(mBottomProgressBar, INVISIBLE); setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? VISIBLE : GONE); if (mLoadingProgressBar instanceof ENDownloadView) { ((ENDownloadView) mLoadingProgressBar).reset(); } updateStartImage(); updatePauseCover(); } @Override protected void changeUiToPlayingBufferingShow() { Debuger.printfLog("changeUiToPlayingBufferingShow"); setViewShowState(mTopContainer, VISIBLE); setViewShowState(mBottomContainer, VISIBLE); setViewShowState(mStartButton, INVISIBLE); setViewShowState(mLoadingProgressBar, VISIBLE); setViewShowState(mThumbImageViewLayout, INVISIBLE); setViewShowState(mBottomProgressBar, INVISIBLE); setViewShowState(mLockScreen, GONE); if (mLoadingProgressBar instanceof ENDownloadView) { ENDownloadView enDownloadView = (ENDownloadView) mLoadingProgressBar; if (enDownloadView.getCurrentState() == ENDownloadView.STATE_PRE) { ((ENDownloadView) mLoadingProgressBar).start(); } } } @Override protected void changeUiToCompleteShow() { Debuger.printfLog("changeUiToCompleteShow"); setViewShowState(mTopContainer, VISIBLE); setViewShowState(mBottomContainer, VISIBLE); setViewShowState(mStartButton, VISIBLE); setViewShowState(mLoadingProgressBar, INVISIBLE); setViewShowState(mThumbImageViewLayout, VISIBLE); setViewShowState(mBottomProgressBar, INVISIBLE); setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? VISIBLE : GONE); if (mLoadingProgressBar instanceof ENDownloadView) { ((ENDownloadView) mLoadingProgressBar).reset(); } updateStartImage(); } @Override protected void changeUiToError() { Debuger.printfLog("changeUiToError"); setViewShowState(mTopContainer, INVISIBLE); setViewShowState(mBottomContainer, INVISIBLE); setViewShowState(mStartButton, VISIBLE); setViewShowState(mLoadingProgressBar, INVISIBLE); setViewShowState(mThumbImageViewLayout, INVISIBLE); setViewShowState(mBottomProgressBar, INVISIBLE); setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? VISIBLE : GONE); if (mLoadingProgressBar instanceof ENDownloadView) { ((ENDownloadView) mLoadingProgressBar).reset(); } updateStartImage(); } /** * 触摸进度dialog的layoutId * 继承后重写可返回自定义 * 有自定义的实现逻辑可重载showProgressDialog方法 */ protected int getProgressDialogLayoutId() { return R.layout.video_progress_dialog; } /** * 触摸进度dialog的进度条id * 继承后重写可返回自定义,如果没有可返回空 * 有自定义的实现逻辑可重载showProgressDialog方法 */ protected int getProgressDialogProgressId() { return R.id.duration_progressbar; } /** * 触摸进度dialog的当前时间文本 * 继承后重写可返回自定义,如果没有可返回空 * 有自定义的实现逻辑可重载showProgressDialog方法 */ protected int getProgressDialogCurrentDurationTextId() { return R.id.tv_current; } /** * 触摸进度dialog全部时间文本 * 继承后重写可返回自定义,如果没有可返回空 * 有自定义的实现逻辑可重载showProgressDialog方法 */ protected int getProgressDialogAllDurationTextId() { return R.id.tv_duration; } /** * 触摸进度dialog的图片id * 继承后重写可返回自定义,如果没有可返回空 * 有自定义的实现逻辑可重载showProgressDialog方法 */ protected int getProgressDialogImageId() { return R.id.duration_image_tip; } /** * 音量dialog的layoutId * 继承后重写可返回自定义 * 有自定义的实现逻辑可重载showVolumeDialog方法 */ protected int getVolumeLayoutId() { return R.layout.video_volume_dialog; } /** * 音量dialog的百分比进度条 id * 继承后重写可返回自定义,如果没有可返回空 * 有自定义的实现逻辑可重载showVolumeDialog方法 */ protected int getVolumeProgressId() { return R.id.volume_progressbar; } /** * 亮度dialog的layoutId * 继承后重写可返回自定义 * 有自定义的实现逻辑可重载showBrightnessDialog方法 */ protected int getBrightnessLayoutId() { return R.layout.video_brightness; } /** * 亮度dialog的百分比text id * 继承后重写可返回自定义,如果没有可返回空 * 有自定义的实现逻辑可重载showBrightnessDialog方法 */ protected int getBrightnessTextId() { return R.id.app_video_brightness; } protected void changeUiToPrepareingClear() { Debuger.printfLog("changeUiToPrepareingClear"); setViewShowState(mTopContainer, INVISIBLE); setViewShowState(mBottomContainer, INVISIBLE); setViewShowState(mStartButton, INVISIBLE); setViewShowState(mLoadingProgressBar, INVISIBLE); setViewShowState(mThumbImageViewLayout, INVISIBLE); setViewShowState(mBottomProgressBar, INVISIBLE); setViewShowState(mLockScreen, GONE); if (mLoadingProgressBar instanceof ENDownloadView) { ((ENDownloadView) mLoadingProgressBar).reset(); } } protected void changeUiToPlayingClear() { Debuger.printfLog("changeUiToPlayingClear"); changeUiToClear(); setViewShowState(mBottomProgressBar, VISIBLE); } protected void changeUiToPauseClear() { Debuger.printfLog("changeUiToPauseClear"); changeUiToClear(); setViewShowState(mBottomProgressBar, VISIBLE); updatePauseCover(); } protected void changeUiToPlayingBufferingClear() { Debuger.printfLog("changeUiToPlayingBufferingClear"); setViewShowState(mTopContainer, INVISIBLE); setViewShowState(mBottomContainer, INVISIBLE); setViewShowState(mStartButton, INVISIBLE); setViewShowState(mLoadingProgressBar, VISIBLE); setViewShowState(mThumbImageViewLayout, INVISIBLE); setViewShowState(mBottomProgressBar, VISIBLE); setViewShowState(mLockScreen, GONE); if (mLoadingProgressBar instanceof ENDownloadView) { ENDownloadView enDownloadView = (ENDownloadView) mLoadingProgressBar; if (enDownloadView.getCurrentState() == ENDownloadView.STATE_PRE) { ((ENDownloadView) mLoadingProgressBar).start(); } } updateStartImage(); } protected void changeUiToClear() { Debuger.printfLog("changeUiToClear"); setViewShowState(mTopContainer, INVISIBLE); setViewShowState(mBottomContainer, INVISIBLE); setViewShowState(mStartButton, INVISIBLE); setViewShowState(mLoadingProgressBar, INVISIBLE); setViewShowState(mThumbImageViewLayout, INVISIBLE); setViewShowState(mBottomProgressBar, INVISIBLE); setViewShowState(mLockScreen, GONE); if (mLoadingProgressBar instanceof ENDownloadView) { ((ENDownloadView) mLoadingProgressBar).reset(); } } protected void changeUiToCompleteClear() { Debuger.printfLog("changeUiToCompleteClear"); setViewShowState(mTopContainer, INVISIBLE); setViewShowState(mBottomContainer, INVISIBLE); setViewShowState(mStartButton, VISIBLE); setViewShowState(mLoadingProgressBar, INVISIBLE); setViewShowState(mThumbImageViewLayout, VISIBLE); setViewShowState(mBottomProgressBar, VISIBLE); setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? VISIBLE : GONE); if (mLoadingProgressBar instanceof ENDownloadView) { ((ENDownloadView) mLoadingProgressBar).reset(); } updateStartImage(); } /** * 定义开始按键显示 */ protected void updateStartImage() { if (mStartButton instanceof ENPlayView) { ENPlayView enPlayView = (ENPlayView) mStartButton; enPlayView.setDuration(500); if (mCurrentState == CURRENT_STATE_PLAYING) { enPlayView.play(); } else if (mCurrentState == CURRENT_STATE_ERROR) { enPlayView.pause(); } else { enPlayView.pause(); } } else if (mStartButton instanceof ImageView) { ImageView imageView = (ImageView) mStartButton; if (mCurrentState == CURRENT_STATE_PLAYING) { imageView.setImageResource(R.drawable.video_click_pause_selector); } else if (mCurrentState == CURRENT_STATE_ERROR) { imageView.setImageResource(R.drawable.video_click_error_selector); } else { imageView.setImageResource(R.drawable.video_click_play_selector); } } } /** * 全屏的UI逻辑 */ private void initFullUI(StandardGSYVideoPlayer standardGSYVideoPlayer) { if (mBottomProgressDrawable != null) { standardGSYVideoPlayer.setBottomProgressBarDrawable(mBottomProgressDrawable); } if (mBottomShowProgressDrawable != null && mBottomShowProgressThumbDrawable != null) { standardGSYVideoPlayer.setBottomShowProgressBarDrawable(mBottomShowProgressDrawable, mBottomShowProgressThumbDrawable); } if (mVolumeProgressDrawable != null) { standardGSYVideoPlayer.setDialogVolumeProgressBar(mVolumeProgressDrawable); } if (mDialogProgressBarDrawable != null) { standardGSYVideoPlayer.setDialogProgressBar(mDialogProgressBarDrawable); } if (mDialogProgressHighLightColor >= 0 && mDialogProgressNormalColor >= 0) { standardGSYVideoPlayer.setDialogProgressColor(mDialogProgressHighLightColor, mDialogProgressNormalColor); } } /** * 底部进度条-弹出的 */ public void setBottomShowProgressBarDrawable(Drawable drawable, Drawable thumb) { mBottomShowProgressDrawable = drawable; mBottomShowProgressThumbDrawable = thumb; if (mProgressBar != null) { mProgressBar.setProgressDrawable(drawable); mProgressBar.setThumb(thumb); } } /** * 底部进度条-非弹出 */ public void setBottomProgressBarDrawable(Drawable drawable) { mBottomProgressDrawable = drawable; if (mBottomProgressBar != null) { mBottomProgressBar.setProgressDrawable(drawable); } } /** * 声音进度条 */ public void setDialogVolumeProgressBar(Drawable drawable) { mVolumeProgressDrawable = drawable; } /** * 中间进度条 */ public void setDialogProgressBar(Drawable drawable) { mDialogProgressBarDrawable = drawable; } /** * 中间进度条字体颜色 */ public void setDialogProgressColor(int highLightColor, int normalColor) { mDialogProgressHighLightColor = highLightColor; mDialogProgressNormalColor = normalColor; } /************************************* 关于截图的 ****************************************/ /** * 获取截图 */ public void taskShotPic(GSYVideoShotListener gsyVideoShotListener) { this.taskShotPic(gsyVideoShotListener, false); } /** * 获取截图 * * @param high 是否需要高清的 */ public void taskShotPic(GSYVideoShotListener gsyVideoShotListener, boolean high) { if (getCurrentPlayer().getRenderProxy() != null) { getCurrentPlayer().getRenderProxy().taskShotPic(gsyVideoShotListener, high); } } /** * 保存截图 */ public void saveFrame(final File file, GSYVideoShotSaveListener gsyVideoShotSaveListener) { saveFrame(file, false, gsyVideoShotSaveListener); } /** * 保存截图 * * @param high 是否需要高清的 */ public void saveFrame(final File file, final boolean high, final GSYVideoShotSaveListener gsyVideoShotSaveListener) { if (getCurrentPlayer().getRenderProxy() != null) { getCurrentPlayer().getRenderProxy().saveFrame(file, high, gsyVideoShotSaveListener); } } /** * 重新开启进度查询以及控制view消失的定时任务 * 用于解决GSYVideoHelper中通过removeview方式做全屏切换导致的定时任务停止的问题 * GSYVideoControlView onDetachedFromWindow() */ public void restartTimerTask() { startProgressTimer(); startDismissControlViewTimer(); } }