@vtx/player 0.0.7 → 0.0.8

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 (89) hide show
  1. package/dist/index.d.ts +221 -0
  2. package/dist/index.es.js +533 -0
  3. package/dist/index.es.js.map +1 -0
  4. package/dist/index.umd.js +533 -0
  5. package/dist/index.umd.js.map +1 -0
  6. package/dist/types/api/fetch.d.ts +12 -0
  7. package/dist/types/api/index.d.ts +15 -0
  8. package/{src/api/types.ts → dist/types/api/types.d.ts} +5 -29
  9. package/dist/types/components/bill-player/index.d.ts +21 -0
  10. package/dist/types/components/controls/index.d.ts +52 -0
  11. package/dist/types/components/history-control/index.d.ts +39 -0
  12. package/dist/types/components/history-player/index.d.ts +31 -0
  13. package/dist/types/components/live-channel-player/index.d.ts +16 -0
  14. package/dist/types/components/live-control/index.d.ts +35 -0
  15. package/dist/types/components/live-player/index.d.ts +22 -0
  16. package/dist/types/components/player/index.d.ts +84 -0
  17. package/dist/types/context/index.d.ts +8 -0
  18. package/dist/types/hooks/useSettings.d.ts +9 -0
  19. package/dist/types/icons/index.d.ts +54 -0
  20. package/{src/main.ts → dist/types/main.d.ts} +0 -1
  21. package/dist/types/utils/index.d.ts +67 -0
  22. package/package.json +2 -2
  23. package/.eslintignore +0 -11
  24. package/.eslintrc.js +0 -31
  25. package/.prettierignore +0 -10
  26. package/.prettierrc.js +0 -22
  27. package/.storybook/main.js +0 -58
  28. package/.storybook/manager.js +0 -7
  29. package/.storybook/preview-head.html +0 -5
  30. package/.storybook/preview.js +0 -9
  31. package/.storybook/proxy.js +0 -6
  32. package/.storybook/theme.js +0 -8
  33. package/.stylelintrc.json +0 -13
  34. package/.vscode/extensions.json +0 -10
  35. package/.vscode/settings.json +0 -16
  36. package/commitlint.config.js +0 -10
  37. package/public/h5player.min.js +0 -311
  38. package/public/playctrl1/AudioRenderer.js +0 -225
  39. package/public/playctrl1/DecodeWorker.js +0 -711
  40. package/public/playctrl1/Decoder.js +0 -1
  41. package/public/playctrl1/SuperRender_10.js +0 -396
  42. package/public/playctrl2/Decoder.js +0 -21
  43. package/public/playctrl2/Decoder.wasm +0 -0
  44. package/public/playctrl2/Decoder.worker.js +0 -1
  45. package/public/playctrl3/Decoder.js +0 -21
  46. package/public/playctrl3/Decoder.wasm +0 -0
  47. package/public/playctrl3/Decoder.worker.js +0 -1
  48. package/rollup.config.js +0 -52
  49. package/src/api/fetch.ts +0 -55
  50. package/src/api/index.ts +0 -43
  51. package/src/components/bill-player/index.less +0 -58
  52. package/src/components/bill-player/index.stories.mdx +0 -24
  53. package/src/components/bill-player/index.stories.tsx +0 -13
  54. package/src/components/bill-player/index.tsx +0 -267
  55. package/src/components/controls/images/arrow.png +0 -0
  56. package/src/components/controls/images/error.png +0 -0
  57. package/src/components/controls/index.less +0 -182
  58. package/src/components/controls/index.tsx +0 -312
  59. package/src/components/history-control/images/collapse.png +0 -0
  60. package/src/components/history-control/index.less +0 -211
  61. package/src/components/history-control/index.stories.mdx +0 -62
  62. package/src/components/history-control/index.stories.tsx +0 -130
  63. package/src/components/history-control/index.tsx +0 -368
  64. package/src/components/history-player/index.less +0 -98
  65. package/src/components/history-player/index.stories.mdx +0 -38
  66. package/src/components/history-player/index.stories.tsx +0 -12
  67. package/src/components/history-player/index.tsx +0 -206
  68. package/src/components/live-channel-player/index.stories.mdx +0 -29
  69. package/src/components/live-channel-player/index.stories.tsx +0 -11
  70. package/src/components/live-channel-player/index.tsx +0 -75
  71. package/src/components/live-control/index.less +0 -65
  72. package/src/components/live-control/index.stories.mdx +0 -64
  73. package/src/components/live-control/index.stories.tsx +0 -61
  74. package/src/components/live-control/index.tsx +0 -274
  75. package/src/components/live-player/index.less +0 -71
  76. package/src/components/live-player/index.stories.mdx +0 -35
  77. package/src/components/live-player/index.stories.tsx +0 -12
  78. package/src/components/live-player/index.tsx +0 -118
  79. package/src/components/player/index.ts +0 -318
  80. package/src/context/index.ts +0 -13
  81. package/src/hooks/useSettings.tsx +0 -14
  82. package/src/icons/index.less +0 -27
  83. package/src/icons/index.tsx +0 -518
  84. package/src/stories/intro.stories.mdx +0 -16
  85. package/src/typings/@vtx/utils/index.d.ts +0 -27
  86. package/src/typings/h5player.d.ts +0 -133
  87. package/src/utils/index.ts +0 -215
  88. package/src/vite-env.d.ts +0 -1
  89. package/tsconfig.json +0 -24
@@ -1,133 +0,0 @@
1
- import { CSSProperties } from 'react';
2
-
3
- declare global {
4
- declare class JSPlugin {
5
- constructor(params: JSPluginConstructorParams);
6
- /** 设置回调方法 */
7
- JS_SetWindowControlCallback(params: JSPluginCallbackParams);
8
- /**
9
- * 开始播放
10
- * @param url 流媒体地址
11
- * @param config 播放参数
12
- * @param windowIndex 当前窗口下标
13
- * @param startTime 开始时间
14
- * @param endTime 结束时间
15
- */
16
- JS_Play(
17
- url: string,
18
- config: PlayConfig,
19
- windowIndex: number,
20
- startTime?: string,
21
- endTime?: string
22
- ): Promise<void>;
23
-
24
- /**
25
- * 停止播放
26
- * @param windowIndex 窗口下标
27
- */
28
- JS_Stop(windowIndex: number): Promise<void>;
29
- /**
30
- * 截图
31
- * @param windowIndex 当前窗口
32
- * @param fileName 文件名称
33
- * @param fileType 文件类型
34
- * @param callback 回调
35
- */
36
- JS_CapturePicture(
37
- windowIndex: number,
38
- fileName: string,
39
- fileType: 'JPEG' | 'PNG',
40
- callback?: () => void
41
- );
42
- /**
43
- * 设置窗口大小
44
- * @param iWidth 宽度
45
- * @param iHeight 高度
46
- */
47
- JS_Resize(iWidth?: number, iHeight?: number);
48
- /**
49
- * 设置音量
50
- * @param windowIndex 当前窗口
51
- * @param value 音量
52
- */
53
- JS_SetVolume(windowIndex: number, value: number);
54
- /**
55
- * 跳转到
56
- * @param windowIndex 当前窗口
57
- * @param startTime 开始时间
58
- * @param endTime 结束时间
59
- */
60
- JS_Seek(windowIndex: number, startTime: string, endTime: string): Promise<void>;
61
- /**
62
- * 暂停播放
63
- * @param windowIndex 当前窗口
64
- */
65
- JS_Pause(windowIndex: number): Promise<void>;
66
- /**
67
- * 恢复播放
68
- * @param windowIndex 当前窗口
69
- */
70
- JS_Resume(windowIndex: number): Promise<void>;
71
- /**
72
- * 调节播放倍速为当前播放速度的2倍,最大为8倍
73
- * @param windowIndex 当前窗口
74
- */
75
- JS_Fast(windowIndex: number): Promise<void>;
76
- /**
77
- * 调节播放倍速为当前播放速度的1/2倍,最小为1/8倍
78
- * @param windowIndex 当前窗口
79
- */
80
- JS_Slow(windowIndex: number): Promise<void>;
81
- /**
82
- * 开始对讲
83
- * @param url 对讲地址
84
- */
85
- JS_StartTalk(url: string): Promise<void>;
86
- /** 结束对讲 */
87
- JS_StopTalk(): Promise<void>;
88
- }
89
- }
90
- type JSPluginConstructorParams = {
91
- /** 容器ID */
92
- szId: string;
93
- /** h5player.min.js引用路径 */
94
- szBasePath: string;
95
- /** 最大分屏数 */
96
- iMaxSplit: number;
97
- /** 当前分屏数 */
98
- iCurrentSplit: number;
99
- /** 开启调试模式 */
100
- openDebug?: boolean;
101
- /** 样式 */
102
- oStyle?: CSSProperties;
103
- /** 宽度 */
104
- iWidth?: number;
105
- /** 高度 */
106
- iHeight?: number;
107
- };
108
-
109
- type JSPluginCallbackParams = {
110
- /** 插件选中窗口回调 */
111
- windowEventSelect: (index: number) => void;
112
- /** 插件错误回调 */
113
- pluginErrorHandler: (index: number, code: string, error: object) => void;
114
- /** 鼠标移过回调 */
115
- windowEventOver: (index: number) => void;
116
- /** 鼠标移出回调 */
117
- windowEventOut: (index: number) => void;
118
- /** 鼠标mouseup事件回调 */
119
- windowEventUp: (index: number) => void;
120
- /** 全屏切换回调 */
121
- windowFullCcreenChange: (full: boolean) => void;
122
- /** 首帧显示回调 */
123
- firstFrameDisplay: (index: number, width: number, height: number) => void;
124
- /** 性能不足回调 */
125
- performanceLack: () => void;
126
- };
127
-
128
- type PlayConfig = {
129
- /** 播放地址 */
130
- playURL: string;
131
- /** 0=普通模式; 1=高级模式 默认为0 */
132
- mode: 0 | 1;
133
- };
@@ -1,215 +0,0 @@
1
- import { Base64 } from 'js-base64';
2
- import moment from 'moment';
3
-
4
- import { GetHistoryUrlResp } from '@/api/types';
5
- import { UrlsTableItemType } from '@/components/history-control';
6
- import { VideoType } from '@/components/player';
7
-
8
- /** 时间格式枚举 */
9
- export enum TimeFormat {
10
- default = 'YYYY-MM-DDTHH:mm:ss',
11
- params = 'YYYY-MM-DD HH:mm:ss',
12
- url = 'YYYYMMDDTHHmmss',
13
- }
14
-
15
- /** 生成随机ID */
16
- export const guidGenerator = () => {
17
- const S4 = function () {
18
- return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
19
- };
20
- return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4();
21
- };
22
-
23
- const initProtocol = (url: string): string => {
24
- let src = url;
25
- const isHttps = 'https:' === document.location.protocol;
26
- if (isHttps) {
27
- if (url.startsWith("http:")) {
28
- url = url.replace('http://', '');
29
- const ipPort = url.substring(0, url.indexOf('/'));
30
- const path = url.substring(url.indexOf('/'));
31
- src = '/visProxy/' + ipPort + '/play' + path;
32
- } else if (url.startsWith("ws:")) {
33
- url = url.replace('http://', '');
34
- const ipPort = url.substring(0, url.indexOf('/'));
35
- const path = url.substring(url.indexOf('/'));
36
- src = 'wss://' + window.location.host + '/visProxy/' + ipPort + '/play' + path;
37
- }
38
- }
39
- return src;
40
- }
41
-
42
- type PlayerParams = {
43
- /** 视频流地址 */
44
- url: string;
45
- /** 视频流格式 */
46
- type: VideoType;
47
- };
48
- /**
49
- * 获取视频直播地址及格式
50
- * @param url
51
- * @returns
52
- */
53
- export const getPlayerParams = (
54
- url: string,
55
- live: boolean,
56
- startTime?: moment.MomentInput,
57
- endTime?: moment.MomentInput
58
- ): PlayerParams => {
59
- let playerUrl = url;
60
- let playerType: VideoType = 'flv';
61
- if (url.startsWith('ws://')) {
62
- playerType = 'hk_ws';
63
- if (live) {
64
- playerUrl = url;
65
- } else {
66
- playerUrl = url.split('?')[0];
67
- }
68
- }
69
- if (url.startsWith('rtsp://')) {
70
- playerType = 'flv';
71
- if (live) {
72
- playerUrl = `/cloud/vic/convert/flv/live.flv?url=${Base64.encode(
73
- url
74
- )}`;
75
- } else {
76
- playerUrl = `/cloud/vic/convert/flv/live.flv?url=${Base64.encode(
77
- getFlvListUrl(url, startTime, endTime)
78
- )}`;
79
- }
80
- }
81
- if (url.endsWith('.m3u8')) {
82
- playerUrl = url;
83
- playerType = 'hls';
84
- }
85
- return { url: initProtocol(playerUrl), type: playerType };
86
- };
87
-
88
- /**
89
- * 获取历史回放表格数据
90
- * @param data
91
- * @returns
92
- */
93
- export const getUrlTableData = (data: GetHistoryUrlResp): UrlsTableItemType[] => {
94
- const result: UrlsTableItemType[] = data.list.map((item, i) => {
95
- const beginTime = moment(item.beginTime);
96
- const endTime = moment(item.endTime);
97
- const totalSeconds = moment(endTime).diff(moment(beginTime), 'seconds');
98
- return {
99
- index: i + 1,
100
- deviceName: data.deviceName,
101
- channelName: data.channelName,
102
- beginTime: beginTime.format(TimeFormat.params),
103
- endTime: endTime.format(TimeFormat.params),
104
- size: bytesToMegaBytes(item.size),
105
- duration: secondsToString(totalSeconds),
106
- downloadUrl: '',
107
- url: item.playbackUrl || '',
108
- };
109
- });
110
- return result;
111
- };
112
-
113
- /**
114
- * bytes转换mb
115
- * @param bytes
116
- * @returns
117
- */
118
- const bytesToMegaBytes = (bytes: number) => `${(bytes / 1024 ** 2).toFixed(2)}MB`;
119
-
120
- /**
121
- * 秒数=>0时0分0秒
122
- * @param total
123
- * @returns
124
- */
125
- const secondsToString = (total: number) => {
126
- const hour = Math.floor(total / 3600);
127
- const minute = Math.floor((total % 3600) / 60);
128
- const second = Math.floor(total % 60);
129
- const result = `${hour > 0 ? hour + '小时' : ''}${minute > 0 ? minute + '分' : ''}${
130
- second > 0 ? second + '秒' : ''
131
- }`;
132
- return result;
133
- };
134
-
135
- /**
136
- * 秒数=>00:00:00
137
- * @param total
138
- * @returns
139
- */
140
- export const secondsToTime = (total: number) => {
141
- const hour = Math.floor(total / 3600);
142
- const minute = Math.floor((total % 3600) / 60);
143
- const second = Math.floor(total % 60);
144
- const result = `${hour >= 10 ? hour : '0' + hour}:${minute >= 10 ? minute : '0' + minute}:${
145
- second >= 10 ? second : '0' + second
146
- }`;
147
- return result;
148
- };
149
-
150
- /**
151
- * 获取海康时间参数
152
- * @param time 时间
153
- * @returns
154
- */
155
- export const getHKTimeString = (time: moment.MomentInput) => {
156
- return moment(time).format(TimeFormat.default) + 'Z';
157
- };
158
-
159
- /**
160
- * 获取海康分段播放地址
161
- * @param totalUrl 总播放地址
162
- * @param startTime 开始时间
163
- * @param endTime 结束时间
164
- * @returns
165
- */
166
- export const getHKListUrl = (
167
- totalUrl: string,
168
- startTime: moment.MomentInput,
169
- endTime: moment.MomentInput
170
- ) => {
171
- const [url, query] = totalUrl.split('?');
172
- const urlParams = new URLSearchParams(query);
173
- urlParams.set('beginTime', getHKTimeString(startTime));
174
- urlParams.set('endTime', getHKTimeString(endTime));
175
- return `${url}?${urlParams.toString()}`;
176
- };
177
-
178
- /**
179
- *
180
- * 获取flv格式分段播放地址
181
- * @param totalUrl 总播放地址
182
- * @param startTime 开始时间
183
- * @param endTime 结束时间
184
- * @returns
185
- */
186
- export const getFlvListUrl = (
187
- totalUrl: string,
188
- startTime: moment.MomentInput,
189
- endTime: moment.MomentInput
190
- ) => {
191
- const [url, query] = totalUrl.split('?');
192
- const urlParams = new URLSearchParams(query);
193
- urlParams.set('beginTime', moment(startTime).format(TimeFormat.url));
194
- urlParams.set('endTime', moment(endTime).format(TimeFormat.url));
195
- return `${url}?${urlParams.toString()}`;
196
- };
197
- /**
198
- * 获取地址栏中的参数信息
199
- * @param key 字段key
200
- * @param href 链接
201
- * @returns 字段值
202
- */
203
- export const getUrlParam = (key?: string, href: string = window.location.href) => {
204
- const paramObj: any = {};
205
- const matchList = href.match(/([^\?&]+)=([^\?&#]+)/g) || [];
206
- for (let i = 0, len = matchList.length; i < len; i++) {
207
- const r: any = matchList[i].match(/([^\?&]+)=([^\?&]+)/);
208
- paramObj[r[1]] = r[2];
209
- }
210
- if (key) {
211
- return paramObj[key];
212
- } else {
213
- return paramObj;
214
- }
215
- };
package/src/vite-env.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "module": "esnext",
5
- "jsx": "react-jsx",
6
- "declaration": true,
7
- "declarationDir": "types",
8
- "sourceMap": true,
9
- "outDir": "dist",
10
- "strict": true,
11
- "moduleResolution": "node",
12
- "allowSyntheticDefaultImports": true,
13
- "esModuleInterop": true,
14
- "skipLibCheck": true,
15
- "forceConsistentCasingInFileNames": true,
16
- "downlevelIteration": true,
17
- "emitDeclarationOnly": true,
18
- "baseUrl": "./",
19
- "paths": {
20
- "@/*": ["src/*"]
21
- }
22
- },
23
- "exclude": ["src/**/*.stories.tsx"],
24
- }