|
@@ -48,16 +48,17 @@ public class WindowPlayer extends AbsPlayer implements View.OnClickListener,
|
|
|
private ImageView mImageCover; // 封面图
|
|
|
private VolumeBrightnessProgressLayout mGestureVolumeBrightnessProgressLayout; // 音量亮度调节布局
|
|
|
private VideoProgressLayout mGestureVideoProgressLayout; // 手势快进提示布局
|
|
|
+
|
|
|
private GestureDetector mGestureDetector; // 手势检测监听器
|
|
|
private VideoGestureDetector mVideoGestureDetector; // 手势控制工具
|
|
|
+
|
|
|
private boolean isShowing; // 自身是否可见
|
|
|
private boolean mIsChangingSeekBarProgress; // 进度条是否正在拖动,避免SeekBar由于视频播放的update而跳动
|
|
|
- private SuperPlayerDef.PlayerType mPlayType = SuperPlayerDef.PlayerType.VOD; // 当前播放视频类型
|
|
|
+
|
|
|
private SuperPlayerDef.PlayerState mCurrentPlayState = SuperPlayerDef.PlayerState.END; // 当前播放状态
|
|
|
private long mDuration; // 视频总时长
|
|
|
- private long mLivePushDuration; // 直播推流总时长
|
|
|
private long mProgress; // 当前播放进度
|
|
|
- private Bitmap mBackgroundBmp; // 背景图
|
|
|
+
|
|
|
private long mLastClickTime; // 上次点击事件的时间
|
|
|
private boolean mIsOpenGesture = true; // 是否开启手势
|
|
|
private boolean isDestroy = false; // Activity 是否被销毁
|
|
@@ -155,17 +156,8 @@ public class WindowPlayer extends AbsPlayer implements View.OnClickListener,
|
|
|
|
|
|
float percentage = ((float) progress) / mBarProgress.getMax();
|
|
|
float currentTime = (mDuration * percentage);
|
|
|
- if (mPlayType == SuperPlayerDef.PlayerType.LIVE || mPlayType == SuperPlayerDef.PlayerType.LIVE_SHIFT) {
|
|
|
- if (mLivePushDuration > MAX_SHIFT_TIME) {
|
|
|
- currentTime = (int) (mLivePushDuration - MAX_SHIFT_TIME * (1 - percentage));
|
|
|
- } else {
|
|
|
- currentTime = mLivePushDuration * percentage;
|
|
|
- }
|
|
|
- mGestureVideoProgressLayout.setTimeText(formattedTime((long) currentTime));
|
|
|
- } else {
|
|
|
- mGestureVideoProgressLayout.setTimeText(formattedTime((long) currentTime) + " / " + formattedTime((long) mDuration));
|
|
|
- }
|
|
|
|
|
|
+ mGestureVideoProgressLayout.setTimeText(formattedTime((long) currentTime) + " / " + formattedTime((long) mDuration));
|
|
|
}
|
|
|
if (mBarProgress != null)
|
|
|
mBarProgress.setProgress(progress);
|
|
@@ -205,7 +197,6 @@ public class WindowPlayer extends AbsPlayer implements View.OnClickListener,
|
|
|
(VolumeBrightnessProgressLayout) findViewById(R.id.superplayer_gesture_progress);
|
|
|
|
|
|
mGestureVideoProgressLayout = (VideoProgressLayout) findViewById(R.id.superplayer_video_progress_layout);
|
|
|
- setBackground(mBackgroundBmp);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -271,7 +262,6 @@ public class WindowPlayer extends AbsPlayer implements View.OnClickListener,
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- mLivePushDuration = 0;
|
|
|
toggleView(mImageCover, true);
|
|
|
mIvPause.setImageResource(R.mipmap.play_state);
|
|
|
updateVideoProgress(0, superPlayerModel.duration);
|
|
@@ -286,13 +276,6 @@ public class WindowPlayer extends AbsPlayer implements View.OnClickListener,
|
|
|
public void show() {
|
|
|
isShowing = true;
|
|
|
mLayoutBottom.setVisibility(View.VISIBLE);
|
|
|
-
|
|
|
- if (mPlayType == SuperPlayerDef.PlayerType.LIVE_SHIFT) {
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void showOrHideBackBtn(boolean isShow) {
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -302,9 +285,6 @@ public class WindowPlayer extends AbsPlayer implements View.OnClickListener,
|
|
|
public void hide() {
|
|
|
isShowing = false;
|
|
|
mLayoutBottom.setVisibility(View.GONE);
|
|
|
-
|
|
|
- if (mPlayType == SuperPlayerDef.PlayerType.LIVE_SHIFT) {
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
public void toggleCoverView(boolean isVisible) {
|
|
@@ -372,21 +352,11 @@ public class WindowPlayer extends AbsPlayer implements View.OnClickListener,
|
|
|
if (mProgress == 0) {
|
|
|
percentage = 0;
|
|
|
}
|
|
|
- if (mPlayType == SuperPlayerDef.PlayerType.LIVE || mPlayType == SuperPlayerDef.PlayerType.LIVE_SHIFT) {
|
|
|
- mLivePushDuration = mLivePushDuration > mProgress ? mLivePushDuration : mProgress;
|
|
|
- long leftTime = mDuration - mProgress;
|
|
|
- mDuration = mDuration > MAX_SHIFT_TIME ? MAX_SHIFT_TIME : mDuration;
|
|
|
- percentage = 1 - (float) leftTime / (float) mDuration;
|
|
|
- }
|
|
|
|
|
|
if (percentage >= 0 && percentage <= 1) {
|
|
|
int progress = Math.round(percentage * mBarProgress.getMax());
|
|
|
if (!mIsChangingSeekBarProgress) {
|
|
|
- if (mPlayType == SuperPlayerDef.PlayerType.LIVE) {
|
|
|
- mBarProgress.setProgress(mBarProgress.getMax());
|
|
|
- } else {
|
|
|
- mBarProgress.setProgress(progress);
|
|
|
- }
|
|
|
+ mBarProgress.setProgress(progress);
|
|
|
}
|
|
|
mTvDuration.setText(formattedTime(mDuration));
|
|
|
}
|
|
@@ -399,7 +369,7 @@ public class WindowPlayer extends AbsPlayer implements View.OnClickListener,
|
|
|
*/
|
|
|
@Override
|
|
|
public void setBackground(final Bitmap bitmap) {
|
|
|
-
|
|
|
+ mImageCover.setImageBitmap(bitmap);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -407,7 +377,7 @@ public class WindowPlayer extends AbsPlayer implements View.OnClickListener,
|
|
|
*/
|
|
|
@Override
|
|
|
public void showBackground() {
|
|
|
-
|
|
|
+ mImageCover.setVisibility(VISIBLE);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -448,17 +418,9 @@ public class WindowPlayer extends AbsPlayer implements View.OnClickListener,
|
|
|
}
|
|
|
mBarProgress.setProgress(progress);
|
|
|
|
|
|
- int seekTime;
|
|
|
float percentage = progress * 1.0f / mBarProgress.getMax();
|
|
|
- if (mPlayType == SuperPlayerDef.PlayerType.LIVE || mPlayType == SuperPlayerDef.PlayerType.LIVE_SHIFT) {
|
|
|
- if (mLivePushDuration > MAX_SHIFT_TIME) {
|
|
|
- seekTime = (int) (mLivePushDuration - MAX_SHIFT_TIME * (1 - percentage));
|
|
|
- } else {
|
|
|
- seekTime = (int) (mLivePushDuration * percentage);
|
|
|
- }
|
|
|
- } else {
|
|
|
- seekTime = (int) (percentage * mDuration);
|
|
|
- }
|
|
|
+ int seekTime = (int) (percentage * mDuration);
|
|
|
+
|
|
|
if (mControllerCallback != null) {
|
|
|
mControllerCallback.onSeekTo(seekTime);
|
|
|
}
|
|
@@ -507,16 +469,8 @@ public class WindowPlayer extends AbsPlayer implements View.OnClickListener,
|
|
|
mGestureVideoProgressLayout.show();
|
|
|
float percentage = ((float) progress) / progressBar.getMax();
|
|
|
float currentTime = (mDuration * percentage);
|
|
|
- if (mPlayType == SuperPlayerDef.PlayerType.LIVE || mPlayType == SuperPlayerDef.PlayerType.LIVE_SHIFT) {
|
|
|
- if (mLivePushDuration > MAX_SHIFT_TIME) {
|
|
|
- currentTime = (int) (mLivePushDuration - MAX_SHIFT_TIME * (1 - percentage));
|
|
|
- } else {
|
|
|
- currentTime = mLivePushDuration * percentage;
|
|
|
- }
|
|
|
- mGestureVideoProgressLayout.setTimeText(formattedTime((long) currentTime));
|
|
|
- } else {
|
|
|
- mGestureVideoProgressLayout.setTimeText(formattedTime((long) currentTime) + " / " + formattedTime((long) mDuration));
|
|
|
- }
|
|
|
+
|
|
|
+ mGestureVideoProgressLayout.setTimeText(formattedTime((long) currentTime) + " / " + formattedTime((long) mDuration));
|
|
|
mGestureVideoProgressLayout.setProgress(progress);
|
|
|
}
|
|
|
}
|
|
@@ -531,28 +485,13 @@ public class WindowPlayer extends AbsPlayer implements View.OnClickListener,
|
|
|
int curProgress = progressBar.getProgress();
|
|
|
int maxProgress = progressBar.getMax();
|
|
|
|
|
|
- switch (mPlayType) {
|
|
|
- case VOD:
|
|
|
- if (curProgress >= 0 && curProgress <= maxProgress) {
|
|
|
- float percentage = ((float) curProgress) / maxProgress;
|
|
|
- int position = (int) (mDuration * percentage);
|
|
|
+ if (curProgress >= 0 && curProgress <= maxProgress) {
|
|
|
+ float percentage = ((float) curProgress) / maxProgress;
|
|
|
+ int position = (int) (mDuration * percentage);
|
|
|
|
|
|
- if (mControllerCallback != null) {
|
|
|
- mControllerCallback.onSeekTo(position);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case LIVE:
|
|
|
- case LIVE_SHIFT:
|
|
|
- toggleView(mPbLiveLoading, true);
|
|
|
- int seekTime = (int) (mLivePushDuration * curProgress * 1.0f / maxProgress);
|
|
|
- if (mLivePushDuration > MAX_SHIFT_TIME) {
|
|
|
- seekTime = (int) (mLivePushDuration - MAX_SHIFT_TIME * (maxProgress - curProgress) * 1.0f / maxProgress);
|
|
|
- }
|
|
|
- if (mControllerCallback != null) {
|
|
|
- mControllerCallback.onSeekTo(seekTime);
|
|
|
- }
|
|
|
- break;
|
|
|
+ if (mControllerCallback != null) {
|
|
|
+ mControllerCallback.onSeekTo(position);
|
|
|
+ }
|
|
|
}
|
|
|
postDelayed(mHideViewRunnable, HIDDEN_DELAY);
|
|
|
}
|