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 [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 : ''

Loading…
Cancel
Save