zhaoyadi 2 vuotta sitten
vanhempi
commit
158d2c35a9

+ 2 - 0
.idea/misc.xml

@@ -26,7 +26,9 @@
         <entry key="..\:/demo/.android/Player_Android/Demo/kit/src/main/res/layout/superplayer_video_progress_layout.xml" value="0.115625" />
         <entry key="..\:/demo/.android/Player_Android/Demo/kit/src/main/res/layout/superplayer_video_volume_brightness_progress_layout.xml" value="0.22370218579234974" />
         <entry key="..\:/demo/.android/Player_Android/Demo/kit/src/main/res/layout/superplayer_vod_player_fullscreen.xml" value="0.12578125" />
+        <entry key="..\:/demo/.android/Player_Android/Demo/kit/src/main/res/layout/superplayer_vod_player_timeout.xml" value="0.1443850267379679" />
         <entry key="..\:/demo/.android/Player_Android/Demo/kit/src/main/res/layout/superplayer_vod_player_window.xml" value="0.12578125" />
+        <entry key="..\:/demo/.android/Player_Android/Demo/kit/src/main/res/layout/superplayer_vod_view.xml" value="0.1" />
         <entry key="..\:/demo/.android/Player_Android/Demo/superplayerdemo/src/main/res/drawable/player_short_video_time.xml" value="0.2535" />
         <entry key="..\:/demo/.android/Player_Android/Demo/superplayerdemo/src/main/res/drawable/player_thumb_view.xml" value="0.2535" />
         <entry key="..\:/demo/.android/Player_Android/Demo/superplayerdemo/src/main/res/drawable/player_video_seek_bar.xml" value="0.2535" />

+ 4 - 0
kit/src/main/java/com/tencent/liteav/demo/superplayer/ui/player/AbsPlayer.java

@@ -51,6 +51,10 @@ public abstract class AbsPlayer extends RelativeLayout implements Player {
 
     }
 
+    public void timeOut(){
+
+    }
+
     @Override
     public void release() {
 

+ 0 - 3
kit/src/main/java/com/tencent/liteav/demo/superplayer/ui/player/FullScreenPlayer.java

@@ -29,11 +29,8 @@ public class FullScreenPlayer extends AbsPlayer implements UnlockProgressView.On
     private ImageView mImageCover;                            // 封面图
 
     private boolean isShowing;  // 自身是否可见
-    private SuperPlayerDef.PlayerType mPlayType;   // 当前播放视频类型
     private SuperPlayerDef.PlayerState mCurrentPlayState = SuperPlayerDef.PlayerState.END; // 当前播放状态
 
-    private Bitmap mBackgroundBmp; // 背景图
-
     private boolean isDestroy = false;  // Activity是否被销毁
 
     public FullScreenPlayer(Context context) {

+ 5 - 0
kit/src/main/java/com/tencent/liteav/demo/superplayer/ui/player/Player.java

@@ -30,6 +30,11 @@ public interface Player {
      */
     void hide();
 
+    /**
+     * 定时时间到了
+     */
+    void timeOut();
+
     /**
      * 释放控件的内存
      */

+ 10 - 2
kit/src/main/java/com/tencent/liteav/demo/superplayer/ui/player/TimeOutPlayer.java

@@ -2,22 +2,30 @@ package com.tencent.liteav.demo.superplayer.ui.player;
 
 import android.content.Context;
 import android.util.AttributeSet;
+import android.view.LayoutInflater;
 import android.view.View;
 
+import com.tencent.liteav.demo.superplayer.R;
+
 public class TimeOutPlayer extends AbsPlayer implements View.OnClickListener{
 
     public TimeOutPlayer(Context context) {
-        super(context);
+        this(context,null);
     }
 
     public TimeOutPlayer(Context context, AttributeSet attrs) {
-        super(context, attrs);
+        this(context, attrs,0);
     }
 
     public TimeOutPlayer(Context context, AttributeSet attrs, int defStyleAttr) {
         super(context, attrs, defStyleAttr);
     }
 
+    private void initView(Context context,AttributeSet attrs){
+        LayoutInflater.from(context).inflate(R.layout.superplayer_vod_player_window, this);
+
+    }
+
     @Override
     public void onClick(View v) {
 

+ 18 - 79
kit/src/main/java/com/tencent/liteav/demo/superplayer/ui/player/WindowPlayer.java

@@ -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);
     }

+ 10 - 0
kit/src/main/res/layout/superplayer_vod_player_timeout.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <ImageView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 3 - 0
ui/src/main/kotlin/com/tencent/liteav/demo/player/viewmodel/PlayerViewModel.kt

@@ -34,14 +34,17 @@ class PlayerViewModel(
         }
     }
 
+    /* 保存一条观看时间段的记录 */
     public fun saveHistory(history: History) = viewModelScope.launch(Dispatchers.IO) {
         repository.insertHistory(history)
     }
 
+    /* 保存对该门课程单独设置的定时 */
     public fun saveCountDown(countDown: CountDown) = viewModelScope.launch {
         repository.insertCountDown(countDown)
     }
 
+    /* 开启定时器 */
     public fun setCountDown(countDown: CountDown) {
         if (countDown.type == CountDown.TYPE_EPISODE) {