From ad846c162d8799aa73c8e60391feb0df96d51c70 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Mon, 24 Apr 2023 15:39:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/sections/console/containers/index.js | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/console/client/src/sections/console/containers/index.js b/console/client/src/sections/console/containers/index.js index 3635c29..fb45d85 100644 --- a/console/client/src/sections/console/containers/index.js +++ b/console/client/src/sections/console/containers/index.js @@ -2,7 +2,7 @@ import React, { useEffect, useState, useRef } from 'react' import { push } from 'react-router-redux'; import { connect } from 'react-redux'; import request from 'superagent'; -import { getCrane, logoutApp } from '../actions' +import { getCrane, logoutApp, getVideo } from '../actions' import { ApiTable } from '$utils' import { Colors } from '@peace/utils' import { @@ -11,6 +11,7 @@ import { import VideoModal from '../components/videoModal' import { Col, Row, Button, Modal, Input, Space } from 'antd'; import '../style.less' +import flvjs from 'flv.js' function calculateIntersection (cx, cy, d, angle) { // 将角度转换为弧度 @@ -58,8 +59,11 @@ function Index (props) { const [isModalOpen, setIsModalOpen] = useState(false); const [videoVis, setVideoVis] = useState(false) const [isOutModalOpen, setIsOutModalOpen] = useState(false) + const [video, setVideo] = useState({}) + const flvPlayer = useRef() const draw = (type, params = {}) => { + return const canvasArea = document.getElementById('canvasArea') const canvasHeight = canvasArea.clientHeight - 12 * 2 - 6 const canvasWidth = canvasArea.clientWidth - 12 * 2 @@ -457,6 +461,35 @@ function Index (props) { } } + // + + dispatch(getVideo()).then(res => { + console.log(res); + if (res.success) { + setVideo(res.payload.data) + const container = document.getElementById('video-play'); + const flv = flvjs.createPlayer({ + type: 'flv', + url: `${res.payload.data.ws_flv}`, + isLive: true, + hasAudio: false, + hasVideo: true, + }, { + enableWorker: false, + enalleStashBuffer: true, + stashInitialSize: 128, + lazyLoadMaxDuration: 3 * 60, + seekType: 'range', + autoCleanupSourceBuffer: true, + cors: true, + }); + flv.attachMediaElement(container); + flv.load(); + flv.play(); + flvPlayer.current = flv + } + }) + return () => { if (ws) { ws.close();//关闭连接 @@ -483,9 +516,9 @@ function Index (props) { - + */} @@ -493,7 +526,10 @@ function Index (props) {
- +
@@ -509,6 +545,14 @@ function Index (props) {
+ +