zhaoyadi пре 2 година
родитељ
комит
17a18b8797

+ 5 - 1
kit/src/main/java/com/tencent/liteav/demo/superplayer/SuperPlayerView.java

@@ -177,6 +177,11 @@ public class SuperPlayerView extends RelativeLayout implements TimeoutUtil.Liste
         mPlayerViewCallback.onPlayPrepare(playIndex, playModel);
     }
 
+    public void clearPlayIndexModel(){
+        mPlayIndex = -1;
+        mCurrentSuperPlayerModel = null;
+    }
+
     public void playIndexModel(int index) {
         playModelInList(index);
     }
@@ -194,7 +199,6 @@ public class SuperPlayerView extends RelativeLayout implements TimeoutUtil.Liste
         mPlayIndex = (index) % mSuperPlayerModelList.size();
         mIsPlayInit = false;
         mSuperPlayer.stop();
-        mPlayIndex = index;
         updateNextButton();
         mCurrentSuperPlayerModel = mSuperPlayerModelList.get(mPlayIndex);
         playWithModelInner(mCurrentSuperPlayerModel);

+ 6 - 6
ui/src/main/assets/data.json

@@ -148,7 +148,7 @@
           "readCount": 8,
           "aiCourseItemChapterId": "1540205198192320513",
           "type": 0,
-          "payType": 0,
+          "payType": 1,
           "freeTime": 0,
           "audioId": null,
           "imgCover": "https://img.luojigou.vip/FnV8CLD1Ci-oF2SAiDERZ6yV7Ez-?imageView2/0/q/50|imageslim",
@@ -168,15 +168,15 @@
           "starList": [],
           "readCountStr": "8",
           "video": {
-            "id": "1540205198364286977",
-            "videoUrl": null,
-            "parentId": "1540205198318149634",
+            "id": "1540205198259429378",
+            "videoUrl": "http://video.training.luojigou.vip/lm6giVlUMxuYKuVaBRTxRr6SNiO__low.mp4",
+            "parentId": "1540205198213292034",
             "createTime": "2022-06-24 13:28:29",
             "updateTime": "2022-06-24 14:15:52",
             "width": 1920,
             "height": 1080,
-            "thumbnailUrl": null,
-            "duration": "292.080000"
+            "thumbnailUrl": "http://video.training.luojigou.vip/lm6giVlUMxuYKuVaBRTxRr6SNiO__low.mp4?vframe/jpg/offset/1",
+            "duration": "291.280000"
           },
           "hasClockIn": 0,
           "getStarCount": 0

+ 3 - 1
ui/src/main/kotlin/com/tencent/liteav/demo/player/PlayerActivity.kt

@@ -235,7 +235,8 @@ class PlayerActivity : AppCompatActivity(),
                 finish()
             }
             R.id.superplayer_tc_lock -> {
-                mSuperPlayerView.switchPlayMode(SuperPlayerDef.PlayerMode.FULLSCREEN)
+                TimersUtil.resetTimer()
+//                mSuperPlayerView.switchPlayMode(SuperPlayerDef.PlayerMode.FULLSCREEN)
             }
             R.id.superplayer_tc_menu -> {
                 PlayerMenu.start(this@PlayerActivity, "")
@@ -295,6 +296,7 @@ class PlayerActivity : AppCompatActivity(),
             if (viewModel.checkCanPlay()) {
                 mSuperPlayerView.playIndexModel(index)
             } else {
+                mSuperPlayerView.clearPlayIndexModel();
                 Toast.makeText(this, "定时时间到了~", Toast.LENGTH_SHORT).show()
             }
         }

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

@@ -156,11 +156,16 @@ class PlayerViewModel(
     override fun onNewTimer(type: Int, value: Int) {
         Log.d("PVM", "onListen: $type , $value")
 
+        var rest = value
+        if (type == 1 && host.hasPlayModel()) {
+            rest -= 1
+        }
+
         countDown = CountDown(
             id = courseId,
             type = type,
             value = value,
-            rest = value,
+            rest = rest,
             datetime = SimpleDateFormat("yyyy-MM-dd").format(Date())
         )
 
@@ -171,10 +176,18 @@ class PlayerViewModel(
     }
 
     override fun onResetTimer() {
-        countDown = countDown.copyWith(
-            rest = countDown.value,
-            datetime = SimpleDateFormat("yyyy-MM-dd").format(Date())
-        )
+        if (countDown.type == 1) {
+
+            countDown = countDown.copyWith(
+                rest = if (host.hasPlayModel()) countDown.value - 1 else countDown.value,
+                datetime = SimpleDateFormat("yyyy-MM-dd").format(Date())
+            )
+        } else {
+            countDown = countDown.copyWith(
+                rest = countDown.value,
+                datetime = SimpleDateFormat("yyyy-MM-dd").format(Date())
+            )
+        }
 
         countDown.let {
             setCountDown(it, true)