@vtx/player 0.0.12 → 0.0.13
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/{dist/types → lib}/api/fetch.d.ts +0 -0
- package/lib/api/fetch.js +128 -0
- package/lib/api/fetch.js.map +1 -0
- package/{dist/types → lib}/api/index.d.ts +0 -0
- package/lib/api/index.js +124 -0
- package/lib/api/index.js.map +1 -0
- package/{dist/types → lib}/api/types.d.ts +0 -0
- package/lib/api/types.js +6 -0
- package/lib/api/types.js.map +1 -0
- package/{dist/types/components → lib}/bill-player/index.d.ts +0 -2
- package/lib/bill-player/index.js +410 -0
- package/lib/bill-player/index.js.map +1 -0
- package/lib/bill-player/style/css.js +22 -0
- package/lib/bill-player/style/css.js.map +1 -0
- package/lib/bill-player/style/index.css +55 -0
- package/lib/bill-player/style/index.d.ts +10 -0
- package/lib/bill-player/style/index.js +22 -0
- package/lib/bill-player/style/index.js.map +1 -0
- package/lib/bill-player/style/index.less +58 -0
- package/lib/components/live-control/images/empty.png +0 -0
- package/{dist/types → lib}/context/index.d.ts +0 -0
- package/lib/context/index.js +20 -0
- package/lib/context/index.js.map +1 -0
- package/lib/controls/images/arrow.png +0 -0
- package/lib/controls/images/error.png +0 -0
- package/{dist/types/components → lib}/controls/index.d.ts +8 -2
- package/lib/controls/index.js +474 -0
- package/lib/controls/index.js.map +1 -0
- package/lib/controls/style/css.js +4 -0
- package/lib/controls/style/css.js.map +1 -0
- package/lib/controls/style/index.css +185 -0
- package/lib/controls/style/index.d.ts +1 -0
- package/lib/controls/style/index.js +4 -0
- package/lib/controls/style/index.js.map +1 -0
- package/lib/controls/style/index.less +187 -0
- package/lib/history-control/images/collapse.png +0 -0
- package/lib/history-control/images/empty.png +0 -0
- package/{dist/types/components → lib}/history-control/index.d.ts +4 -1
- package/lib/history-control/index.js +506 -0
- package/lib/history-control/index.js.map +1 -0
- package/lib/history-control/style/css.js +6 -0
- package/lib/history-control/style/css.js.map +1 -0
- package/lib/history-control/style/index.css +195 -0
- package/lib/history-control/style/index.d.ts +2 -0
- package/lib/history-control/style/index.js +6 -0
- package/lib/history-control/style/index.js.map +1 -0
- package/lib/history-control/style/index.less +219 -0
- package/{dist/types/components → lib}/history-player/index.d.ts +7 -4
- package/lib/history-player/index.js +276 -0
- package/lib/history-player/index.js.map +1 -0
- package/lib/history-player/style/css.js +6 -0
- package/lib/history-player/style/css.js.map +1 -0
- package/lib/history-player/style/index.css +105 -0
- package/lib/history-player/style/index.d.ts +2 -0
- package/lib/history-player/style/index.js +6 -0
- package/lib/history-player/style/index.js.map +1 -0
- package/lib/history-player/style/index.less +98 -0
- package/{dist/types → lib}/hooks/useSettings.d.ts +0 -0
- package/lib/hooks/useSettings.js +28 -0
- package/lib/hooks/useSettings.js.map +1 -0
- package/lib/icons/index.css +28 -0
- package/{dist/types → lib}/icons/index.d.ts +0 -0
- package/lib/icons/index.js +788 -0
- package/lib/icons/index.js.map +1 -0
- package/lib/icons/index.less +27 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +64 -0
- package/lib/index.js.map +1 -0
- package/{dist/types/components → lib}/live-channel-player/index.d.ts +1 -2
- package/lib/live-channel-player/index.js +164 -0
- package/lib/live-channel-player/index.js.map +1 -0
- package/lib/live-channel-player/style/css.js +6 -0
- package/lib/live-channel-player/style/css.js.map +1 -0
- package/lib/live-channel-player/style/index.d.ts +2 -0
- package/lib/live-channel-player/style/index.js +6 -0
- package/lib/live-channel-player/style/index.js.map +1 -0
- package/lib/live-control/images/empty.png +0 -0
- package/{dist/types/components → lib}/live-control/index.d.ts +6 -3
- package/lib/live-control/index.js +381 -0
- package/lib/live-control/index.js.map +1 -0
- package/lib/live-control/style/css.js +6 -0
- package/lib/live-control/style/css.js.map +1 -0
- package/lib/live-control/style/index.css +73 -0
- package/lib/live-control/style/index.d.ts +2 -0
- package/lib/live-control/style/index.js +6 -0
- package/lib/live-control/style/index.js.map +1 -0
- package/lib/live-control/style/index.less +65 -0
- package/{dist/types/components → lib}/live-player/index.d.ts +6 -4
- package/lib/live-player/index.js +178 -0
- package/lib/live-player/index.js.map +1 -0
- package/lib/live-player/style/css.js +6 -0
- package/lib/live-player/style/css.js.map +1 -0
- package/lib/live-player/style/index.css +83 -0
- package/lib/live-player/style/index.d.ts +2 -0
- package/lib/live-player/style/index.js +6 -0
- package/lib/live-player/style/index.js.map +1 -0
- package/lib/live-player/style/index.less +70 -0
- package/{dist/types/components → lib}/player/index.d.ts +5 -0
- package/lib/player/index.js +476 -0
- package/lib/player/index.js.map +1 -0
- package/lib/player/style/css.js +2 -0
- package/lib/player/style/css.js.map +1 -0
- package/lib/player/style/index.d.ts +1 -0
- package/lib/player/style/index.js +2 -0
- package/lib/player/style/index.js.map +1 -0
- package/lib/typings/@vtx/utils/index.d.ts +27 -0
- package/lib/typings/h5player.d.ts +131 -0
- package/{dist/types → lib}/utils/index.d.ts +3 -3
- package/lib/utils/index.js +265 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/vite-env.d.ts +1 -0
- package/package.json +2 -2
- package/dist/index.d.ts +0 -221
- 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/main.d.ts +0 -8
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
export declare class JSPlugin {
|
|
4
|
+
constructor(params: JSPluginConstructorParams);
|
|
5
|
+
/** 设置回调方法 */
|
|
6
|
+
JS_SetWindowControlCallback(params: JSPluginCallbackParams);
|
|
7
|
+
/**
|
|
8
|
+
* 开始播放
|
|
9
|
+
* @param url 流媒体地址
|
|
10
|
+
* @param config 播放参数
|
|
11
|
+
* @param windowIndex 当前窗口下标
|
|
12
|
+
* @param startTime 开始时间
|
|
13
|
+
* @param endTime 结束时间
|
|
14
|
+
*/
|
|
15
|
+
JS_Play(
|
|
16
|
+
url: string,
|
|
17
|
+
config: PlayConfig,
|
|
18
|
+
windowIndex: number,
|
|
19
|
+
startTime?: string,
|
|
20
|
+
endTime?: string
|
|
21
|
+
): Promise<void>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 停止播放
|
|
25
|
+
* @param windowIndex 窗口下标
|
|
26
|
+
*/
|
|
27
|
+
JS_Stop(windowIndex: number): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* 截图
|
|
30
|
+
* @param windowIndex 当前窗口
|
|
31
|
+
* @param fileName 文件名称
|
|
32
|
+
* @param fileType 文件类型
|
|
33
|
+
* @param callback 回调
|
|
34
|
+
*/
|
|
35
|
+
JS_CapturePicture(
|
|
36
|
+
windowIndex: number,
|
|
37
|
+
fileName: string,
|
|
38
|
+
fileType: 'JPEG' | 'PNG',
|
|
39
|
+
callback?: () => void
|
|
40
|
+
);
|
|
41
|
+
/**
|
|
42
|
+
* 设置窗口大小
|
|
43
|
+
* @param iWidth 宽度
|
|
44
|
+
* @param iHeight 高度
|
|
45
|
+
*/
|
|
46
|
+
JS_Resize(iWidth?: number, iHeight?: number);
|
|
47
|
+
/**
|
|
48
|
+
* 设置音量
|
|
49
|
+
* @param windowIndex 当前窗口
|
|
50
|
+
* @param value 音量
|
|
51
|
+
*/
|
|
52
|
+
JS_SetVolume(windowIndex: number, value: number);
|
|
53
|
+
/**
|
|
54
|
+
* 跳转到
|
|
55
|
+
* @param windowIndex 当前窗口
|
|
56
|
+
* @param startTime 开始时间
|
|
57
|
+
* @param endTime 结束时间
|
|
58
|
+
*/
|
|
59
|
+
JS_Seek(windowIndex: number, startTime: string, endTime: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* 暂停播放
|
|
62
|
+
* @param windowIndex 当前窗口
|
|
63
|
+
*/
|
|
64
|
+
JS_Pause(windowIndex: number): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* 恢复播放
|
|
67
|
+
* @param windowIndex 当前窗口
|
|
68
|
+
*/
|
|
69
|
+
JS_Resume(windowIndex: number): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* 调节播放倍速为当前播放速度的2倍,最大为8倍
|
|
72
|
+
* @param windowIndex 当前窗口
|
|
73
|
+
*/
|
|
74
|
+
JS_Fast(windowIndex: number): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* 调节播放倍速为当前播放速度的1/2倍,最小为1/8倍
|
|
77
|
+
* @param windowIndex 当前窗口
|
|
78
|
+
*/
|
|
79
|
+
JS_Slow(windowIndex: number): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* 开始对讲
|
|
82
|
+
* @param url 对讲地址
|
|
83
|
+
*/
|
|
84
|
+
JS_StartTalk(url: string): Promise<void>;
|
|
85
|
+
/** 结束对讲 */
|
|
86
|
+
JS_StopTalk(): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
type JSPluginConstructorParams = {
|
|
89
|
+
/** 容器ID */
|
|
90
|
+
szId: string;
|
|
91
|
+
/** h5player.min.js引用路径 */
|
|
92
|
+
szBasePath: string;
|
|
93
|
+
/** 最大分屏数 */
|
|
94
|
+
iMaxSplit: number;
|
|
95
|
+
/** 当前分屏数 */
|
|
96
|
+
iCurrentSplit: number;
|
|
97
|
+
/** 开启调试模式 */
|
|
98
|
+
openDebug?: boolean;
|
|
99
|
+
/** 样式 */
|
|
100
|
+
oStyle?: CSSProperties;
|
|
101
|
+
/** 宽度 */
|
|
102
|
+
iWidth?: number;
|
|
103
|
+
/** 高度 */
|
|
104
|
+
iHeight?: number;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
type JSPluginCallbackParams = {
|
|
108
|
+
/** 插件选中窗口回调 */
|
|
109
|
+
windowEventSelect: (index: number) => void;
|
|
110
|
+
/** 插件错误回调 */
|
|
111
|
+
pluginErrorHandler: (index: number, code: string, error: object) => void;
|
|
112
|
+
/** 鼠标移过回调 */
|
|
113
|
+
windowEventOver: (index: number) => void;
|
|
114
|
+
/** 鼠标移出回调 */
|
|
115
|
+
windowEventOut: (index: number) => void;
|
|
116
|
+
/** 鼠标mouseup事件回调 */
|
|
117
|
+
windowEventUp: (index: number) => void;
|
|
118
|
+
/** 全屏切换回调 */
|
|
119
|
+
windowFullCcreenChange: (full: boolean) => void;
|
|
120
|
+
/** 首帧显示回调 */
|
|
121
|
+
firstFrameDisplay: (index: number, width: number, height: number) => void;
|
|
122
|
+
/** 性能不足回调 */
|
|
123
|
+
performanceLack: () => void;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
type PlayConfig = {
|
|
127
|
+
/** 播放地址 */
|
|
128
|
+
playURL: string;
|
|
129
|
+
/** 0=普通模式; 1=高级模式 默认为0 */
|
|
130
|
+
mode: 0 | 1;
|
|
131
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import moment from 'moment';
|
|
2
|
-
import { GetHistoryUrlResp } from '
|
|
3
|
-
import { UrlsTableItemType } from '
|
|
4
|
-
import { VideoType } from '
|
|
2
|
+
import { GetHistoryUrlResp } from '../api/types';
|
|
3
|
+
import { UrlsTableItemType } from '../history-control';
|
|
4
|
+
import { VideoType } from '../player';
|
|
5
5
|
/** 时间格式枚举 */
|
|
6
6
|
export declare enum TimeFormat {
|
|
7
7
|
default = "YYYY-MM-DDTHH:mm:ss",
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.secondsToTime = exports.guidGenerator = exports.getUrlTableData = exports.getUrlParam = exports.getPlayerParams = exports.getHKTimeString = exports.getHKListUrl = exports.getFlvListUrl = exports.TimeFormat = void 0;
|
|
7
|
+
|
|
8
|
+
var _jsBase = require("js-base64");
|
|
9
|
+
|
|
10
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
|
|
14
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
|
+
|
|
16
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
+
|
|
18
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
19
|
+
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
21
|
+
|
|
22
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
23
|
+
|
|
24
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
|
+
|
|
26
|
+
/** 时间格式枚举 */
|
|
27
|
+
var TimeFormat;
|
|
28
|
+
exports.TimeFormat = TimeFormat;
|
|
29
|
+
|
|
30
|
+
(function (TimeFormat) {
|
|
31
|
+
TimeFormat["default"] = "YYYY-MM-DDTHH:mm:ss";
|
|
32
|
+
TimeFormat["params"] = "YYYY-MM-DD HH:mm:ss";
|
|
33
|
+
TimeFormat["url"] = "YYYYMMDDTHHmmss";
|
|
34
|
+
})(TimeFormat || (exports.TimeFormat = TimeFormat = {}));
|
|
35
|
+
/** 生成随机ID */
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
var guidGenerator = function guidGenerator() {
|
|
39
|
+
var S4 = function S4() {
|
|
40
|
+
return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4();
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.guidGenerator = guidGenerator;
|
|
47
|
+
|
|
48
|
+
var initProtocol = function initProtocol(url) {
|
|
49
|
+
var src = url;
|
|
50
|
+
var isHttps = 'https:' === document.location.protocol;
|
|
51
|
+
|
|
52
|
+
if (isHttps) {
|
|
53
|
+
if (url.startsWith("http:")) {
|
|
54
|
+
url = url.replace('http://', '');
|
|
55
|
+
var ipPort = url.substring(0, url.indexOf('/'));
|
|
56
|
+
var path = url.substring(url.indexOf('/'));
|
|
57
|
+
src = '/visProxy/' + ipPort + '/play' + path;
|
|
58
|
+
} else if (url.startsWith("ws:")) {
|
|
59
|
+
url = url.replace('http://', '');
|
|
60
|
+
|
|
61
|
+
var _ipPort = url.substring(0, url.indexOf('/'));
|
|
62
|
+
|
|
63
|
+
var _path = url.substring(url.indexOf('/'));
|
|
64
|
+
|
|
65
|
+
src = 'wss://' + window.location.host + '/visProxy/' + _ipPort + '/play' + _path;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return src;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* 获取视频直播地址及格式
|
|
73
|
+
* @param url
|
|
74
|
+
* @returns
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
var getPlayerParams = function getPlayerParams(url, live, startTime, endTime) {
|
|
79
|
+
var playerUrl = url;
|
|
80
|
+
var playerType = 'flv';
|
|
81
|
+
|
|
82
|
+
if (url.startsWith('ws://')) {
|
|
83
|
+
playerType = 'hk_ws';
|
|
84
|
+
|
|
85
|
+
if (live) {
|
|
86
|
+
playerUrl = url;
|
|
87
|
+
} else {
|
|
88
|
+
playerUrl = url.split('?')[0];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (url.startsWith('rtsp://')) {
|
|
93
|
+
playerType = 'flv';
|
|
94
|
+
|
|
95
|
+
if (live) {
|
|
96
|
+
playerUrl = "/cloud/vic/convert/flv/live.flv?url=".concat(_jsBase.Base64.encode(url));
|
|
97
|
+
} else {
|
|
98
|
+
playerUrl = "/cloud/vic/convert/flv/live.flv?url=".concat(_jsBase.Base64.encode(getFlvListUrl(url, startTime, endTime)));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (url.endsWith('.m3u8')) {
|
|
103
|
+
playerUrl = url;
|
|
104
|
+
playerType = 'hls';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
url: initProtocol(playerUrl),
|
|
109
|
+
type: playerType
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* 获取历史回放表格数据
|
|
114
|
+
* @param data
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
exports.getPlayerParams = getPlayerParams;
|
|
120
|
+
|
|
121
|
+
var getUrlTableData = function getUrlTableData(data) {
|
|
122
|
+
var result = data.list.map(function (item, i) {
|
|
123
|
+
var beginTime = (0, _moment["default"])(item.beginTime);
|
|
124
|
+
var endTime = (0, _moment["default"])(item.endTime);
|
|
125
|
+
var totalSeconds = (0, _moment["default"])(endTime).diff((0, _moment["default"])(beginTime), 'seconds');
|
|
126
|
+
return {
|
|
127
|
+
index: i + 1,
|
|
128
|
+
deviceName: data.deviceName,
|
|
129
|
+
channelName: data.channelName,
|
|
130
|
+
beginTime: beginTime.format(TimeFormat.params),
|
|
131
|
+
endTime: endTime.format(TimeFormat.params),
|
|
132
|
+
size: bytesToMegaBytes(item.size),
|
|
133
|
+
duration: secondsToString(totalSeconds),
|
|
134
|
+
downloadUrl: '',
|
|
135
|
+
url: item.playbackUrl || ''
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
return result;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* bytes转换mb
|
|
142
|
+
* @param bytes
|
|
143
|
+
* @returns
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
exports.getUrlTableData = getUrlTableData;
|
|
148
|
+
|
|
149
|
+
var bytesToMegaBytes = function bytesToMegaBytes(bytes) {
|
|
150
|
+
return "".concat((bytes / Math.pow(1024, 2)).toFixed(2), "MB");
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* 秒数=>0时0分0秒
|
|
154
|
+
* @param total
|
|
155
|
+
* @returns
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
var secondsToString = function secondsToString(total) {
|
|
160
|
+
var hour = Math.floor(total / 3600);
|
|
161
|
+
var minute = Math.floor(total % 3600 / 60);
|
|
162
|
+
var second = Math.floor(total % 60);
|
|
163
|
+
var result = "".concat(hour > 0 ? hour + '小时' : '').concat(minute > 0 ? minute + '分' : '').concat(second > 0 ? second + '秒' : '');
|
|
164
|
+
return result;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* 秒数=>00:00:00
|
|
168
|
+
* @param total
|
|
169
|
+
* @returns
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
var secondsToTime = function secondsToTime(total) {
|
|
174
|
+
var hour = Math.floor(total / 3600);
|
|
175
|
+
var minute = Math.floor(total % 3600 / 60);
|
|
176
|
+
var second = Math.floor(total % 60);
|
|
177
|
+
var result = "".concat(hour >= 10 ? hour : '0' + hour, ":").concat(minute >= 10 ? minute : '0' + minute, ":").concat(second >= 10 ? second : '0' + second);
|
|
178
|
+
return result;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* 获取海康时间参数
|
|
182
|
+
* @param time 时间
|
|
183
|
+
* @returns
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
exports.secondsToTime = secondsToTime;
|
|
188
|
+
|
|
189
|
+
var getHKTimeString = function getHKTimeString(time) {
|
|
190
|
+
return (0, _moment["default"])(time).format(TimeFormat["default"]) + 'Z';
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* 获取海康分段播放地址
|
|
194
|
+
* @param totalUrl 总播放地址
|
|
195
|
+
* @param startTime 开始时间
|
|
196
|
+
* @param endTime 结束时间
|
|
197
|
+
* @returns
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
exports.getHKTimeString = getHKTimeString;
|
|
202
|
+
|
|
203
|
+
var getHKListUrl = function getHKListUrl(totalUrl, startTime, endTime) {
|
|
204
|
+
var _totalUrl$split = totalUrl.split('?'),
|
|
205
|
+
_totalUrl$split2 = _slicedToArray(_totalUrl$split, 2),
|
|
206
|
+
url = _totalUrl$split2[0],
|
|
207
|
+
query = _totalUrl$split2[1];
|
|
208
|
+
|
|
209
|
+
var urlParams = new URLSearchParams(query);
|
|
210
|
+
urlParams.set('beginTime', getHKTimeString(startTime));
|
|
211
|
+
urlParams.set('endTime', getHKTimeString(endTime));
|
|
212
|
+
return "".concat(url, "?").concat(urlParams.toString());
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
*
|
|
216
|
+
* 获取flv格式分段播放地址
|
|
217
|
+
* @param totalUrl 总播放地址
|
|
218
|
+
* @param startTime 开始时间
|
|
219
|
+
* @param endTime 结束时间
|
|
220
|
+
* @returns
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
exports.getHKListUrl = getHKListUrl;
|
|
225
|
+
|
|
226
|
+
var getFlvListUrl = function getFlvListUrl(totalUrl, startTime, endTime) {
|
|
227
|
+
var _totalUrl$split3 = totalUrl.split('?'),
|
|
228
|
+
_totalUrl$split4 = _slicedToArray(_totalUrl$split3, 2),
|
|
229
|
+
url = _totalUrl$split4[0],
|
|
230
|
+
query = _totalUrl$split4[1];
|
|
231
|
+
|
|
232
|
+
var urlParams = new URLSearchParams(query);
|
|
233
|
+
urlParams.set('beginTime', (0, _moment["default"])(startTime).format(TimeFormat.url));
|
|
234
|
+
urlParams.set('endTime', (0, _moment["default"])(endTime).format(TimeFormat.url));
|
|
235
|
+
return "".concat(url, "?").concat(urlParams.toString());
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* 获取地址栏中的参数信息
|
|
239
|
+
* @param key 字段key
|
|
240
|
+
* @param href 链接
|
|
241
|
+
* @returns 字段值
|
|
242
|
+
*/
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
exports.getFlvListUrl = getFlvListUrl;
|
|
246
|
+
|
|
247
|
+
var getUrlParam = function getUrlParam(key) {
|
|
248
|
+
var href = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location.href;
|
|
249
|
+
var paramObj = {};
|
|
250
|
+
var matchList = href.match(/([^\?&]+)=([^\?&#]+)/g) || [];
|
|
251
|
+
|
|
252
|
+
for (var i = 0, len = matchList.length; i < len; i++) {
|
|
253
|
+
var r = matchList[i].match(/([^\?&]+)=([^\?&]+)/);
|
|
254
|
+
paramObj[r[1]] = r[2];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (key) {
|
|
258
|
+
return paramObj[key];
|
|
259
|
+
} else {
|
|
260
|
+
return paramObj;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
exports.getUrlParam = getUrlParam;
|
|
265
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["TimeFormat","guidGenerator","S4","Math","random","toString","substring","initProtocol","url","src","isHttps","document","location","protocol","startsWith","replace","ipPort","indexOf","path","window","host","getPlayerParams","live","startTime","endTime","playerUrl","playerType","split","Base64","encode","getFlvListUrl","endsWith","type","getUrlTableData","data","result","list","map","item","i","beginTime","moment","totalSeconds","diff","index","deviceName","channelName","format","params","size","bytesToMegaBytes","duration","secondsToString","downloadUrl","playbackUrl","bytes","pow","toFixed","total","hour","floor","minute","second","secondsToTime","getHKTimeString","time","getHKListUrl","totalUrl","query","urlParams","URLSearchParams","set","getUrlParam","key","href","paramObj","matchList","match","len","length","r"],"sources":["utils/index.js"],"sourcesContent":["import { Base64 } from 'js-base64';\nimport moment from 'moment';\n/** 时间格式枚举 */\nexport var TimeFormat;\n(function (TimeFormat) {\n TimeFormat[\"default\"] = \"YYYY-MM-DDTHH:mm:ss\";\n TimeFormat[\"params\"] = \"YYYY-MM-DD HH:mm:ss\";\n TimeFormat[\"url\"] = \"YYYYMMDDTHHmmss\";\n})(TimeFormat || (TimeFormat = {}));\n/** 生成随机ID */\nexport const guidGenerator = () => {\n const S4 = function () {\n return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);\n };\n return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4();\n};\nconst initProtocol = (url) => {\n let src = url;\n const isHttps = 'https:' === document.location.protocol;\n if (isHttps) {\n if (url.startsWith(\"http:\")) {\n url = url.replace('http://', '');\n const ipPort = url.substring(0, url.indexOf('/'));\n const path = url.substring(url.indexOf('/'));\n src = '/visProxy/' + ipPort + '/play' + path;\n }\n else if (url.startsWith(\"ws:\")) {\n url = url.replace('http://', '');\n const ipPort = url.substring(0, url.indexOf('/'));\n const path = url.substring(url.indexOf('/'));\n src = 'wss://' + window.location.host + '/visProxy/' + ipPort + '/play' + path;\n }\n }\n return src;\n};\n/**\n * 获取视频直播地址及格式\n * @param url\n * @returns\n */\nexport const getPlayerParams = (url, live, startTime, endTime) => {\n let playerUrl = url;\n let playerType = 'flv';\n if (url.startsWith('ws://')) {\n playerType = 'hk_ws';\n if (live) {\n playerUrl = url;\n }\n else {\n playerUrl = url.split('?')[0];\n }\n }\n if (url.startsWith('rtsp://')) {\n playerType = 'flv';\n if (live) {\n playerUrl = `/cloud/vic/convert/flv/live.flv?url=${Base64.encode(url)}`;\n }\n else {\n playerUrl = `/cloud/vic/convert/flv/live.flv?url=${Base64.encode(getFlvListUrl(url, startTime, endTime))}`;\n }\n }\n if (url.endsWith('.m3u8')) {\n playerUrl = url;\n playerType = 'hls';\n }\n return { url: initProtocol(playerUrl), type: playerType };\n};\n/**\n * 获取历史回放表格数据\n * @param data\n * @returns\n */\nexport const getUrlTableData = (data) => {\n const result = data.list.map((item, i) => {\n const beginTime = moment(item.beginTime);\n const endTime = moment(item.endTime);\n const totalSeconds = moment(endTime).diff(moment(beginTime), 'seconds');\n return {\n index: i + 1,\n deviceName: data.deviceName,\n channelName: data.channelName,\n beginTime: beginTime.format(TimeFormat.params),\n endTime: endTime.format(TimeFormat.params),\n size: bytesToMegaBytes(item.size),\n duration: secondsToString(totalSeconds),\n downloadUrl: '',\n url: item.playbackUrl || '',\n };\n });\n return result;\n};\n/**\n * bytes转换mb\n * @param bytes\n * @returns\n */\nconst bytesToMegaBytes = (bytes) => `${(bytes / Math.pow(1024, 2)).toFixed(2)}MB`;\n/**\n * 秒数=>0时0分0秒\n * @param total\n * @returns\n */\nconst secondsToString = (total) => {\n const hour = Math.floor(total / 3600);\n const minute = Math.floor((total % 3600) / 60);\n const second = Math.floor(total % 60);\n const result = `${hour > 0 ? hour + '小时' : ''}${minute > 0 ? minute + '分' : ''}${second > 0 ? second + '秒' : ''}`;\n return result;\n};\n/**\n * 秒数=>00:00:00\n * @param total\n * @returns\n */\nexport const secondsToTime = (total) => {\n const hour = Math.floor(total / 3600);\n const minute = Math.floor((total % 3600) / 60);\n const second = Math.floor(total % 60);\n const result = `${hour >= 10 ? hour : '0' + hour}:${minute >= 10 ? minute : '0' + minute}:${second >= 10 ? second : '0' + second}`;\n return result;\n};\n/**\n * 获取海康时间参数\n * @param time 时间\n * @returns\n */\nexport const getHKTimeString = (time) => {\n return moment(time).format(TimeFormat.default) + 'Z';\n};\n/**\n * 获取海康分段播放地址\n * @param totalUrl 总播放地址\n * @param startTime 开始时间\n * @param endTime 结束时间\n * @returns\n */\nexport const getHKListUrl = (totalUrl, startTime, endTime) => {\n const [url, query] = totalUrl.split('?');\n const urlParams = new URLSearchParams(query);\n urlParams.set('beginTime', getHKTimeString(startTime));\n urlParams.set('endTime', getHKTimeString(endTime));\n return `${url}?${urlParams.toString()}`;\n};\n/**\n *\n * 获取flv格式分段播放地址\n * @param totalUrl 总播放地址\n * @param startTime 开始时间\n * @param endTime 结束时间\n * @returns\n */\nexport const getFlvListUrl = (totalUrl, startTime, endTime) => {\n const [url, query] = totalUrl.split('?');\n const urlParams = new URLSearchParams(query);\n urlParams.set('beginTime', moment(startTime).format(TimeFormat.url));\n urlParams.set('endTime', moment(endTime).format(TimeFormat.url));\n return `${url}?${urlParams.toString()}`;\n};\n/**\n * 获取地址栏中的参数信息\n * @param key 字段key\n * @param href 链接\n * @returns 字段值\n */\nexport const getUrlParam = (key, href = window.location.href) => {\n const paramObj = {};\n const matchList = href.match(/([^\\?&]+)=([^\\?&#]+)/g) || [];\n for (let i = 0, len = matchList.length; i < len; i++) {\n const r = matchList[i].match(/([^\\?&]+)=([^\\?&]+)/);\n paramObj[r[1]] = r[2];\n }\n if (key) {\n return paramObj[key];\n }\n else {\n return paramObj;\n }\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;;;;;;;;;;;;;;;AACA;AACO,IAAIA,UAAJ;;;AACP,CAAC,UAAUA,UAAV,EAAsB;EACnBA,UAAU,CAAC,SAAD,CAAV,GAAwB,qBAAxB;EACAA,UAAU,CAAC,QAAD,CAAV,GAAuB,qBAAvB;EACAA,UAAU,CAAC,KAAD,CAAV,GAAoB,iBAApB;AACH,CAJD,EAIGA,UAAU,0BAAKA,UAAU,GAAG,EAAlB,CAJb;AAKA;;;AACO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,GAAM;EAC/B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GAAV,cAAiB6D,SAAS,CAAChE,QAAV,EAAjB;AACH,CANM;AAOP;AACA;AACA;AACA;AACA;AACA;;;;;AACO,IAAMmE,WAAW,GAAG,SAAdA,WAAc,CAACC,GAAD,EAAsC;EAAA,IAAhCC,IAAgC,uEAAzBvD,MAAM,CAACP,QAAP,CAAgB8D,IAAS;EAC7D,IAAMC,QAAQ,GAAG,EAAjB;EACA,IAAMC,SAAS,GAAGF,IAAI,CAACG,KAAL,CAAW,uBAAX,KAAuC,EAAzD;;EACA,KAAK,IAAItC,CAAC,GAAG,CAAR,EAAWuC,GAAG,GAAGF,SAAS,CAACG,MAAhC,EAAwCxC,CAAC,GAAGuC,GAA5C,EAAiDvC,CAAC,EAAlD,EAAsD;IAClD,IAAMyC,CAAC,GAAGJ,SAAS,CAACrC,CAAD,CAAT,CAAasC,KAAb,CAAmB,qBAAnB,CAAV;IACAF,QAAQ,CAACK,CAAC,CAAC,CAAD,CAAF,CAAR,GAAiBA,CAAC,CAAC,CAAD,CAAlB;EACH;;EACD,IAAIP,GAAJ,EAAS;IACL,OAAOE,QAAQ,CAACF,GAAD,CAAf;EACH,CAFD,MAGK;IACD,OAAOE,QAAP;EACH;AACJ,CAbM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtx/player",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "视频业务组件",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
|
-
"
|
|
10
|
+
"lib"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"start": "start-storybook -p 6006",
|
package/dist/index.d.ts
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import moment from 'moment';
|
|
3
|
-
import { CloudControlPanelProps } from '@/components/controls';
|
|
4
|
-
import { VideoType as VideoType$1 } from '@/components/player';
|
|
5
|
-
import * as react from 'react';
|
|
6
|
-
import { GetHistoryUrlParams, LoadVideoInfoParams } from '@/api/types';
|
|
7
|
-
|
|
8
|
-
/** 视频流格式 */
|
|
9
|
-
declare type VideoType = 'flv' | 'hls' | 'hk_ws';
|
|
10
|
-
interface ConstructorParams {
|
|
11
|
-
url: string;
|
|
12
|
-
/** 渲染容器 */
|
|
13
|
-
container: HTMLDivElement;
|
|
14
|
-
/** 是否直播,flv.js需要 */
|
|
15
|
-
live?: boolean;
|
|
16
|
-
/** 视频流格式 */
|
|
17
|
-
type?: VideoType;
|
|
18
|
-
/** 开始时间,历史回放需要 */
|
|
19
|
-
startTime?: moment.MomentInput;
|
|
20
|
-
/** 结束时间,历史回放需要 */
|
|
21
|
-
endTime?: moment.MomentInput;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* 视频播放核心类
|
|
25
|
-
*/
|
|
26
|
-
declare class Player {
|
|
27
|
-
/** 视频地址 */
|
|
28
|
-
url: string;
|
|
29
|
-
/** 视频流格式 */
|
|
30
|
-
type: VideoType;
|
|
31
|
-
private player;
|
|
32
|
-
private video;
|
|
33
|
-
/** 开始时间,历史回放需要 */
|
|
34
|
-
private startTime?;
|
|
35
|
-
/** 结束时间,历史回放需要 */
|
|
36
|
-
private endTime?;
|
|
37
|
-
/** 跳转时间,用于处理进度条位置 */
|
|
38
|
-
private seekTime?;
|
|
39
|
-
/** 之前的视频播放速度,用于处理海康音量控制 */
|
|
40
|
-
private preSpeed;
|
|
41
|
-
constructor(params: ConstructorParams);
|
|
42
|
-
/** 播放 */
|
|
43
|
-
play(): Promise<void>;
|
|
44
|
-
/** 回放 */
|
|
45
|
-
playBack(): Promise<void>;
|
|
46
|
-
/** 销毁 */
|
|
47
|
-
destroy(): void;
|
|
48
|
-
/** 截图 */
|
|
49
|
-
capture(captureName?: string, time?: boolean): void;
|
|
50
|
-
/** 尺寸重置 */
|
|
51
|
-
resize(): void;
|
|
52
|
-
/**
|
|
53
|
-
* 设置音量
|
|
54
|
-
* @param value
|
|
55
|
-
*/
|
|
56
|
-
setVolume(value: number): void;
|
|
57
|
-
/**
|
|
58
|
-
* 设置播放速度
|
|
59
|
-
* @param speed
|
|
60
|
-
*/
|
|
61
|
-
setSpeed(speed: 0.5 | 1 | 2 | 4 | 8): void;
|
|
62
|
-
/**
|
|
63
|
-
* 时间更新事件
|
|
64
|
-
* @param callback 回调函数
|
|
65
|
-
*/
|
|
66
|
-
onTimeUpdate(callback: (currentTime: number, speed: number) => void): void;
|
|
67
|
-
/** 跳转到 */
|
|
68
|
-
seekTo(time: number): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* 暂停播放
|
|
71
|
-
* @param callback 回调函数
|
|
72
|
-
*/
|
|
73
|
-
pause(callback?: () => void): void;
|
|
74
|
-
/**
|
|
75
|
-
* 恢复播放
|
|
76
|
-
* @param callback 回调函数
|
|
77
|
-
*/
|
|
78
|
-
resume(callback?: () => void): void;
|
|
79
|
-
/**
|
|
80
|
-
* 开始对讲
|
|
81
|
-
* @param url 对讲地址
|
|
82
|
-
*/
|
|
83
|
-
startTalk(url: string): Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
* 开始对讲
|
|
86
|
-
* @param state 状态
|
|
87
|
-
*/
|
|
88
|
-
stopTalk(): Promise<void>;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
interface VtxPlayerProps$1 {
|
|
92
|
-
/** 视频流地址 */
|
|
93
|
-
url: string;
|
|
94
|
-
/** 宽度 */
|
|
95
|
-
width?: number;
|
|
96
|
-
/** 高度 */
|
|
97
|
-
height?: number;
|
|
98
|
-
/** 视频流格式,如果为空则根据url自行判断 */
|
|
99
|
-
type?: VideoType$1;
|
|
100
|
-
/** 截图文件名 */
|
|
101
|
-
captureName?: string;
|
|
102
|
-
/** 对讲地址 */
|
|
103
|
-
talkUrl?: string;
|
|
104
|
-
/** 云台控制 */
|
|
105
|
-
cloudParams?: CloudControlPanelProps;
|
|
106
|
-
}
|
|
107
|
-
declare const LivePlayer: (props: VtxPlayerProps$1) => JSX.Element;
|
|
108
|
-
|
|
109
|
-
declare type HistoryPlayerHandle = {
|
|
110
|
-
/**
|
|
111
|
-
* 跳转,目前仅支持海康视频跳转
|
|
112
|
-
*/
|
|
113
|
-
seekTo: (time: string) => Promise<void>;
|
|
114
|
-
};
|
|
115
|
-
interface VtxPlayerProps {
|
|
116
|
-
/** 视频流地址 */
|
|
117
|
-
url: string;
|
|
118
|
-
/** 视频流格式,如果为空则根据url自行判断 */
|
|
119
|
-
type?: VideoType$1;
|
|
120
|
-
/** 开始时间,格式为:YYYY-MM-DD HH:mm:ss */
|
|
121
|
-
startTime: string;
|
|
122
|
-
/** 结束时间,格式为:YYYY-MM-DD HH:mm:ss */
|
|
123
|
-
endTime: string;
|
|
124
|
-
/** 宽度 */
|
|
125
|
-
width?: number;
|
|
126
|
-
/** 高度 */
|
|
127
|
-
height?: number;
|
|
128
|
-
/** 截图文件名 */
|
|
129
|
-
captureName?: string;
|
|
130
|
-
/** 控制条bottom */
|
|
131
|
-
controlBottom?: number;
|
|
132
|
-
/** 播放器进度回调,time:YYYY-MM-DD HH:mm:ss speed:播放速率 */
|
|
133
|
-
onTimeChange?: (time: string, speed: number) => void;
|
|
134
|
-
}
|
|
135
|
-
declare const HistoryPlayer: react.ForwardRefExoticComponent<VtxPlayerProps & react.RefAttributes<HistoryPlayerHandle>>;
|
|
136
|
-
|
|
137
|
-
declare type LiveControlHandle = {
|
|
138
|
-
/** 加载视频 */
|
|
139
|
-
load: (channel: ChannelType) => void;
|
|
140
|
-
/** 卸载视频,参数为通道编号 */
|
|
141
|
-
unLoad: (channelNum: string) => void;
|
|
142
|
-
/** 一次加载多个视频,适用于初始化 */
|
|
143
|
-
multiLoad: (channels: ChannelType[]) => void;
|
|
144
|
-
};
|
|
145
|
-
interface LiveControlProps {
|
|
146
|
-
/** 展开/收缩按钮回调 */
|
|
147
|
-
onExpandChange?: (expand: boolean) => void;
|
|
148
|
-
/** 视频关闭回调,参数为通道编号数组 */
|
|
149
|
-
onChannelChange?: (channelSNum: string[]) => void;
|
|
150
|
-
/** 宽度 */
|
|
151
|
-
width?: number | string;
|
|
152
|
-
/** 高度 */
|
|
153
|
-
height?: number | string;
|
|
154
|
-
/** 轮询频率 */
|
|
155
|
-
polling?: number | undefined;
|
|
156
|
-
}
|
|
157
|
-
declare type ChannelType = {
|
|
158
|
-
/** 通道号 */
|
|
159
|
-
channelNum: string;
|
|
160
|
-
/** 设备ID */
|
|
161
|
-
deviceId?: string;
|
|
162
|
-
/** 协议 */
|
|
163
|
-
protocol?: string;
|
|
164
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* 实时分屏组件
|
|
167
|
-
*/
|
|
168
|
-
declare const LiveControl: react.ForwardRefExoticComponent<LiveControlProps & react.RefAttributes<LiveControlHandle>>;
|
|
169
|
-
|
|
170
|
-
declare type HistoryControlHandle = {
|
|
171
|
-
load: (channel: GetHistoryUrlParams) => void;
|
|
172
|
-
};
|
|
173
|
-
interface HistoryControlProps {
|
|
174
|
-
/** 宽度 */
|
|
175
|
-
width?: number;
|
|
176
|
-
/** 高度 */
|
|
177
|
-
height?: number;
|
|
178
|
-
/** 展开/收缩按钮回调 */
|
|
179
|
-
onExpandChange?: (expand: boolean) => void;
|
|
180
|
-
/** 播放器进度回调,time:YYYY-MM-DD HH:mm:ss */
|
|
181
|
-
onTimeChange?: (time: string) => void;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* 历史视频控制器
|
|
185
|
-
*/
|
|
186
|
-
declare const HistoryControl: react.ForwardRefExoticComponent<HistoryControlProps & react.RefAttributes<HistoryControlHandle>>;
|
|
187
|
-
|
|
188
|
-
interface BillPlayerProps {
|
|
189
|
-
/** 参数 */
|
|
190
|
-
params: LoadVideoInfoParams;
|
|
191
|
-
/** 宽度 */
|
|
192
|
-
width?: string | number;
|
|
193
|
-
/** 高度 */
|
|
194
|
-
height?: string | number;
|
|
195
|
-
/** 是否显示实时视频,默认为true */
|
|
196
|
-
live?: boolean;
|
|
197
|
-
/** 是否显示历史视频,默认为true */
|
|
198
|
-
history?: boolean;
|
|
199
|
-
/** 实时默认播放 */
|
|
200
|
-
defaultLivePlay?: boolean;
|
|
201
|
-
/** 历史默认播放 */
|
|
202
|
-
defaultHistoryPlay?: boolean;
|
|
203
|
-
}
|
|
204
|
-
declare const BillPlayer: (props: BillPlayerProps) => JSX.Element;
|
|
205
|
-
|
|
206
|
-
interface LiveChannelPlayerProps {
|
|
207
|
-
/** 通道ID */
|
|
208
|
-
channelId: string;
|
|
209
|
-
/** 宽度 */
|
|
210
|
-
width?: number;
|
|
211
|
-
/** 高度 */
|
|
212
|
-
height?: number;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* 基于通道ID的实时播放器
|
|
216
|
-
* @param props
|
|
217
|
-
* @returns
|
|
218
|
-
*/
|
|
219
|
-
declare const LiveChannelPlayer: (props: LiveChannelPlayerProps) => JSX.Element | undefined;
|
|
220
|
-
|
|
221
|
-
export { BillPlayer, HistoryControl, HistoryPlayer, LiveChannelPlayer, LiveControl, LivePlayer, Player };
|