@vtx/player 0.0.3 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +11 -0
- package/.eslintrc.js +31 -0
- package/.prettierignore +10 -0
- package/.prettierrc.js +22 -0
- package/.storybook/main.js +58 -0
- package/.storybook/manager.js +7 -0
- package/.storybook/preview-head.html +5 -0
- package/.storybook/preview.js +9 -0
- package/.storybook/proxy.js +6 -0
- package/.storybook/theme.js +8 -0
- package/.stylelintrc.json +13 -0
- package/.vscode/extensions.json +10 -0
- package/.vscode/settings.json +16 -0
- package/README.md +2 -2
- package/commitlint.config.js +10 -0
- package/package.json +98 -100
- package/public/h5player.min.js +311 -0
- package/public/playctrl1/AudioRenderer.js +225 -0
- package/public/playctrl1/DecodeWorker.js +711 -0
- package/public/playctrl1/Decoder.js +1 -0
- package/public/playctrl1/SuperRender_10.js +396 -0
- package/public/playctrl2/Decoder.js +21 -0
- package/public/playctrl2/Decoder.wasm +0 -0
- package/public/playctrl2/Decoder.worker.js +1 -0
- package/public/playctrl3/Decoder.js +21 -0
- package/public/playctrl3/Decoder.wasm +0 -0
- package/public/playctrl3/Decoder.worker.js +1 -0
- package/rollup.config.js +52 -0
- package/src/api/fetch.ts +55 -0
- package/src/api/index.ts +43 -0
- package/{dist/types/api/types.d.ts → src/api/types.ts} +131 -117
- package/src/components/bill-player/index.less +58 -0
- package/src/components/bill-player/index.stories.mdx +24 -0
- package/src/components/bill-player/index.stories.tsx +13 -0
- package/src/components/bill-player/index.tsx +267 -0
- package/src/components/controls/images/arrow.png +0 -0
- package/src/components/controls/images/error.png +0 -0
- package/src/components/controls/index.less +182 -0
- package/src/components/controls/index.tsx +312 -0
- package/src/components/history-control/images/collapse.png +0 -0
- package/src/components/history-control/index.less +211 -0
- package/src/components/history-control/index.stories.mdx +62 -0
- package/src/components/history-control/index.stories.tsx +130 -0
- package/src/components/history-control/index.tsx +368 -0
- package/src/components/history-player/index.less +98 -0
- package/src/components/history-player/index.stories.mdx +38 -0
- package/src/components/history-player/index.stories.tsx +12 -0
- package/src/components/history-player/index.tsx +206 -0
- package/src/components/live-channel-player/index.stories.mdx +29 -0
- package/src/components/live-channel-player/index.stories.tsx +11 -0
- package/src/components/live-channel-player/index.tsx +75 -0
- package/src/components/live-control/index.less +65 -0
- package/src/components/live-control/index.stories.mdx +64 -0
- package/src/components/live-control/index.stories.tsx +61 -0
- package/src/components/live-control/index.tsx +274 -0
- package/src/components/live-player/index.less +71 -0
- package/src/components/live-player/index.stories.mdx +35 -0
- package/src/components/live-player/index.stories.tsx +12 -0
- package/src/components/live-player/index.tsx +118 -0
- package/src/components/player/index.ts +318 -0
- package/src/context/index.ts +13 -0
- package/src/hooks/useSettings.tsx +14 -0
- package/src/icons/index.less +27 -0
- package/src/icons/index.tsx +518 -0
- package/{dist/types/main.d.ts → src/main.ts} +9 -8
- package/src/stories/intro.stories.mdx +16 -0
- package/src/typings/@vtx/utils/index.d.ts +27 -0
- package/src/typings/h5player.d.ts +133 -0
- package/src/utils/index.ts +215 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +24 -0
- package/dist/index.d.ts +0 -223
- package/dist/index.es.js +0 -533
- package/dist/index.es.js.map +0 -1
- package/dist/index.umd.js +0 -533
- package/dist/index.umd.js.map +0 -1
- package/dist/types/api/fetch.d.ts +0 -12
- package/dist/types/api/index.d.ts +0 -16
- package/dist/types/components/bill-player/index.d.ts +0 -21
- package/dist/types/components/controls/index.d.ts +0 -52
- package/dist/types/components/history-control/index.d.ts +0 -39
- package/dist/types/components/history-player/index.d.ts +0 -31
- package/dist/types/components/live-channel-player/index.d.ts +0 -18
- package/dist/types/components/live-control/index.d.ts +0 -35
- package/dist/types/components/live-player/index.d.ts +0 -22
- package/dist/types/components/player/index.d.ts +0 -84
- package/dist/types/context/index.d.ts +0 -8
- package/dist/types/hooks/useSettings.d.ts +0 -9
- package/dist/types/icons/index.d.ts +0 -54
- package/dist/types/utils/index.d.ts +0 -60
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import HistoryControl, { HistoryControlHandle } from '.';
|
|
4
|
+
import { ComponentStory } from '@storybook/react';
|
|
5
|
+
import { Button, DatePicker, Form, Input, Space } from 'antd';
|
|
6
|
+
import { useForm } from 'antd/lib/form/Form';
|
|
7
|
+
import moment from 'moment';
|
|
8
|
+
|
|
9
|
+
type FormData = {
|
|
10
|
+
/** 频道号 */
|
|
11
|
+
channelNum: string;
|
|
12
|
+
/** 设备ID */
|
|
13
|
+
deviceId: string;
|
|
14
|
+
/** 协议 */
|
|
15
|
+
protocol?: string;
|
|
16
|
+
/** 开始时间,格式:2022-06-01 00:00:00 */
|
|
17
|
+
beginTime: string;
|
|
18
|
+
/** 结束时间,格式:2022-06-01 23:59:59 */
|
|
19
|
+
endTime: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const Template: ComponentStory<typeof HistoryControl> = (args) => {
|
|
23
|
+
const ref = useRef<HistoryControlHandle>(null);
|
|
24
|
+
const [form] = useForm();
|
|
25
|
+
const onFinish = (values: FormData) => {
|
|
26
|
+
const control = ref.current;
|
|
27
|
+
if (control)
|
|
28
|
+
control.load({
|
|
29
|
+
...values,
|
|
30
|
+
beginTime: moment(values.beginTime).format('YYYY-MM-DD HH:mm:ss'),
|
|
31
|
+
endTime: moment(values.endTime).format('YYYY-MM-DD HH:mm:ss'),
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
return (
|
|
35
|
+
<Space size={24}>
|
|
36
|
+
<HistoryControl {...args} ref={ref} />
|
|
37
|
+
<div>
|
|
38
|
+
<Space style={{ marginBottom: 20 }}>
|
|
39
|
+
<Button
|
|
40
|
+
onClick={() => {
|
|
41
|
+
form.setFieldsValue({
|
|
42
|
+
channelNum: '98956603975e480c8d673c87f1126f5f',
|
|
43
|
+
deviceId: 'c15f2219af0d4770b399dc5e519fbd37',
|
|
44
|
+
});
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
海康测试-万科中粮
|
|
48
|
+
</Button>
|
|
49
|
+
<Button
|
|
50
|
+
onClick={() => {
|
|
51
|
+
form.setFieldsValue({
|
|
52
|
+
channelNum: '396ee1a6d586404982ce4c412bdcaf49',
|
|
53
|
+
deviceId: '25d0b7c5e1624cf0a9abf18c45cca7a0',
|
|
54
|
+
});
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
FLV测试-惠盛
|
|
58
|
+
</Button>
|
|
59
|
+
<Button
|
|
60
|
+
onClick={() => {
|
|
61
|
+
form.setFieldsValue({
|
|
62
|
+
channelNum: '87cc1a9de57a41e19344d4d3e75a5976',
|
|
63
|
+
deviceId: '687a1c4765c0453ea58618e5c7c6d9dd',
|
|
64
|
+
});
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
海康测试-垃圾房对讲
|
|
68
|
+
</Button>
|
|
69
|
+
</Space>
|
|
70
|
+
<Form
|
|
71
|
+
form={form}
|
|
72
|
+
name="basic"
|
|
73
|
+
labelCol={{ span: 8 }}
|
|
74
|
+
wrapperCol={{ span: 16 }}
|
|
75
|
+
onFinish={onFinish}
|
|
76
|
+
initialValues={{
|
|
77
|
+
channelNum: '98956603975e480c8d673c87f1126f5f',
|
|
78
|
+
deviceId: 'c15f2219af0d4770b399dc5e519fbd37',
|
|
79
|
+
beginTime: moment().subtract(1, 'day').startOf('day'),
|
|
80
|
+
endTime: moment().subtract(1, 'day').endOf('day'),
|
|
81
|
+
}}
|
|
82
|
+
autoComplete="off"
|
|
83
|
+
>
|
|
84
|
+
<Form.Item
|
|
85
|
+
label="ChannelNum"
|
|
86
|
+
name="channelNum"
|
|
87
|
+
rules={[{ required: true, message: '请输入通道编号' }]}
|
|
88
|
+
>
|
|
89
|
+
<Input />
|
|
90
|
+
</Form.Item>
|
|
91
|
+
<Form.Item
|
|
92
|
+
label="DeviceId"
|
|
93
|
+
name="deviceId"
|
|
94
|
+
rules={[{ required: true, message: '请输入设备ID' }]}
|
|
95
|
+
>
|
|
96
|
+
<Input />
|
|
97
|
+
</Form.Item>
|
|
98
|
+
<Form.Item label="Protocol" name="protocol">
|
|
99
|
+
<Input />
|
|
100
|
+
</Form.Item>
|
|
101
|
+
<Form.Item
|
|
102
|
+
label="BeginTime"
|
|
103
|
+
name="beginTime"
|
|
104
|
+
rules={[{ required: true, message: '请输入开始时间' }]}
|
|
105
|
+
>
|
|
106
|
+
<DatePicker showTime />
|
|
107
|
+
</Form.Item>
|
|
108
|
+
<Form.Item
|
|
109
|
+
label="EndTime"
|
|
110
|
+
name="endTime"
|
|
111
|
+
rules={[{ required: true, message: '请输入结束时间' }]}
|
|
112
|
+
>
|
|
113
|
+
<DatePicker showTime />
|
|
114
|
+
</Form.Item>
|
|
115
|
+
<Form.Item wrapperCol={{ offset: 8, span: 16 }}>
|
|
116
|
+
<Button type="primary" htmlType="submit">
|
|
117
|
+
加载
|
|
118
|
+
</Button>
|
|
119
|
+
</Form.Item>
|
|
120
|
+
</Form>
|
|
121
|
+
</div>
|
|
122
|
+
</Space>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
export const Default = Template.bind({});
|
|
126
|
+
Default.args = {
|
|
127
|
+
width: 1000,
|
|
128
|
+
height: 600,
|
|
129
|
+
};
|
|
130
|
+
export default Default;
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import './index.less';
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle } from 'react';
|
|
4
|
+
import useCollapse from 'react-collapsed';
|
|
5
|
+
|
|
6
|
+
import HistoryPlayer from '../history-player';
|
|
7
|
+
import { useRequest, useSetState } from 'ahooks';
|
|
8
|
+
import { Button, Space, Table, Tooltip } from 'antd';
|
|
9
|
+
import { ColumnsType } from 'antd/lib/table';
|
|
10
|
+
import moment from 'moment';
|
|
11
|
+
|
|
12
|
+
import { getHistoryUrl } from '@/api';
|
|
13
|
+
import { GetHistoryUrlParams, HistoryUrlItem } from '@/api/types';
|
|
14
|
+
import { PlayerHeader } from '@/components/controls';
|
|
15
|
+
import { ExpandIcon, FoldIcon, TimePositionIcon, VideoCloseIcon, VideoPlayIcon } from '@/icons';
|
|
16
|
+
import { getUrlTableData } from '@/utils';
|
|
17
|
+
|
|
18
|
+
import collapseBtnImg from './images/collapse.png';
|
|
19
|
+
|
|
20
|
+
export type HistoryControlHandle = {
|
|
21
|
+
load: (channel: GetHistoryUrlParams) => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
interface HistoryControlProps {
|
|
25
|
+
/** 宽度 */
|
|
26
|
+
width?: number;
|
|
27
|
+
/** 高度 */
|
|
28
|
+
height?: number;
|
|
29
|
+
/** 展开/收缩按钮回调 */
|
|
30
|
+
onExpandChange?: (expand: boolean) => void;
|
|
31
|
+
/** 播放器进度回调,time:YYYY-MM-DD HH:mm:ss */
|
|
32
|
+
onTimeChange?: (time: string) => void;
|
|
33
|
+
}
|
|
34
|
+
/** 播放器参数 */
|
|
35
|
+
type PlayParams = {
|
|
36
|
+
index: number;
|
|
37
|
+
url: string;
|
|
38
|
+
startTime: string;
|
|
39
|
+
endTime: string;
|
|
40
|
+
};
|
|
41
|
+
/** 默认播放器参数 */
|
|
42
|
+
const DEFAULT_PLAY_PARAMS: PlayParams = {
|
|
43
|
+
index: -1,
|
|
44
|
+
url: '',
|
|
45
|
+
startTime: '',
|
|
46
|
+
endTime: '',
|
|
47
|
+
};
|
|
48
|
+
type State = {
|
|
49
|
+
/** 展开/收缩 */
|
|
50
|
+
expand: boolean;
|
|
51
|
+
/** 当前时间刻度位置 */
|
|
52
|
+
timeLinePosition: number;
|
|
53
|
+
/** 名称 */
|
|
54
|
+
name: string;
|
|
55
|
+
/** 表格数据 */
|
|
56
|
+
tableData: UrlsTableItemType[];
|
|
57
|
+
/** 分段数据 */
|
|
58
|
+
segmentData: GetSegmentsProps;
|
|
59
|
+
/** 通道信息 */
|
|
60
|
+
channel?: GetHistoryUrlParams;
|
|
61
|
+
/** 总地址 */
|
|
62
|
+
totalUrl: string;
|
|
63
|
+
/** 播放器参数 */
|
|
64
|
+
playParams: PlayParams;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* 历史视频控制器
|
|
68
|
+
*/
|
|
69
|
+
export const HistoryControl = forwardRef<HistoryControlHandle, HistoryControlProps>(
|
|
70
|
+
(props, ref) => {
|
|
71
|
+
const { width = '100%', height = '100%', onExpandChange, onTimeChange } = props;
|
|
72
|
+
const { runAsync } = useRequest(getHistoryUrl, {
|
|
73
|
+
manual: true,
|
|
74
|
+
});
|
|
75
|
+
const { getCollapseProps, getToggleProps, isExpanded } = useCollapse();
|
|
76
|
+
const [state, setState] = useSetState<State>({
|
|
77
|
+
expand: true,
|
|
78
|
+
name: '',
|
|
79
|
+
tableData: [],
|
|
80
|
+
segmentData: { list: [] },
|
|
81
|
+
totalUrl: '',
|
|
82
|
+
timeLinePosition: -1, //初始化,负数不显示
|
|
83
|
+
playParams: DEFAULT_PLAY_PARAMS,
|
|
84
|
+
});
|
|
85
|
+
useImperativeHandle(ref, () => {
|
|
86
|
+
return {
|
|
87
|
+
load: (channel) => {
|
|
88
|
+
if (JSON.stringify(channel) !== JSON.stringify(state.channel)) {
|
|
89
|
+
setState({ channel, timeLinePosition: -1 });
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (state.channel) {
|
|
96
|
+
runAsync(state.channel).then((result) => {
|
|
97
|
+
// 如果没有list,只有url,则直接播放url
|
|
98
|
+
if (Array.isArray(result.list)) {
|
|
99
|
+
const tableData = getUrlTableData(result);
|
|
100
|
+
const segmentData = {
|
|
101
|
+
list: result.list,
|
|
102
|
+
start: moment(state.channel?.beginTime).startOf('day'),
|
|
103
|
+
end: moment(state.channel?.endTime).endOf('day'),
|
|
104
|
+
};
|
|
105
|
+
setState({
|
|
106
|
+
tableData,
|
|
107
|
+
segmentData,
|
|
108
|
+
name: `${result.deviceName}-${result.channelName}`,
|
|
109
|
+
totalUrl: result.totalTimeUrl,
|
|
110
|
+
});
|
|
111
|
+
} else if (result.totalTimeUrl) {
|
|
112
|
+
setState({
|
|
113
|
+
tableData: [],
|
|
114
|
+
segmentData: { list: [] },
|
|
115
|
+
name: `${result.deviceName}-${result.channelName}`,
|
|
116
|
+
totalUrl: result.totalTimeUrl,
|
|
117
|
+
playParams: {
|
|
118
|
+
index: 0,
|
|
119
|
+
url: result.totalTimeUrl,
|
|
120
|
+
startTime: state.channel?.beginTime || '',
|
|
121
|
+
endTime: state.channel?.endTime || '',
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
setState({
|
|
126
|
+
tableData: [],
|
|
127
|
+
segmentData: { list: [] },
|
|
128
|
+
name: ``,
|
|
129
|
+
playParams: DEFAULT_PLAY_PARAMS,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
});
|
|
134
|
+
return () => {
|
|
135
|
+
setState({
|
|
136
|
+
tableData: [],
|
|
137
|
+
segmentData: { list: [] },
|
|
138
|
+
name: ``,
|
|
139
|
+
playParams: DEFAULT_PLAY_PARAMS,
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}, [state.channel]);
|
|
144
|
+
const handleExpand = () => {
|
|
145
|
+
onExpandChange && onExpandChange(!state.expand);
|
|
146
|
+
setState({ expand: !state.expand });
|
|
147
|
+
};
|
|
148
|
+
const handleClose = () => {
|
|
149
|
+
setState({ channel: undefined, timeLinePosition: -1 });
|
|
150
|
+
};
|
|
151
|
+
const columns: ColumnsType<UrlsTableItemType> = [
|
|
152
|
+
{
|
|
153
|
+
title: '序号',
|
|
154
|
+
dataIndex: 'index',
|
|
155
|
+
width: 60,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
title: '播放视频',
|
|
159
|
+
key: 'play',
|
|
160
|
+
width: 90,
|
|
161
|
+
render: (_, record, index) => {
|
|
162
|
+
const active = state.playParams.index === index;
|
|
163
|
+
return (
|
|
164
|
+
<Button
|
|
165
|
+
className={`play-btn ${active ? 'active' : ''}`}
|
|
166
|
+
onClick={() => {
|
|
167
|
+
if (active) {
|
|
168
|
+
setState({
|
|
169
|
+
playParams: DEFAULT_PLAY_PARAMS,
|
|
170
|
+
timeLinePosition: -1,
|
|
171
|
+
});
|
|
172
|
+
} else {
|
|
173
|
+
const url = record.url || state.totalUrl;
|
|
174
|
+
setState({
|
|
175
|
+
playParams: {
|
|
176
|
+
index,
|
|
177
|
+
url,
|
|
178
|
+
startTime: record.beginTime,
|
|
179
|
+
endTime: record.endTime,
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}}
|
|
184
|
+
>
|
|
185
|
+
{active ? (
|
|
186
|
+
<>
|
|
187
|
+
<VideoCloseIcon active={true} />
|
|
188
|
+
关闭
|
|
189
|
+
</>
|
|
190
|
+
) : (
|
|
191
|
+
<>
|
|
192
|
+
<VideoPlayIcon />
|
|
193
|
+
播放
|
|
194
|
+
</>
|
|
195
|
+
)}
|
|
196
|
+
</Button>
|
|
197
|
+
);
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
// {
|
|
201
|
+
// title: '设备名称',
|
|
202
|
+
// dataIndex: 'deviceName',
|
|
203
|
+
// },
|
|
204
|
+
// {
|
|
205
|
+
// title: '通道名称',
|
|
206
|
+
// dataIndex: 'channelName',
|
|
207
|
+
// },
|
|
208
|
+
{
|
|
209
|
+
title: '开始时间',
|
|
210
|
+
dataIndex: 'beginTime',
|
|
211
|
+
width: 170,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
title: '结束时间',
|
|
215
|
+
dataIndex: 'endTime',
|
|
216
|
+
width: 170,
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
title: '持续时间',
|
|
220
|
+
width: 120,
|
|
221
|
+
dataIndex: 'duration',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
title: '视频大小',
|
|
225
|
+
width: 100,
|
|
226
|
+
dataIndex: 'size',
|
|
227
|
+
},
|
|
228
|
+
];
|
|
229
|
+
const handleTimeChange = (time: string) => {
|
|
230
|
+
onTimeChange && onTimeChange(time);
|
|
231
|
+
// 计算播放时间占起始时间当日的百分比
|
|
232
|
+
const progress =
|
|
233
|
+
(moment(time).diff(moment(state.channel?.beginTime).startOf('day'), 'seconds') /
|
|
234
|
+
(24 * 60 * 60)) *
|
|
235
|
+
100;
|
|
236
|
+
setState({ timeLinePosition: progress });
|
|
237
|
+
};
|
|
238
|
+
return (
|
|
239
|
+
<div className="vtx-history-control" style={{ width, height }}>
|
|
240
|
+
{state.name && <PlayerHeader name={state.name} onClose={handleClose} />}
|
|
241
|
+
<div className="player-container">
|
|
242
|
+
{state.playParams.url && (
|
|
243
|
+
<HistoryPlayer
|
|
244
|
+
{...state.playParams}
|
|
245
|
+
controlBottom={isExpanded ? 235 : 0}
|
|
246
|
+
onTimeChange={handleTimeChange}
|
|
247
|
+
/>
|
|
248
|
+
)}
|
|
249
|
+
</div>
|
|
250
|
+
{state.tableData && state.tableData.length > 0 && (
|
|
251
|
+
<div className="collapse-controls">
|
|
252
|
+
<div className="action-bar" {...getToggleProps({})}>
|
|
253
|
+
<img
|
|
254
|
+
src={collapseBtnImg}
|
|
255
|
+
alt=""
|
|
256
|
+
style={{ transform: `rotate(${isExpanded ? 180 : 0}deg)` }}
|
|
257
|
+
/>
|
|
258
|
+
</div>
|
|
259
|
+
<section className="collapse-panel-container" {...getCollapseProps()}>
|
|
260
|
+
<div className="panels">
|
|
261
|
+
<div className="time-panel">
|
|
262
|
+
<div className="segments">{getSegments(state.segmentData)}</div>
|
|
263
|
+
{state.timeLinePosition >= 0 && (
|
|
264
|
+
<TimePositionIcon
|
|
265
|
+
className="time-line-icon"
|
|
266
|
+
style={{ left: `${state.timeLinePosition}%` }}
|
|
267
|
+
/>
|
|
268
|
+
)}
|
|
269
|
+
<TimeLine />
|
|
270
|
+
</div>
|
|
271
|
+
<div className="urls-panel">
|
|
272
|
+
<Table
|
|
273
|
+
className="history-url-table"
|
|
274
|
+
columns={columns}
|
|
275
|
+
dataSource={state.tableData}
|
|
276
|
+
scroll={{ y: 100 }}
|
|
277
|
+
pagination={false}
|
|
278
|
+
rowClassName={(_, index) =>
|
|
279
|
+
index === state.playParams.index ? 'active' : ''
|
|
280
|
+
}
|
|
281
|
+
/>
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
</section>
|
|
285
|
+
</div>
|
|
286
|
+
)}
|
|
287
|
+
<div className="bottom-controls">
|
|
288
|
+
<Space className="left" size={12} align="center">
|
|
289
|
+
{onExpandChange && (
|
|
290
|
+
<Tooltip title={state.expand ? '收起' : '展开'}>
|
|
291
|
+
<div onClick={handleExpand}>
|
|
292
|
+
{state.expand ? <FoldIcon /> : <ExpandIcon />}
|
|
293
|
+
</div>
|
|
294
|
+
</Tooltip>
|
|
295
|
+
)}
|
|
296
|
+
</Space>
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
HistoryControl.displayName = 'HistoryControl';
|
|
303
|
+
export type UrlsTableItemType = {
|
|
304
|
+
/** 序号 */
|
|
305
|
+
index: number;
|
|
306
|
+
/** 设备名称 */
|
|
307
|
+
deviceName: string;
|
|
308
|
+
/** 通道名称 */
|
|
309
|
+
channelName: string;
|
|
310
|
+
/** 开始时间 */
|
|
311
|
+
beginTime: string;
|
|
312
|
+
/** 结束时间 */
|
|
313
|
+
endTime: string;
|
|
314
|
+
/** 视频时长 */
|
|
315
|
+
duration: string;
|
|
316
|
+
/** 视频大小 */
|
|
317
|
+
size: string;
|
|
318
|
+
/** 地址 */
|
|
319
|
+
url: string;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
const TimeLine = () => {
|
|
323
|
+
const getSplitLines = () => {
|
|
324
|
+
const result = [];
|
|
325
|
+
const step = 100 / 24;
|
|
326
|
+
for (let i = 0; i < 25; i++) {
|
|
327
|
+
const element = (
|
|
328
|
+
<div key={i} className="line" style={{ left: `${step * i}%` }}>
|
|
329
|
+
<div className="number">{i >= 10 ? i : '0' + i}</div>
|
|
330
|
+
</div>
|
|
331
|
+
);
|
|
332
|
+
result.push(element);
|
|
333
|
+
}
|
|
334
|
+
return result;
|
|
335
|
+
};
|
|
336
|
+
return (
|
|
337
|
+
<div className="time-axis">
|
|
338
|
+
<div className="axis" />
|
|
339
|
+
<div className="split-lines">{getSplitLines()}</div>
|
|
340
|
+
</div>
|
|
341
|
+
);
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
type GetSegmentsProps = { list: HistoryUrlItem[]; start?: moment.Moment; end?: moment.Moment };
|
|
345
|
+
const getSegments = (props: GetSegmentsProps) => {
|
|
346
|
+
const { list, start, end } = props;
|
|
347
|
+
const startTime = moment(start);
|
|
348
|
+
const endTime = moment(end);
|
|
349
|
+
const total = endTime.diff(startTime, 'seconds'); // 总时间
|
|
350
|
+
const result = list.map((i) => {
|
|
351
|
+
const itemStart =
|
|
352
|
+
moment(i.beginTime).diff(startTime, 'seconds') > 0 ? moment(i.beginTime) : startTime;
|
|
353
|
+
const itemEnd = moment(i.endTime);
|
|
354
|
+
const itemTotal = itemEnd.diff(itemStart, 'seconds'); // 分段总时间
|
|
355
|
+
const width = (itemTotal / total) * 100; // 分段时间占总时间百分比
|
|
356
|
+
const left = (itemStart.diff(startTime, 'seconds') / total) * 100; // 分段其实时间
|
|
357
|
+
return (
|
|
358
|
+
<div
|
|
359
|
+
key={i.beginTime}
|
|
360
|
+
className="segment"
|
|
361
|
+
style={{ width: `${width}%`, left: `${left < 0 ? 0 : left}%` }}
|
|
362
|
+
/>
|
|
363
|
+
);
|
|
364
|
+
});
|
|
365
|
+
return result;
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
export default HistoryControl;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
.vtx-history-player {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
background-color: #2b3d51;
|
|
7
|
+
border: 1px solid transparent;
|
|
8
|
+
|
|
9
|
+
.controls {
|
|
10
|
+
position: absolute;
|
|
11
|
+
bottom: 0;
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 30px;
|
|
16
|
+
padding: 0 12px;
|
|
17
|
+
background-color: #131d27;
|
|
18
|
+
border-bottom: 1px solid rgb(82 196 26 / 100%);
|
|
19
|
+
opacity: 0;
|
|
20
|
+
transition: opacity 0.5s;
|
|
21
|
+
|
|
22
|
+
.time {
|
|
23
|
+
padding: 4px 12px;
|
|
24
|
+
margin: 0 12px;
|
|
25
|
+
background-color: rgb(145 165 185 / 30%);
|
|
26
|
+
|
|
27
|
+
.current {
|
|
28
|
+
color: white;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.total {
|
|
32
|
+
color: rgb(255 255 255 / 85%);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.slider {
|
|
37
|
+
flex-grow: 1;
|
|
38
|
+
margin-right: 24px;
|
|
39
|
+
|
|
40
|
+
.ant-slider {
|
|
41
|
+
.ant-slider-rail {
|
|
42
|
+
background-color: rgb(173 176 180);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.right {
|
|
48
|
+
margin-left: auto;
|
|
49
|
+
|
|
50
|
+
> div {
|
|
51
|
+
height: 24px;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&:hover {
|
|
57
|
+
.controls {
|
|
58
|
+
opacity: 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
video {
|
|
63
|
+
width: 100%;
|
|
64
|
+
height: 100%;
|
|
65
|
+
object-fit: fill;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.sub-wnd {
|
|
69
|
+
width: 100% !important;
|
|
70
|
+
height: 100% !important;
|
|
71
|
+
pointer-events: none;
|
|
72
|
+
background-color: #2b3d51 !important;
|
|
73
|
+
border: 1px solid transparent !important;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.error-container {
|
|
77
|
+
position: absolute;
|
|
78
|
+
top: 50%;
|
|
79
|
+
left: 50%;
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
align-items: center;
|
|
83
|
+
transform: translate(-50%, -50%);
|
|
84
|
+
|
|
85
|
+
.text {
|
|
86
|
+
margin: 20px 0;
|
|
87
|
+
font-size: 14px;
|
|
88
|
+
color: rgb(255 255 255 / 65%);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.loading-container {
|
|
93
|
+
position: absolute;
|
|
94
|
+
top: 50%;
|
|
95
|
+
left: 50%;
|
|
96
|
+
transform: translate(-50%, -50%);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import HistoryPlayer from '.';
|
|
2
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
3
|
+
import { Alert, Space } from 'antd';
|
|
4
|
+
|
|
5
|
+
import * as stories from './index.stories';
|
|
6
|
+
|
|
7
|
+
<Meta title="组件/历史播放器" component={HistoryPlayer} />
|
|
8
|
+
|
|
9
|
+
# 历史播放器
|
|
10
|
+
|
|
11
|
+
## 引入
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { HistoryPlayer } from '@vtx/player';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 支持的格式
|
|
18
|
+
|
|
19
|
+
- 海康 ws,使用海康提供的 h5player.js 实现
|
|
20
|
+
- flv,使用 flv.js 实现
|
|
21
|
+
- hls,使用 hls.js 实现
|
|
22
|
+
|
|
23
|
+
## 注意
|
|
24
|
+
|
|
25
|
+
<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
|
|
26
|
+
<Alert message="当type属性为空时,组件将自动根据url判断视频流格式" type="warning" />
|
|
27
|
+
<Alert message="flv格式视频流不支持进度条拖拽" type="warning" />
|
|
28
|
+
</Space>
|
|
29
|
+
|
|
30
|
+
## 属性
|
|
31
|
+
|
|
32
|
+
<ArgsTable of={HistoryPlayer} />
|
|
33
|
+
|
|
34
|
+
## 例子
|
|
35
|
+
|
|
36
|
+
<Canvas>
|
|
37
|
+
<Story name="历史播放器" story={stories.Default} />
|
|
38
|
+
</Canvas>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import HistoryPlayer from '.';
|
|
2
|
+
import { ComponentStory } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
const Template: ComponentStory<typeof HistoryPlayer> = (args) => <HistoryPlayer {...args} />;
|
|
5
|
+
|
|
6
|
+
export const Default = Template.bind({});
|
|
7
|
+
Default.args = {
|
|
8
|
+
url: '',
|
|
9
|
+
width: 1000,
|
|
10
|
+
height: 600,
|
|
11
|
+
};
|
|
12
|
+
export default Default;
|