Jelajahi Sumber

feat 自动播放下一个随机合集

erekook 11 bulan lalu
induk
melakukan
195002a470
1 mengubah file dengan 16 tambahan dan 7 penghapusan
  1. 16 7
      pages/collect-video/video.js

+ 16 - 7
pages/collect-video/video.js

@@ -6,7 +6,7 @@ import {
   getCollectRealVideoUrl,
   getCollectRealVideoUrl,
   getRecCollectList,
   getRecCollectList,
 } from "../../api/api";
 } from "../../api/api";
-import { rnd, SendEvent } from "../../utils/util";
+import { rnd, SendEvent, rndone } from "../../utils/util";
 import { apple } from "../../config/config";
 import { apple } from "../../config/config";
 
 
 const app = getApp();
 const app = getApp();
@@ -323,15 +323,24 @@ Page({
       videoStatus: 0,
       videoStatus: 0,
     });
     });
 
 
-    // 切换下一集
     const nextEp = this.data.playingEp + 1;
     const nextEp = this.data.playingEp + 1;
-    if (nextEp <= this.data.eps.length - 1) {
+    // 最后一集播放完,随机播放下一个合集
+    if (nextEp === this.data.eps.length && this.data.videoList.length > 0) {
+      const rndCollect = rndone(this.data.videoList);
       this.setData({
       this.setData({
-        playingEp: nextEp,
-        videoDetail: this.data.eps[nextEp],
+        collectId: rndCollect.id,
       });
       });
-      if (!this.data.videoDetail.lock) {
-        this.getVideoPlayUrl();
+      this.getCollectVideoDetail();
+    } else {
+      // 切换下一集
+      if (nextEp <= this.data.eps.length - 1) {
+        this.setData({
+          playingEp: nextEp,
+          videoDetail: this.data.eps[nextEp],
+        });
+        if (!this.data.videoDetail.lock) {
+          this.getVideoPlayUrl();
+        }
       }
       }
     }
     }
   },
   },