Commit 4b69ff95 authored by 李纪文's avatar 李纪文

feat: 视频回放增加进度条

parent ab211a80
...@@ -62,7 +62,7 @@ export default class RvResponsiveCanvas extends Component { ...@@ -62,7 +62,7 @@ export default class RvResponsiveCanvas extends Component {
ref={this.setRef} ref={this.setRef}
width={width * scale} width={width * scale}
height={height * scale} height={height * scale}
style={{ ...style, width, height, minWidth: '952px' }} style={{ ...style, width, height }}
/> />
); );
} }
......
import { message, ConfigProvider } from 'antd'; import { message, ConfigProvider, Progress } from 'antd';
import { useEffect, useState, useContext, useRef, useImperativeHandle } from 'react'; import { useEffect, useState, useContext, useRef, useImperativeHandle } from 'react';
import TestVideo from '../index'; import TestVideo from '../index';
import classNames from 'classnames'; import classNames from 'classnames';
import Empty from '@wisdom-components/empty'; import Empty from '@wisdom-components/empty';
import empty_icon from '../assets/缺省页.png';
import { videoPlayback, newPlayback } from '../apis'; import { videoPlayback, newPlayback } from '../apis';
import './index.less'; import './index.less';
import moment from 'moment'; import moment from 'moment';
...@@ -21,11 +22,29 @@ const RecVideo = (props, ref) => { ...@@ -21,11 +22,29 @@ const RecVideo = (props, ref) => {
const [minTimestamp, setMinTimestamp] = useState(null); //时间轴最小时间 const [minTimestamp, setMinTimestamp] = useState(null); //时间轴最小时间
const [maxTimestamp, setMaxTimestamp] = useState(null); //时间轴最大时间 const [maxTimestamp, setMaxTimestamp] = useState(null); //时间轴最大时间
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [percent, setPercent] = useState(0);
const timeRef = useRef(null);
useEffect(() => { useEffect(() => {
changeReplayCfg(); changeReplayCfg();
}, [props.VideoInfo]); }, [props.VideoInfo]);
useEffect(() => {
let current = percent;
if (loading) timeRef.current = setInterval(() => {
current = current + 1;
setPercent(current > 99 ? 99 : current);
}, 40);
return () => {
if (timeRef.current) {
clearInterval(timeRef.current);
timeRef.current = null;
setPercent(0);
}
}
}, [loading]);
useImperativeHandle(ref, () => { useImperativeHandle(ref, () => {
// changeVal 就是暴露给父组件的方法, newVal是父组件传递的参数 // changeVal 就是暴露给父组件的方法, newVal是父组件传递的参数
return jessibuca.current; // _video&& _video.current&&_video.current.jessibuca return jessibuca.current; // _video&& _video.current&&_video.current.jessibuca
...@@ -43,7 +62,8 @@ const RecVideo = (props, ref) => { ...@@ -43,7 +62,8 @@ const RecVideo = (props, ref) => {
force: 1, force: 1,
startTime: formattedTime, startTime: formattedTime,
endTime: edDates, endTime: edDates,
'site-code': window?.globalConfig?.userInfo?.LocalSite || window?.globalConfig?.userInfo?.site || '', 'site-code':
window?.globalConfig?.userInfo?.LocalSite || window?.globalConfig?.userInfo?.site || '',
}; };
rePaly(params); rePaly(params);
} }
...@@ -62,7 +82,8 @@ const RecVideo = (props, ref) => { ...@@ -62,7 +82,8 @@ const RecVideo = (props, ref) => {
force: 1, force: 1,
startTime: stTimes, startTime: stTimes,
endTime: edTimes, endTime: edTimes,
'site-code': window?.globalConfig?.userInfo?.LocalSite || window?.globalConfig?.userInfo?.site || '', 'site-code':
window?.globalConfig?.userInfo?.LocalSite || window?.globalConfig?.userInfo?.site || '',
}; };
setHoursRuler(hoursPerRuler); setHoursRuler(hoursPerRuler);
setMinTimestamp(moment(stTimes).valueOf()); setMinTimestamp(moment(stTimes).valueOf());
...@@ -72,34 +93,36 @@ const RecVideo = (props, ref) => { ...@@ -72,34 +93,36 @@ const RecVideo = (props, ref) => {
const getVideoPlBack = (param) => { const getVideoPlBack = (param) => {
setLoading(true); setLoading(true);
videoPlayback(param).then((res) => { videoPlayback(param)
setLoading(false); .then((res) => {
if (res.code === 200) { setLoading(false);
setPeridos( if (res.code === 200) {
res.data.peridos.map((times, i) => { setPeridos(
let beginTime = moment(times.StartTime.replaceAll('T', ' ').replaceAll('Z', ' ')); res.data.peridos.map((times, i) => {
let endTime = moment(times.EndTime.replaceAll('T', ' ').replaceAll('Z', ' ')); let beginTime = moment(times.StartTime.replaceAll('T', ' ').replaceAll('Z', ' '));
return { let endTime = moment(times.EndTime.replaceAll('T', ' ').replaceAll('Z', ' '));
...times, return {
idx: i, ...times,
beginTime: beginTime.valueOf(), idx: i,
endTime: endTime.valueOf(), beginTime: beginTime.valueOf(),
style: { background: '#637DEC' }, endTime: endTime.valueOf(),
}; style: { background: '#637DEC' },
}), };
); }),
setShowId(res.data.url); );
} else { setShowId(res.data.url);
message.warn(res.msg); } else {
setShowId(null); message.warn(res.msg);
} setShowId(null);
}); }
})
.catch((error) => {
setLoading(false);
});
}; };
const rePaly = (params) => { const rePaly = (params) => {
setLoading(true);
newPlayback(params).then((res) => { newPlayback(params).then((res) => {
setLoading(false);
if (res.code === 200) { if (res.code === 200) {
setShowId(res.data); setShowId(res.data);
} else { } else {
...@@ -117,7 +140,14 @@ const RecVideo = (props, ref) => { ...@@ -117,7 +140,14 @@ const RecVideo = (props, ref) => {
return ( return (
<div className={classNames(prefixCls)}> <div className={classNames(prefixCls)}>
{showId ? ( {loading ? (
<>
<div className={classNames(`${prefixCls}-load`)}>
<Progress className={classNames(`${prefixCls}-progress`)} strokeWidth={14} percent={percent} />
<span>视频回放信息获取中,请稍后...</span>
</div>
</>
) : showId ? (
<> <>
<div className={classNames(`${prefixCls}-video`)}> <div className={classNames(`${prefixCls}-video`)}>
{showId && ( {showId && (
...@@ -152,7 +182,11 @@ const RecVideo = (props, ref) => { ...@@ -152,7 +182,11 @@ const RecVideo = (props, ref) => {
</> </>
) : ( ) : (
<div className={classNames(`${prefixCls}-empty`)}> <div className={classNames(`${prefixCls}-empty`)}>
{!loading && <Empty theme={'dark'} description={''} />} <Empty
image={empty_icon}
theme={'dark'}
description={'咦~暂时没有查询到视频回放信息呢~'}
/>
</div> </div>
)} )}
</div> </div>
......
...@@ -9,6 +9,23 @@ ...@@ -9,6 +9,23 @@
height: 100%; height: 100%;
width: 100%; width: 100%;
&-load {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
overflow: hidden;
}
&-progress {
width: 100%;
overflow: hidden;
width: 50%;
margin-bottom: 10px;
}
&-video { &-video {
flex: 1; flex: 1;
width: 100%; width: 100%;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment