Browse Source

自动播放

skyblued 2 years ago
parent
commit
69678306ab
1 changed files with 12 additions and 8 deletions
  1. 12 8
      src/views/coursewarePlay/index.tsx

+ 12 - 8
src/views/coursewarePlay/index.tsx

@@ -125,7 +125,7 @@ export default defineComponent({
         const res = await request.get(
           `${state.platformApi}/courseSchedule/detail/${route.query.courseId}`
         )
-        if (res?.data){
+        if (res?.data) {
           data.isCourse = res.data.status === 'COMPLETE' ? false : true
         }
       } catch (e) {
@@ -171,6 +171,7 @@ export default defineComponent({
             ...videoItem,
             iframeRef: null,
             tabName: item.name,
+            isLast: j === itemLength, // 当前知识点
             autoPlay: j === itemLength
           })
         }
@@ -354,17 +355,20 @@ export default defineComponent({
     //当前视频播放完
     const handleEnded = (m: any) => {
       // console.log(m)
-      // 自动播放下一个知识点
-      if (m.autoPlay) {
-        if (popupData.activeIndex != data.itemList.length - 1) {
-          popupData.activeIndex++
-          swipeRef.value?.next()
-          const nextItem = data.itemList[popupData.activeIndex]
+      if (popupData.activeIndex != data.itemList.length - 1) {
+        popupData.activeIndex++
+        swipeRef.value?.next()
+        const nextItem = data.itemList[popupData.activeIndex]
+        if (nextItem.type === 'VIDEO'){
           nextTick(() => {
+            // 自动播放下一个知识点
+            // if (m.autoPlay) {
+            // }
             nextItem.videoEle?.play()
           })
-          console.log('🚀 ~ nextItem', nextItem)
         }
+        
+        console.log('🚀 ~ nextItem', nextItem)
       }
     }