2 Commits

  1. 52
      src/pages/OutRoadMgm/OutDeviceMgm/OutMonitorMgm/HistoryTable.jsx
  2. 21
      src/pages/OutRoadMgm/OutDeviceMgm/OutMonitorMgm/loadable.jsx

52
src/pages/OutRoadMgm/OutDeviceMgm/OutMonitorMgm/HistoryTable.jsx

@ -21,9 +21,10 @@ export default function HistoryTable(props) {
const [visible, setVisible]= useState(false) const [visible, setVisible]= useState(false)
const [timeRange, setTimeRange] = useState([moment(new Date(new Date().getTime() - 7*86400*1000)), moment()]) const [timeRange, setTimeRange] = useState([moment(new Date(new Date().getTime() - 7*86400*1000)), moment()])
const videoRef = useRef()
const modalVideoRef = useRef()
const [videoUrl, setVideoUrl] = useState('') const [videoUrl, setVideoUrl] = useState('')
const intervalPlayRef = useRef() const intervalPlayRef = useRef()
const recordRef = useRef()
const columns = [ const columns = [
{ {
title: '序号', title: '序号',
@ -50,7 +51,7 @@ export default function HistoryTable(props) {
key: 'operation', key: 'operation',
width: 150, width: 150,
align: "center", align: "center",
render: (va, record) => <a onClick={()=>{getOneVideoPlay(record.start_time, record.end_time)}}>查看回放</a>,
render: (va, record) => <a onClick={()=>{getOneVideoPlay(record)}}>查看回放</a>,
}, },
]; ];
@ -73,25 +74,47 @@ export default function HistoryTable(props) {
}) })
} }
const getOneVideoPlay =(time1, time2)=>{
ajax.getOneVideoPlay({id: id, start_time: time1, end_time: time2, type: 2}).then(
const getOneVideoPlay =(record)=>{
recordRef.current = record
ajax.getOneVideoPlay({id: id, start_time: record.start_time, end_time: record.end_time, type: 2}).then(
res=>{ res=>{
if(res.status == 20000){ if(res.status == 20000){
setVisible(true) setVisible(true)
setVideoUrl(res.data.url) setVideoUrl(res.data.url)
setTimeout(() => {
modalVideoRef.current.changeUrl(res.data.url)
}, 300);
startIntervalToPlay()
} }
} }
).catch(err=>{ ).catch(err=>{
}) })
} }
const startIntervalToPlay = ()=>{
if(!intervalPlayRef.current){
intervalPlayRef.current = setInterval(() => {
ajax.getOutRoadVideoPlaying({id: id, start_time: recordRef.current.start_time, end_time: recordRef.current.end_time, type:2}).then((res)=>{
if(res.status == 20000){
}
})
}, 5000);
}
}
const stopIntervalToClose = ()=>{
if(modalVideoRef.current){
modalVideoRef.current.closeVideo()
// videoRef.current = null
}
if(intervalPlayRef.current){
clearInterval(intervalPlayRef.current)
intervalPlayRef.current = null
}
}
// const stopIntervalToClose = ()=>{
// if(intervalPlayRef.current){
// clearInterval(intervalPlayRef.current)
// intervalPlayRef.current = null
// }
// }
useEffect(()=>{ useEffect(()=>{
getHistoryVideoList() getHistoryVideoList()
@ -99,6 +122,9 @@ export default function HistoryTable(props) {
useEffect(()=>{ useEffect(()=>{
getHistoryVideoList() getHistoryVideoList()
return ()=>{
stopIntervalToClose()
}
},[]) },[])
return ( return (
@ -141,13 +167,11 @@ export default function HistoryTable(props) {
open={visible} open={visible}
width={1200} width={1200}
title="" title=""
onCancel={()=>{setVisible(false);}}
onCancel={()=>{setVisible(false);stopIntervalToClose(); }}
footer={null} footer={null}
> >
<div> <div>
{
videoUrl ? <VideoPlay videoType="mp4" ref={videoRef} videoUrl={videoUrl} ></VideoPlay> : null
}
<VideoPlay videoType="mp4" ref={modalVideoRef} ></VideoPlay>
</div> </div>
</Modal> </Modal>
</div> </div>

21
src/pages/OutRoadMgm/OutDeviceMgm/OutMonitorMgm/loadable.jsx

@ -91,6 +91,7 @@ function OutMonitorMgm(props) {
const [oneVideoRealtimeUrlInfo, setOneVideoRealtimeUrlInfo] = useState({}) const [oneVideoRealtimeUrlInfo, setOneVideoRealtimeUrlInfo] = useState({})
const videoRef = useRef() const videoRef = useRef()
const urlRef = useRef()
const intervalRef = useRef() const intervalRef = useRef()
const rowDataRef = useRef() const rowDataRef = useRef()
rowDataRef.current = rowData rowDataRef.current = rowData
@ -211,6 +212,7 @@ function OutMonitorMgm(props) {
if(res.status == 20000 && res.data.url){ if(res.status == 20000 && res.data.url){
setVideoModalVisible(true) setVideoModalVisible(true)
// setOneVideoRealtimeUrlInfo({id: item.id, url: res.data.url}) // setOneVideoRealtimeUrlInfo({id: item.id, url: res.data.url})
urlRef.current= res.data.url
setTimeout(() => { setTimeout(() => {
videoRef.current.changeUrl(res.data.url) videoRef.current.changeUrl(res.data.url)
}, 300); }, 300);
@ -225,10 +227,10 @@ function OutMonitorMgm(props) {
}; };
const startIntervalToPlay = (type)=>{
const startIntervalToPlay = ()=>{
if(!intervalPlayRef.current){ if(!intervalPlayRef.current){
intervalPlayRef.current = setInterval(() => { intervalPlayRef.current = setInterval(() => {
ajax.getOutRoadVideoPlaying({id: rowDataRef.current.id, type:type}).then((res)=>{
ajax.getOutRoadVideoPlaying({id: rowDataRef.current.id, type:1}).then((res)=>{
if(res.status == 20000){ if(res.status == 20000){
// console.log('') // console.log('')
} }
@ -240,7 +242,7 @@ function OutMonitorMgm(props) {
const stopIntervalToClose = ()=>{ const stopIntervalToClose = ()=>{
if(videoRef.current){ if(videoRef.current){
videoRef.current.closeVideo() videoRef.current.closeVideo()
videoRef.current = null
// videoRef.current = null
} }
if(intervalPlayRef.current){ if(intervalPlayRef.current){
clearInterval(intervalPlayRef.current) clearInterval(intervalPlayRef.current)
@ -250,8 +252,15 @@ function OutMonitorMgm(props) {
const clickSwitch=(val)=>{ const clickSwitch=(val)=>{
setPlayType(val); setPlayType(val);
stopIntervalToClose();
startIntervalToPlay(val)
if(val == 2){ // ,
stopIntervalToClose();
}else{ // ,
startIntervalToPlay()
setTimeout(() => {
videoRef.current.changeUrl(urlRef.current)
}, 200);
}
// startIntervalToPlay(val)
} }
const handleDel = (item) => { const handleDel = (item) => {
@ -914,7 +923,7 @@ function OutMonitorMgm(props) {
{ {
playType == '1' ? playType == '1' ?
<div> <div>
<VideoPlay videoType="mp4" ref={videoRef} ></VideoPlay>
<VideoPlay videoType="mp4" ref={(e)=>{videoRef.current = e}} ></VideoPlay>
</div> </div>
: :
<div > <div >

Loading…
Cancel
Save