Browse Source

摄像头播放不成功时重复执行

dev_trial
wenlele 2 years ago
parent
commit
e4eea06493
  1. 19
      code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoPlay.jsx

19
code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoPlay.jsx

@ -105,7 +105,7 @@ const VideoPlay = ({ dispatch, actions,
const [showTime_, setShowTime] = useState('') const [showTime_, setShowTime] = useState('')
const [showTimeSelect, setShowTimeSelect] = useState(false) const [showTimeSelect, setShowTimeSelect] = useState(false)
const [playNumber, setPlayNumber] = useState(0)
const [hideFullScreenBut, setHideFullScreenBut] = useState(false) const [hideFullScreenBut, setHideFullScreenBut] = useState(false)
@ -124,6 +124,8 @@ const VideoPlay = ({ dispatch, actions,
const jessibucas = useRef(null) const jessibucas = useRef(null)
const flvPlayer = useRef() const flvPlayer = useRef()
useEffect(() => { useEffect(() => {
setRoll(false) setRoll(false)
}, [resolution]); }, [resolution]);
@ -133,7 +135,7 @@ const VideoPlay = ({ dispatch, actions,
if (disappear || !videoMask) { if (disappear || !videoMask) {
let duration = moment.duration(videoAfter?.diff(videoFront))._data.milliseconds; let duration = moment.duration(videoAfter?.diff(videoFront))._data.milliseconds;
setTimeout(() => { setTimeout(() => {
if (disappear || duration > 2000) { if (disappear || duration > 6000) {
setVideoMask(true) setVideoMask(true)
dispatch(openness.getErrorCode(videoObj.videoToken ? { status: numbers, platform: videoObj.type, token: videoObj.videoToken } : { status: numbers, platform: videoObj.type })).then((res) => { dispatch(openness.getErrorCode(videoObj.videoToken ? { status: numbers, platform: videoObj.type, token: videoObj.videoToken } : { status: numbers, platform: videoObj.type })).then((res) => {
if (res.payload.data) { 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') { if (yingshiPlayer.current && videoObj.type == 'yingshi') {
yingshiPlayer.current.stop() yingshiPlayer.current.stop().then(() => {
yingshiPlayer.current.destroy()
})
} }
} }
}, []) }, [])
@ -472,9 +476,16 @@ const VideoPlay = ({ dispatch, actions,
}, },
handleError: (e) => { // handleError: (e) => { //
console.log(e, '播放失败'); console.log(e, '播放失败');
if (playNumber > 4) {
setNumbers(e.retcode) setNumbers(e.retcode)
videoAfter = new moment(); // videoAfter = new moment(); //
setDisappear(true) setDisappear(true)
} else {
setPlayNumber(playNumber + 1)
yingshiPlayer.current.stop().then(() => {
yingshiPlayer.current.play({ url: videoObj.playUrlSd })
})
}
}, },
}) })
setPlayer(player) setPlayer(player)

Loading…
Cancel
Save