播放结束自动播放下一个课程

main
king 1 year ago
parent 8e34ddb5af
commit 088ab69f32
  1. 2
      src/pages/business/videoInfo/components/catalogue.tsx
  2. 6
      src/pages/business/videoInfo/components/course.tsx
  3. 13
      src/pages/business/videoInfo/videoInfo.tsx
  4. BIN
      src/static/img/curRecord.png
  5. BIN
      src/static/img/hourRecord.png

@ -85,7 +85,7 @@ const Catalogue: FC<Props> = ({data, setHors, id}) => {
if (flat.id === lastTimeId) { if (flat.id === lastTimeId) {
const next = flats[index + 1] const next = flats[index + 1]
if (next) { if (next) {
setHors(true, lastTimeId) setHors(true, next.id)
} }
} }
} }

@ -32,7 +32,7 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}: Props) => {
const [count, setCount] = useState<Record<number, number> | null>(null) const [count, setCount] = useState<Record<number, number> | null>(null)
const [frequency, setFrequency] = useState<number>(1) // 次数 const [frequency, setFrequency] = useState<number>(1) // 次数
const [testId, setTestId] = useState<number | null>(null) const [testId, setTestId] = useState<number | null>(null)
const [startRecording, setStartRecording] = useState<CurEndParam | null>(null) // 开始记录 const [startRecording, setStartRecording] = useState<CurEndParam | null>(null) // 视频开始记录
const {user} = Profile.useContainer() const {user} = Profile.useContainer()
@ -179,7 +179,7 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}: Props) => {
setTime={videoSeek} setTime={videoSeek}
/> />
<view> <View>
<CustomPageContainer <CustomPageContainer
show={show} show={show}
position='bottom' position='bottom'
@ -239,7 +239,7 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}: Props) => {
{frequency === 0 && validate && <Button className='button' onClick={again}></Button>} {frequency === 0 && validate && <Button className='button' onClick={again}></Button>}
</View> </View>
</CustomPageContainer> </CustomPageContainer>
</view> </View>
</> </>
) )

@ -1,5 +1,5 @@
import {Image, Text, View} from "@tarojs/components"; import {Image, Text, View} from "@tarojs/components";
import {FC, useEffect, useState} from "react"; import {FC, useCallback, useEffect, useState} from "react";
import {CourseDepData, curriculum} from "@/api"; import {CourseDepData, curriculum} from "@/api";
import './videoInfo.scss' import './videoInfo.scss'
import {Profile} from '@/store' import {Profile} from '@/store'
@ -24,7 +24,7 @@ const VideoInfo: FC = () => {
} }
/** 用于自动播放 判断当前课程是否完成 */ /** 用于自动播放 判断当前课程是否完成 */
if (playId) { if (playId) {
currentVideo() currentVideo(res)
} }
} }
@ -37,8 +37,9 @@ const VideoInfo: FC = () => {
getData() getData()
}, []) }, [])
/** 播放下一个视频 */ /** 播放下一个视频 */
function playNext() { const playNext = useCallback(() => {
const flats: Hour[] = Object.values(data?.hours || {}).flat(Infinity) as Hour[] const flats: Hour[] = Object.values(data?.hours || {}).flat(Infinity) as Hour[]
if (playId === flats?.[flats.length - 1]?.id) { if (playId === flats?.[flats.length - 1]?.id) {
Taro.showModal({title: '当前课程结束'}) Taro.showModal({title: '当前课程结束'})
@ -61,12 +62,12 @@ const VideoInfo: FC = () => {
return return
} }
} }
} }, [playId, data])
/** /**
* *
*/ */
function currentVideo() { const currentVideo = useCallback((data: CourseDepData) => {
const courseHourRecordsFinish = data?.learn_hour_records.find(d => d.id === playId)?.courseHourRecordsFinish const courseHourRecordsFinish = data?.learn_hour_records.find(d => d.id === playId)?.courseHourRecordsFinish
if (typeof courseHourRecordsFinish === 'number') { if (typeof courseHourRecordsFinish === 'number') {
if (courseHourRecordsFinish === 1) { if (courseHourRecordsFinish === 1) {
@ -82,7 +83,7 @@ const VideoInfo: FC = () => {
}) })
} }
} }
} }, [playId, data])
Taro.useDidShow(() => { Taro.useDidShow(() => {
data && getData() data && getData()

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Loading…
Cancel
Save