From e4eea064934d4bb40783200f1936929615f06f80 Mon Sep 17 00:00:00 2001 From: wenlele Date: Mon, 22 May 2023 16:40:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=91=84=E5=83=8F=E5=A4=B4=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E4=B8=8D=E6=88=90=E5=8A=9F=E6=97=B6=E9=87=8D=E5=A4=8D=E6=89=A7?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/videoPlayer/videoPlay.jsx | 63 +++++++++++-------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoPlay.jsx b/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoPlay.jsx index d9b4809..41d9ff1 100644 --- a/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoPlay.jsx +++ b/code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoPlay.jsx @@ -105,7 +105,7 @@ const VideoPlay = ({ dispatch, actions, const [showTime_, setShowTime] = useState('') const [showTimeSelect, setShowTimeSelect] = useState(false) - + const [playNumber, setPlayNumber] = useState(0) const [hideFullScreenBut, setHideFullScreenBut] = useState(false) @@ -124,6 +124,8 @@ const VideoPlay = ({ dispatch, actions, const jessibucas = useRef(null) const flvPlayer = useRef() + + useEffect(() => { setRoll(false) }, [resolution]); @@ -133,7 +135,7 @@ const VideoPlay = ({ dispatch, actions, if (disappear || !videoMask) { let duration = moment.duration(videoAfter?.diff(videoFront))._data.milliseconds; setTimeout(() => { - if (disappear || duration > 2000) { + if (disappear || duration > 6000) { setVideoMask(true) dispatch(openness.getErrorCode(videoObj.videoToken ? { status: numbers, platform: videoObj.type, token: videoObj.videoToken } : { status: numbers, platform: videoObj.type })).then((res) => { if (res.payload.data) { @@ -152,7 +154,7 @@ const VideoPlay = ({ dispatch, actions, }); } - }, duration > 2000 ? 0 : 2000 - duration) + }, duration > 6000 ? 0 : 6000 - duration) } @@ -324,7 +326,9 @@ const VideoPlay = ({ dispatch, actions, }) } if (yingshiPlayer.current && videoObj.type == 'yingshi') { - yingshiPlayer.current.stop() + yingshiPlayer.current.stop().then(() => { + yingshiPlayer.current.destroy() + }) } } }, []) @@ -458,27 +462,34 @@ const VideoPlay = ({ dispatch, actions, videoFront = new moment(); //验证前时间 // setTimeout(() => { - const player = new EZUIKit.EZUIKitPlayer({ - id: containerId, // 视频容器ID - accessToken: videoObj?.yingshiToken, - url: videoObj.playUrlSd, - width: setupSize('width'), - height: setupSize('height'), - handleSuccess: (e) => { //播放成功 - setRoll(true) - setVideoMask(false) - playState.current = true - videoAfter = new moment(); //验证后时间 - }, - handleError: (e) => { //播放失败 - console.log(e, '播放失败'); + const player = new EZUIKit.EZUIKitPlayer({ + id: containerId, // 视频容器ID + accessToken: videoObj?.yingshiToken, + url: videoObj.playUrlSd, + width: setupSize('width'), + height: setupSize('height'), + handleSuccess: (e) => { //播放成功 + setRoll(true) + setVideoMask(false) + playState.current = true + videoAfter = new moment(); //验证后时间 + }, + handleError: (e) => { //播放失败 + console.log(e, '播放失败'); + if (playNumber > 4) { setNumbers(e.retcode) videoAfter = new moment(); //验证后时间 setDisappear(true) - }, - }) - setPlayer(player) - yingshiPlayer.current = player + } else { + setPlayNumber(playNumber + 1) + yingshiPlayer.current.stop().then(() => { + yingshiPlayer.current.play({ url: videoObj.playUrlSd }) + }) + } + }, + }) + setPlayer(player) + yingshiPlayer.current = player // }, 0) } @@ -552,10 +563,10 @@ const VideoPlay = ({ dispatch, actions, } } else { setTimeout(() => { - if (videoObj.type == 'yingshi' && player?.pluginStatus) { - player.reSize(videoWidth, videoHeight) - } - }) + if (videoObj.type == 'yingshi' && player?.pluginStatus) { + player.reSize(videoWidth, videoHeight) + } + }) } setSize({ parentWidth: containerWidth, parentHeight: containerHeight, width: videoWidth, height: videoHeight }) return data == 'width' ? videoWidth : data == 'height' ? videoHeight : ''