From 3738dc15580d8233604efbb41e027fe1bbde57b1 Mon Sep 17 00:00:00 2001 From: jl-zhoujl2 Date: Wed, 12 Jul 2023 15:10:44 +0800 Subject: [PATCH] =?UTF-8?q?7.12=20=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/router.config.ts | 5 + .../Monitor/RoomDetail/videoplay.tsx | 226 ++++++++++++++++++ 2 files changed, 231 insertions(+) create mode 100644 src/pages/ElecEvaluation/Monitor/RoomDetail/videoplay.tsx diff --git a/config/router.config.ts b/config/router.config.ts index 495beb8..2d88327 100644 --- a/config/router.config.ts +++ b/config/router.config.ts @@ -43,6 +43,11 @@ export default [ // path: '/Calendar', // component: './MainPage/ProjectManager/components/CalendarForm', // }, + //视频播放-视频播放列表(暂时用) + { + path: '/ElecEvaluation/Monitor/videoplay', + component: './ElecEvaluation/Monitor/RoomDetail/videoplay', + }, //富文本组件 // { // path: '/editor', diff --git a/src/pages/ElecEvaluation/Monitor/RoomDetail/videoplay.tsx b/src/pages/ElecEvaluation/Monitor/RoomDetail/videoplay.tsx new file mode 100644 index 0000000..f0476e4 --- /dev/null +++ b/src/pages/ElecEvaluation/Monitor/RoomDetail/videoplay.tsx @@ -0,0 +1,226 @@ +import React, { useEffect, useRef, useState } from "react"; +import { List, Spin, Typography } from "antd"; +import '../../../Evaluation/BiddingDocumentsDecrypt/index.less'; +import styles from '../../../Evaluation/BiddingDocumentsDecrypt/index.less'; +import logo from '@/images/opening/logo.svg'; +import ProCard from "@ant-design/pro-card"; +import { PlayCircleOutlined } from "@ant-design/icons"; +import Player from './js/player'; +import JTimeLine from "./js/JtimeLine"; +import moment from "moment"; +import request from '@/utils/request'; + +export async function getList() { + return request('/api/biz-service-ebtp-evaluation/v1/bizvidouploadtask/list', { + method: 'GET', + }); +} export async function getUrl(data: any) { + return request('/api/biz-service-ebtp-evaluation/v1/eval/room/jovision/taskGetRecordPlayback', { + method: 'POST', + data: { ...data }, + }); +} + + +const viewOfTenderDocuments: React.FC<{}> = () => { + const [list, setList] = useState([]); + //播放器ref + const playerRefList = useRef([]); + //回播组件 + const jTimeLineRef = useRef(); + //定时时间 + const timerMsRef = useRef(1000); + //回放进度条长度 + const [recordWidthRef, setRecordWidthRef] = useState(1000); + //进度条大小 + const currentScaleRef = useRef(0); + //倍速 + const [speed, setSpeed] = useState(1); + //倍速序号 + const speedindexRef = useRef(0); + //回放定时器 + const timeLineTimerRef = useRef(null); + const fullscreen = () => { + playerRefList.current[0].fullscreen(); + } + const mathchDot = (currentScale: any) => { + var position = 0; + switch (currentScale) { + case 0: + (position = 0), jTimeLineRef.current.changeSize(0); + break; + case 1: + (position = 30), jTimeLineRef.current.changeSize(1); + break; + case 2: + (position = 60), jTimeLineRef.current.changeSize(2); + break; + case 3: + (position = 100), jTimeLineRef.current.changeSize(3); + } + document.getElementsByClassName("dot-container-dot")[0].style.left = position + "%"; + } + const onReduce = () => { + currentScaleRef.current > 0 && (--currentScaleRef.current, mathchDot(currentScaleRef.current)); + } + const onAdd = () => { + currentScaleRef.current < 3 && (++currentScaleRef.current, mathchDot(currentScaleRef.current)); + } + const changeTimer = () => { + if (timeLineTimerRef.current) { + clearInterval(timeLineTimerRef.current); + } + + timeLineTimerRef.current = setInterval(() => { + jTimeLineRef.current.run({ time: parseInt(playerRefList.current[0].getCurTimestamp()) }); + }, timerMsRef.current); + } + const setSpeedFun = () => { + if (playerRefList.current[0].getState() == 2) return; + const arr = ["1", "2", "4", "8", "4", "2", "1", "1/2", "1/4", "1/8", "1/4", "1/2"]; + const arr2 = [1, 2, 4, 8, 4, 2, 1, 0.5, 0.25, 0.125, 0.25, 0.5]; + speedindexRef.current++; + if (speedindexRef.current == 12) { + speedindexRef.current = 0; + } + setSpeed(arr[speedindexRef.current]); + + playerRefList.current[0].setSpeed(arr2[speedindexRef.current] + ""); + timerMsRef.current = 1000 / arr2[speedindexRef.current]; + changeTimer(); + } + const handleTimeChange = (nowTime: any) => { + playerRefList.current[0].seekTo(nowTime); + } + const infoPlayer = () => { + for (var i = 0; i < 1; i++) { + playerRefList.current[i] = new Player(document.getElementById("container" + i), null); + } + } + const jTimeLinePlayer = () => { + + var container = document.getElementById("container0"); + setRecordWidthRef(container?.clientWidth); + + //初始化回播组件 + jTimeLineRef.current = new JTimeLine(); + jTimeLineRef.current.init({ + id: "canvas", + onChange: handleTimeChange, + }); + + jTimeLineRef.current.run({ time: parseInt(playerRefList.current[0].getCurTimestamp()) }); + changeTimer(); + } + //播放 + const toplayer = (url: any, endtime: any, player: any) => { + console.log("playerRef.current.getState() :" + player.getState()) + if (player.getState() != 0) { + player.stop(); + player.talkDestroy(); + } + let options = { + url: url, + endtime: endtime, + isStream: true, + encrypted_key: "", + encrypted_iv: "", + encrypted_type: "" + }; + setTimeout(() => { + player.play(options); + setTimeout(() => { + jTimeLinePlayer(); + }, 1000); + }, 1000); + + } + const onGetLiveStream = ({ taskId, createTime }: any) => { + var i = 0; + playerRefList.current.forEach((element) => { + getUrl({ taskId, "protocol": "ws" }).then(res => { + toplayer(res.data.url, moment(createTime).format('yyyyMMDDHHmmss'), element); + }) + i++; + }); + } + useEffect(() => { + if (timeLineTimerRef.current) { + clearInterval(timeLineTimerRef.current); + } + //初始化播放器 + infoPlayer(); + getList().then(res => { + setList(res.data); + }); + return () => { + clearInterval(timeLineTimerRef.current); + } + }, []) + + + + return ( +
+
+
+ 招标采购中心 | 视频播放 +
+
+ + + ( + onGetLiveStream(item)} hidden={item.status !== 1}>播放]} + > + {item.taskName} + + )} + /> + + +
+
fullscreen()}>
+
+
+ + 该浏览器不支持canvas + +
+
+
+
+ onReduce()}> +
+
+
+ onAdd()}> +
+
+
+
+ +    + fullscreen()}> +
+
+
+
+
+
+
+
+ ) +} +export default viewOfTenderDocuments