Browse Source

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

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

63
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()
})
} }
} }
}, []) }, [])
@ -458,27 +462,34 @@ const VideoPlay = ({ dispatch, actions,
videoFront = new moment(); // videoFront = new moment(); //
// setTimeout(() => { // setTimeout(() => {
const player = new EZUIKit.EZUIKitPlayer({ const player = new EZUIKit.EZUIKitPlayer({
id: containerId, // ID id: containerId, // ID
accessToken: videoObj?.yingshiToken, accessToken: videoObj?.yingshiToken,
url: videoObj.playUrlSd, url: videoObj.playUrlSd,
width: setupSize('width'), width: setupSize('width'),
height: setupSize('height'), height: setupSize('height'),
handleSuccess: (e) => { // handleSuccess: (e) => { //
setRoll(true) setRoll(true)
setVideoMask(false) setVideoMask(false)
playState.current = true playState.current = true
videoAfter = new moment(); // videoAfter = new moment(); //
}, },
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)
setPlayer(player) yingshiPlayer.current.stop().then(() => {
yingshiPlayer.current = player yingshiPlayer.current.play({ url: videoObj.playUrlSd })
})
}
},
})
setPlayer(player)
yingshiPlayer.current = player
// }, 0) // }, 0)
} }
@ -552,10 +563,10 @@ const VideoPlay = ({ dispatch, actions,
} }
} else { } else {
setTimeout(() => { setTimeout(() => {
if (videoObj.type == 'yingshi' && player?.pluginStatus) { if (videoObj.type == 'yingshi' && player?.pluginStatus) {
player.reSize(videoWidth, videoHeight) player.reSize(videoWidth, videoHeight)
} }
}) })
} }
setSize({ parentWidth: containerWidth, parentHeight: containerHeight, width: videoWidth, height: videoHeight }) setSize({ parentWidth: containerWidth, parentHeight: containerHeight, width: videoWidth, height: videoHeight })
return data == 'width' ? videoWidth : data == 'height' ? videoHeight : '' return data == 'width' ? videoWidth : data == 'height' ? videoHeight : ''

Loading…
Cancel
Save