From 56cc7ac3dafe43177fade7f1e2992a07af313924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Mon, 27 Mar 2023 15:16:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E6=92=AD=E6=94=BE=E8=AE=B0=E5=BD=95=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/compenents/video.module.scss | 2 +- src/pages/course/compenents/video.tsx | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/pages/course/compenents/video.module.scss b/src/pages/course/compenents/video.module.scss index faa99a3..0ab4fce 100644 --- a/src/pages/course/compenents/video.module.scss +++ b/src/pages/course/compenents/video.module.scss @@ -63,7 +63,7 @@ .video-box { width: 1200px; - height: 600px; + height: 675px; margin: 0 auto; border-radius: 8px; overflow: hidden; diff --git a/src/pages/course/compenents/video.tsx b/src/pages/course/compenents/video.tsx index a7a68ad..1993e66 100644 --- a/src/pages/course/compenents/video.tsx +++ b/src/pages/course/compenents/video.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useRef, useEffect } from "react"; import styles from "./video.module.scss"; import { course } from "../../../api/index"; import { ArrowLeftOutlined } from "@ant-design/icons"; @@ -22,6 +22,7 @@ export const VideoModel: React.FC = ({ }) => { const [playUrl, setPlayUrl] = useState(""); const [playDuration, setPlayDuration] = useState(0); + const myRef = useRef(0); useEffect(() => { if (open) { @@ -29,6 +30,10 @@ export const VideoModel: React.FC = ({ } }, [open, id, cid]); + useEffect(() => { + myRef.current = playDuration; + }, [playDuration]); + const getVideoUrl = () => { course.playUrl(cid, id).then((res: any) => { setPlayUrl(res.data.url); @@ -41,12 +46,11 @@ export const VideoModel: React.FC = ({ container: document.getElementById("meedu-player-container"), autoplay: false, video: { - quality: playUrl, - defaultQuality: 0, + url: playUrl, }, try: isTrySee === 1, bulletSecret: { - enabled: true, + enabled: false, text: "18119604035", size: "15px", color: "red", @@ -67,7 +71,7 @@ export const VideoModel: React.FC = ({ }; const playTimeUpdate = (duration: number, isEnd: boolean) => { - if (duration - playDuration >= 10 || isEnd === true) { + if (duration - myRef.current >= 10 || isEnd === true) { setPlayDuration(duration); course.record(cid, id, duration).then((res: any) => {}); }