@vtx/player 0.0.1

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.
Files changed (71) hide show
  1. package/.eslintignore +11 -0
  2. package/.eslintrc.js +31 -0
  3. package/.prettierignore +10 -0
  4. package/.prettierrc.js +22 -0
  5. package/.storybook/main.js +58 -0
  6. package/.storybook/manager.js +7 -0
  7. package/.storybook/preview-head.html +5 -0
  8. package/.storybook/preview.js +9 -0
  9. package/.storybook/proxy.js +6 -0
  10. package/.storybook/theme.js +8 -0
  11. package/.stylelintrc.json +13 -0
  12. package/.vscode/extensions.json +10 -0
  13. package/.vscode/settings.json +16 -0
  14. package/README.md +3 -0
  15. package/commitlint.config.js +10 -0
  16. package/package.json +98 -0
  17. package/public/h5player.min.js +311 -0
  18. package/public/playctrl1/AudioRenderer.js +225 -0
  19. package/public/playctrl1/DecodeWorker.js +711 -0
  20. package/public/playctrl1/Decoder.js +1 -0
  21. package/public/playctrl1/SuperRender_10.js +396 -0
  22. package/public/playctrl2/Decoder.js +21 -0
  23. package/public/playctrl2/Decoder.wasm +0 -0
  24. package/public/playctrl2/Decoder.worker.js +1 -0
  25. package/public/playctrl3/Decoder.js +21 -0
  26. package/public/playctrl3/Decoder.wasm +0 -0
  27. package/public/playctrl3/Decoder.worker.js +1 -0
  28. package/rollup.config.js +52 -0
  29. package/src/api/fetch.ts +50 -0
  30. package/src/api/index.ts +44 -0
  31. package/src/api/types.ts +141 -0
  32. package/src/components/bill-player/index.less +58 -0
  33. package/src/components/bill-player/index.stories.mdx +24 -0
  34. package/src/components/bill-player/index.stories.tsx +14 -0
  35. package/src/components/bill-player/index.tsx +269 -0
  36. package/src/components/controls/images/arrow.png +0 -0
  37. package/src/components/controls/images/error.png +0 -0
  38. package/src/components/controls/index.less +182 -0
  39. package/src/components/controls/index.tsx +312 -0
  40. package/src/components/history-control/images/collapse.png +0 -0
  41. package/src/components/history-control/index.less +211 -0
  42. package/src/components/history-control/index.stories.mdx +64 -0
  43. package/src/components/history-control/index.stories.tsx +140 -0
  44. package/src/components/history-control/index.tsx +344 -0
  45. package/src/components/history-player/index.less +98 -0
  46. package/src/components/history-player/index.stories.mdx +38 -0
  47. package/src/components/history-player/index.stories.tsx +12 -0
  48. package/src/components/history-player/index.tsx +205 -0
  49. package/src/components/live-channel-player/index.stories.mdx +29 -0
  50. package/src/components/live-channel-player/index.stories.tsx +11 -0
  51. package/src/components/live-channel-player/index.tsx +79 -0
  52. package/src/components/live-control/index.less +65 -0
  53. package/src/components/live-control/index.stories.mdx +66 -0
  54. package/src/components/live-control/index.stories.tsx +69 -0
  55. package/src/components/live-control/index.tsx +255 -0
  56. package/src/components/live-player/index.less +71 -0
  57. package/src/components/live-player/index.stories.mdx +35 -0
  58. package/src/components/live-player/index.stories.tsx +12 -0
  59. package/src/components/live-player/index.tsx +118 -0
  60. package/src/components/player/index.ts +293 -0
  61. package/src/context/index.ts +13 -0
  62. package/src/hooks/useSettings.tsx +14 -0
  63. package/src/icons/index.less +27 -0
  64. package/src/icons/index.tsx +518 -0
  65. package/src/main.ts +9 -0
  66. package/src/stories/intro.stories.mdx +16 -0
  67. package/src/typings/@vtx/utils/index.d.ts +27 -0
  68. package/src/typings/h5player.d.ts +133 -0
  69. package/src/utils/index.ts +177 -0
  70. package/src/vite-env.d.ts +1 -0
  71. package/tsconfig.json +24 -0
Binary file
@@ -0,0 +1 @@
1
+ "use strict";var Module={};var initializedJS=false;function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};self.onmessage=function(e){try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob==="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}JSPlayerModule(Module).then(function(instance){Module=instance})}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(Module["keepRuntimeAlive"]()){Module["PThread"].setExitStatus(result)}else{Module["__emscripten_thread_exit"](result)}}catch(ex){if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["__emscripten_thread_exit"](ex.status)}}else{Module["__emscripten_thread_exit"](-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}postMessage({"cmd":"cancelDone"})}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){Module["_emscripten_current_thread_process_queued_calls"]()}}else{err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){err("worker.js onmessage() captured an uncaught exception: "+ex);if(ex&&ex.stack)err(ex.stack);throw ex}};
@@ -0,0 +1,52 @@
1
+ import babel from '@rollup/plugin-babel';
2
+ import commonjs from '@rollup/plugin-commonjs';
3
+ import resolve from '@rollup/plugin-node-resolve';
4
+ import typescript from '@rollup/plugin-typescript';
5
+ import url from '@rollup/plugin-url';
6
+ import dts from 'rollup-plugin-dts';
7
+ import external from 'rollup-plugin-peer-deps-external';
8
+ import postcss from 'rollup-plugin-postcss';
9
+ import { terser } from 'rollup-plugin-terser';
10
+
11
+ const packageJson = require('./package.json');
12
+
13
+ export default [
14
+ {
15
+ input: 'src/main.ts',
16
+ output: [
17
+ // 构建cjs格式包
18
+ {
19
+ file: packageJson.main,
20
+ format: 'cjs',
21
+ sourcemap: true,
22
+ },
23
+ // 构建esm格式包
24
+ {
25
+ file: packageJson.module,
26
+ format: 'esm',
27
+ sourcemap: true,
28
+ },
29
+ ],
30
+ plugins: [
31
+ external(), // 排除peerDependencies中的包不被压缩到输出文件中
32
+ resolve(), // 添加rollup引用第三方包支持
33
+ babel({
34
+ exclude: 'node_modules/**',
35
+ presets: [['@babel/preset-env']],
36
+ babelHelpers: 'bundled',
37
+ }),
38
+ commonjs(), // 添加commonJs支持
39
+ postcss(), // 处理css文件
40
+ url(), // 处理图片文件
41
+ typescript({ tsconfig: './tsconfig.json' }), //处理 typescript文件
42
+ terser(), // 文件压缩
43
+ ],
44
+ },
45
+ {
46
+ // 打包d.ts文件
47
+ input: 'dist/types/main.d.ts',
48
+ output: [{ file: packageJson.types, format: 'esm' }],
49
+ external: [/\.less$/],
50
+ plugins: [dts()],
51
+ },
52
+ ];
@@ -0,0 +1,50 @@
1
+ interface VMFetchProps {
2
+ /** 请求体 */
3
+ data?: any;
4
+ /** 请求头 */
5
+ headersEx?: object;
6
+ }
7
+
8
+ /**
9
+ * 数据fetch总入口
10
+ * @param props
11
+ */
12
+ const Fetch = async <T>(
13
+ url: string,
14
+ type: 'GET' | 'POST' = 'GET',
15
+ params?: VMFetchProps
16
+ ): Promise<T> => {
17
+ const { data, headersEx } = params || {};
18
+ try {
19
+ let headers: HeadersInit = { 'content-type': 'application/json' };
20
+ if (headersEx) {
21
+ headers = { ...headers, ...headersEx };
22
+ }
23
+ if (type === 'GET' && data) {
24
+ const queryString = Object.keys(data)
25
+ .map((key) => key + '=' + data[key])
26
+ .join('&');
27
+
28
+ url += '?' + queryString;
29
+ }
30
+ const resp = await fetch(encodeURI(url), {
31
+ body: type === 'POST' ? JSON.stringify(data) : undefined,
32
+ headers,
33
+ method: type,
34
+ });
35
+
36
+ const json: Result<T> = await resp.json();
37
+ if (json.result === 0) return json.data;
38
+ else {
39
+ const error = {
40
+ exception: json.exception,
41
+ msg: json.msg,
42
+ };
43
+ throw error;
44
+ }
45
+ } catch (e) {
46
+ return Promise.reject(e);
47
+ }
48
+ };
49
+
50
+ export default Fetch;
@@ -0,0 +1,44 @@
1
+ import Fetch from './fetch';
2
+ import * as Types from './types';
3
+
4
+ /** 获取预览地址 */
5
+ export const getPreviewUrl = (data: Types.GetPreviewUrlParams) =>
6
+ Fetch<Types.GetPreviewUrlResp>('/cloud/vis/base/np/artemis/previewUrl.smvc', 'GET', {
7
+ data,
8
+ });
9
+
10
+ /** 获取历史地址 */
11
+ export const getHistoryUrl = (data: Types.GetHistoryUrlParams) =>
12
+ Fetch<Types.GetHistoryUrlResp>('/cloud/vis/base/np/artemis/playbackUrl.smvc', 'GET', {
13
+ data,
14
+ });
15
+
16
+ /** 获取视频信息 */
17
+ export const loadVideoInfo = (data: Types.LoadVideoInfoParams) =>
18
+ Fetch<Types.LoadVideoInfoResp>('/cloud/vis/base/np/videoCommon/loadVideoInfos.smvc', 'GET', {
19
+ data,
20
+ });
21
+
22
+ /** 云台控制 */
23
+ export const cloudControl = (data: Types.CloudControlParams) =>
24
+ Fetch('/cloud/vis/base/np/artemis/controlling.smvc', 'GET', {
25
+ data,
26
+ });
27
+
28
+ /**
29
+ * 获取通道信息
30
+ * @param channelId 通道ID
31
+ * @param tenantId 租户ID
32
+ * @returns
33
+ */
34
+ export const loadVideoChannel = async (channelId: string, tenantId: string) => {
35
+ const result = await Fetch<string>(
36
+ '/cloud/vis/base/np/videoDevice/loadTheVideoChannel.smvc',
37
+ 'GET',
38
+ {
39
+ data: { parameters: JSON.stringify({ videoChannelId: channelId, tenantId }) },
40
+ }
41
+ );
42
+ const parseResult = JSON.parse(result) as Types.LoadVideoChannelResp[];
43
+ return parseResult[0];
44
+ };
@@ -0,0 +1,141 @@
1
+ /** 获取预览地址Resp */
2
+ export interface GetPreviewUrlResp {
3
+ /** 对讲地址 */
4
+ apiUrl: string;
5
+ /** 地址 */
6
+ url: string;
7
+ /** 设备名称 */
8
+ deviceName: string;
9
+ /** 设备ID */
10
+ deviceId:string;
11
+ /** 通道名称 */
12
+ channelName: string;
13
+ /** 通道编号 */
14
+ channelNum:string;
15
+ /** 播放器 */
16
+ player: string | null;
17
+ /** 是否可以对讲,1为可以,0为不可以 */
18
+ beenHasVideo?: 1 | 0;
19
+ /** 云台类型,1全功能,2不能转动,3不能变焦,4无功能 */
20
+ ptzType?: 1 | 2 | 3 | 4;
21
+ }
22
+
23
+ /** 获取预览地址Params */
24
+ export interface GetPreviewUrlParams {
25
+ /** 租户ID */
26
+ tenantId: string;
27
+ /** 频道号 */
28
+ channelNum: string;
29
+ /** 设备ID */
30
+ deviceId: string;
31
+ /** 协议 */
32
+ protocol?: string;
33
+ }
34
+
35
+ /** 历史地址子项 */
36
+ export interface HistoryUrlItem {
37
+ /** 开始时间 */
38
+ beginTime: string;
39
+ /** 结束时间 */
40
+ endTime: string;
41
+ /** 回放地址 */
42
+ playbackUrl: string | null;
43
+ /** 大小 */
44
+ size: number;
45
+ }
46
+
47
+ /** 获取历史地址Resp */
48
+ export interface GetHistoryUrlResp {
49
+ /** 设备名称 */
50
+ deviceName: string;
51
+ /** 通道名称 */
52
+ channelName: string;
53
+ /** url列表 */
54
+ list: HistoryUrlItem[];
55
+ /** 播放器 */
56
+ player: string | null;
57
+ /** 全时播放地址 */
58
+ totalTimeUrl: string;
59
+ /** 地址 */
60
+ url: string;
61
+ }
62
+
63
+ /** 获取历史地址Params */
64
+ export interface GetHistoryUrlParams {
65
+ /** 租户ID */
66
+ tenantId: string;
67
+ /** 频道号 */
68
+ channelNum: string;
69
+ /** 设备ID */
70
+ deviceId: string;
71
+ /** 协议 */
72
+ protocol?: string;
73
+ /** 开始时间,格式:2022-06-01 00:00:00 */
74
+ beginTime: string;
75
+ /** 结束时间,格式:2022-06-01 23:59:59 */
76
+ endTime: string;
77
+ }
78
+
79
+ /** 获取视频信息Params */
80
+ export interface LoadVideoInfoParams {
81
+ /** 租户ID */
82
+ tenantId: string;
83
+ /** 业务ID */
84
+ billId: string;
85
+ }
86
+
87
+ export interface LoadVideoInfo {
88
+ /** 频道号 */
89
+ channelNum: string;
90
+ /** 设备ID */
91
+ videoDeviceId: string;
92
+ /** 通道名称 */
93
+ channelName: string;
94
+ }
95
+ /** 获取视频信息Resp */
96
+ export type LoadVideoInfoResp = LoadVideoInfo[];
97
+
98
+ /** 云台控制Params */
99
+ export type CloudControlParams = {
100
+ /** 租户ID */
101
+ tenantId: string;
102
+ /** 频道号 */
103
+ channelNum: string;
104
+ /** 设备ID */
105
+ deviceId: string;
106
+ /** 操作:1为按下,0为放开 */
107
+ action: 1 | 0;
108
+ /** 命令 */
109
+ command: CloudControlCommandType;
110
+ };
111
+
112
+ /** 云台控制命令 */
113
+ export type CloudControlCommandType =
114
+ | 'LEFT'
115
+ | 'RIGHT'
116
+ | 'UP'
117
+ | 'DOWN'
118
+ | 'LEFT_UP'
119
+ | 'LEFT_DOWN'
120
+ | 'RIGHT_UP'
121
+ | 'RIGHT_DOWN'
122
+ | 'ZOOM_IN'
123
+ | 'ZOOM_OUT'
124
+ | 'FOCUS_NEAR'
125
+ | 'FOCUS_FAR'
126
+ | 'IRIS_ENLARGE'
127
+ | 'IRIS_REDUCE';
128
+
129
+ export type LoadVideoChannelParams = {
130
+ /** 租户ID */
131
+ tenantId: string;
132
+ /** 通道ID */
133
+ videoChannelId: string;
134
+ };
135
+
136
+ export type LoadVideoChannelResp = {
137
+ /** 通道号 */
138
+ channelNum: string;
139
+ /** 设备ID */
140
+ videoDeviceId: string;
141
+ };
@@ -0,0 +1,58 @@
1
+ .vtx-bill-player {
2
+ .bill-tabs {
3
+ height: 100%;
4
+
5
+ .ant-tabs-content-holder {
6
+ height: 100%;
7
+
8
+ .ant-tabs-content {
9
+ height: 100%;
10
+ }
11
+ }
12
+ }
13
+
14
+ .player-panel {
15
+ display: flex;
16
+ height: 100%;
17
+
18
+ > .player-container {
19
+ flex-grow: 1;
20
+ width: 0;
21
+ }
22
+
23
+ .control-container {
24
+ width: 376px;
25
+ height: fit-content;
26
+ margin-left: 16px;
27
+ border: 1px solid #e8e8e8;
28
+ border-radius: 2px;
29
+
30
+ .header {
31
+ padding: 12px 24px;
32
+ font-weight: bold;
33
+ border-bottom: 1px solid #e8e8e8;
34
+ }
35
+
36
+ .list {
37
+ display: flex;
38
+ flex-direction: column;
39
+ padding: 12px 24px;
40
+
41
+ .ant-checkbox-wrapper {
42
+ margin-bottom: 12px;
43
+ margin-left: 0;
44
+ }
45
+ }
46
+
47
+ .form {
48
+ padding: 12px 24px;
49
+
50
+ .time-radio-group {
51
+ .ant-radio-wrapper {
52
+ margin-right: 4px;
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,24 @@
1
+ import BillPlayer from '.';
2
+ import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
3
+
4
+ import * as stories from './index.stories';
5
+
6
+ <Meta title="组件/业务播放器" component={BillPlayer} />
7
+
8
+ # 组件--按钮
9
+
10
+ ### 如何使用
11
+
12
+ ```js
13
+ import { BillPlayer } from '@vtx/player';
14
+ ```
15
+
16
+ ### 属性
17
+
18
+ <ArgsTable of={BillPlayer} />
19
+
20
+ ### 例子
21
+
22
+ <Canvas>
23
+ <Story name="业务播放器" story={stories.Default} />
24
+ </Canvas>
@@ -0,0 +1,14 @@
1
+ import BillPlayer from '.';
2
+ import { ComponentStory } from '@storybook/react';
3
+
4
+ const Template: ComponentStory<typeof BillPlayer> = (args) => <BillPlayer {...args} />;
5
+ export const Default = Template.bind({});
6
+ Default.args = {
7
+ width: 1200,
8
+ height: 600,
9
+ params: {
10
+ tenantId: '60edef2faea44a39a6385146f4fa131c',
11
+ billId: 'shxq_qqq',
12
+ },
13
+ };
14
+ export default Template;
@@ -0,0 +1,269 @@
1
+ import './index.less';
2
+
3
+ import { useRef } from 'react';
4
+
5
+ import HistoryControl, { HistoryControlHandle } from '../history-control';
6
+ import LiveControl, { LiveControlHandle } from '../live-control';
7
+ import { useRequest, useSetState } from 'ahooks';
8
+ import { Button, Checkbox, DatePicker, Form, Radio, RadioChangeEvent, Select, Tabs } from 'antd';
9
+ import moment from 'moment';
10
+
11
+ import { loadVideoInfo } from '@/api';
12
+ import { LoadVideoInfoParams } from '@/api/types';
13
+ import { TimeFormat } from '@/utils';
14
+
15
+ const { TabPane } = Tabs;
16
+
17
+ type HistoryFormData = {
18
+ /** 频道号 */
19
+ channelNum: string;
20
+ /** 开始时间,格式:2022-06-01 00:00:00 */
21
+ beginTime: string;
22
+ /** 结束时间,格式:2022-06-01 23:59:59 */
23
+ endTime: string;
24
+ };
25
+
26
+ interface State {
27
+ /** 日期选择器是否可用 */
28
+ datePickerDisabled: boolean;
29
+ /** 实时视频列表勾选状态 */
30
+ liveListState: Map<string, boolean>;
31
+ /** 设备ID */
32
+ deviceId: string;
33
+ }
34
+
35
+ interface BillPlayerProps {
36
+ /** 参数 */
37
+ params: LoadVideoInfoParams;
38
+ /** 宽度 */
39
+ width?: string | number;
40
+ /** 高度 */
41
+ height?: string | number;
42
+ /** 是否显示实时视频,默认为true */
43
+ live?: boolean;
44
+ /** 是否显示历史视频,默认为true */
45
+ history?: boolean;
46
+ /** 实时默认播放 */
47
+ defaultLivePlay?: boolean;
48
+ /** 历史默认播放 */
49
+ defaultHistoryPlay?: boolean;
50
+ }
51
+ export const BillPlayer = (props: BillPlayerProps) => {
52
+ const {
53
+ params,
54
+ live = true,
55
+ history = true,
56
+ height = '100%',
57
+ width = '100%',
58
+ defaultLivePlay = true,
59
+ } = props;
60
+ const [state, setState] = useSetState<State>({
61
+ datePickerDisabled: false,
62
+ liveListState: new Map(),
63
+ deviceId: '',
64
+ });
65
+ const { data } = useRequest(() => loadVideoInfo(params), {
66
+ refreshDeps: [params.billId],
67
+ onSuccess: (result) => {
68
+ if (defaultLivePlay) {
69
+ const livePlayer = liveRef.current;
70
+ if (livePlayer) {
71
+ const liveListState = new Map();
72
+ for (const item of result) {
73
+ liveListState.set(item.channelNum, true);
74
+ }
75
+ setState({ liveListState, deviceId: result[0].videoDeviceId });
76
+ livePlayer.multiLoad(
77
+ result.map((item) => ({
78
+ channelNum: item.channelNum,
79
+ deviceId: item.videoDeviceId,
80
+ tenantId: params.tenantId,
81
+ }))
82
+ );
83
+ }
84
+ }
85
+ form.setFieldsValue({ channelNum: result[0].channelNum });
86
+ },
87
+ });
88
+ const [form] = Form.useForm();
89
+ const liveRef = useRef<LiveControlHandle>(null);
90
+ const historyRef = useRef<HistoryControlHandle>(null);
91
+ const getLivePanel = () => {
92
+ const list = data?.map((item) => (
93
+ <Checkbox
94
+ key={item.channelNum}
95
+ checked={state.liveListState.get(item.channelNum)}
96
+ onChange={(e) => {
97
+ const checked = e.target.checked;
98
+ const liveControl = liveRef.current;
99
+ if (liveControl) {
100
+ if (checked) {
101
+ liveControl.load({ ...item, deviceId: item.videoDeviceId });
102
+ } else {
103
+ liveControl.unLoad(item.channelNum);
104
+ }
105
+ }
106
+ }}
107
+ >
108
+ {item.channelName}
109
+ </Checkbox>
110
+ ));
111
+ return (
112
+ <div className="player-panel">
113
+ <div className="player-container">
114
+ <LiveControl
115
+ ref={liveRef}
116
+ onChannelChange={(channelsNum) => {
117
+ const liveListState = new Map(state.liveListState);
118
+ for (const channelNum of channelsNum) {
119
+ liveListState.set(channelNum, !liveListState.get(channelNum));
120
+ }
121
+ for (const item of liveListState) {
122
+ if (channelsNum.includes(item[0])) liveListState.set(item[0], true);
123
+ else liveListState.set(item[0], false);
124
+ }
125
+ setState({ liveListState });
126
+ }}
127
+ />
128
+ </div>
129
+ <div className="control-container">
130
+ <div className="header">视频通道</div>
131
+ <div className="list">{list}</div>
132
+ </div>
133
+ </div>
134
+ );
135
+ };
136
+ const onHistorySubmit = (values: HistoryFormData) => {
137
+ const historyControl = historyRef.current;
138
+ historyControl?.load({
139
+ channelNum: values.channelNum,
140
+ tenantId: params.tenantId,
141
+ deviceId: state.deviceId,
142
+ beginTime: moment(values.beginTime).format(TimeFormat.default),
143
+ endTime: moment(values.endTime).format(TimeFormat.default),
144
+ });
145
+ };
146
+ const onTimeRadioChange = (e: RadioChangeEvent) => {
147
+ const value = e.target.value;
148
+ if (value === 'custom') {
149
+ setState({ datePickerDisabled: false });
150
+ } else {
151
+ setState({ datePickerDisabled: true });
152
+ if (value === 'today') {
153
+ form.setFieldsValue({
154
+ beginTime: moment().startOf('day'),
155
+ endTime: moment(),
156
+ });
157
+ }
158
+ if (value === 'yesterday') {
159
+ form.setFieldsValue({
160
+ beginTime: moment().subtract(1, 'day').startOf('day'),
161
+ endTime: moment().subtract(1, 'day').endOf('day'),
162
+ });
163
+ }
164
+ if (value === 'dayBeforeYesterday') {
165
+ form.setFieldsValue({
166
+ beginTime: moment().subtract(2, 'day').startOf('day'),
167
+ endTime: moment().subtract(2, 'day').endOf('day'),
168
+ });
169
+ }
170
+ }
171
+ };
172
+ const getHistoryPanel = () => {
173
+ return (
174
+ <div className="player-panel">
175
+ <div className="player-container">
176
+ <HistoryControl ref={historyRef} />
177
+ </div>
178
+ <div className="control-container">
179
+ <div className="header">查询视频</div>
180
+ <div className="form">
181
+ <Form
182
+ form={form}
183
+ name="history"
184
+ labelCol={{ span: 5 }}
185
+ wrapperCol={{ span: 19 }}
186
+ onFinish={onHistorySubmit}
187
+ requiredMark={false}
188
+ colon={false}
189
+ initialValues={{
190
+ beginTime: moment().subtract(1, 'day').startOf('day'),
191
+ endTime: moment().subtract(1, 'day').endOf('day'),
192
+ }}
193
+ autoComplete="off"
194
+ >
195
+ <Form.Item label="选择时段">
196
+ <Radio.Group
197
+ onChange={onTimeRadioChange}
198
+ defaultValue="custom"
199
+ className="time-radio-group"
200
+ >
201
+ <Radio value="today">当日</Radio>
202
+ <Radio value="yesterday">昨日</Radio>
203
+ <Radio value="dayBeforeYesterday">前日</Radio>
204
+ <Radio value="custom">自选</Radio>
205
+ </Radio.Group>
206
+ </Form.Item>
207
+ <Form.Item
208
+ label="开始时间"
209
+ name="beginTime"
210
+ rules={[{ required: true, message: '请输入开始时间' }]}
211
+ >
212
+ <DatePicker
213
+ style={{ width: '100%' }}
214
+ showTime
215
+ disabled={state.datePickerDisabled}
216
+ />
217
+ </Form.Item>
218
+ <Form.Item
219
+ label="结束时间"
220
+ name="endTime"
221
+ rules={[{ required: true, message: '请输入结束时间' }]}
222
+ >
223
+ <DatePicker showTime disabled={state.datePickerDisabled} />
224
+ </Form.Item>
225
+ <Form.Item
226
+ label="视频通道"
227
+ name="channelNum"
228
+ rules={[{ required: true, message: '请选择视频通道' }]}
229
+ >
230
+ <Select>
231
+ {data?.map((item) => (
232
+ <Select.Option
233
+ key={item.channelNum}
234
+ value={item.channelNum}
235
+ >
236
+ {item.channelName}
237
+ </Select.Option>
238
+ ))}
239
+ </Select>
240
+ </Form.Item>
241
+ <Form.Item wrapperCol={{ span: 24 }}>
242
+ <Button type="primary" htmlType="submit">
243
+ 查询
244
+ </Button>
245
+ </Form.Item>
246
+ </Form>
247
+ </div>
248
+ </div>
249
+ </div>
250
+ );
251
+ };
252
+ return (
253
+ <div className="vtx-bill-player" style={{ height, width }}>
254
+ {live && history && (
255
+ <Tabs defaultActiveKey="live" className="bill-tabs">
256
+ <TabPane tab="实时视频" key="live">
257
+ {getLivePanel()}
258
+ </TabPane>
259
+ <TabPane tab="历史视频" key="history">
260
+ {getHistoryPanel()}
261
+ </TabPane>
262
+ </Tabs>
263
+ )}
264
+ {live && !history && getLivePanel()}
265
+ {history && !live && getHistoryPanel()}
266
+ </div>
267
+ );
268
+ };
269
+ export default BillPlayer;