@vtx/player 1.5.4 → 1.6.0
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/lib/player/index.d.ts +1 -1
- package/lib/player/index.js +61 -19
- package/lib/player/index.js.map +1 -1
- package/lib/utils/index.js +13 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/vtxHls/PlayerManager.d.ts +38 -0
- package/lib/vtxHls/PlayerManager.js +123 -0
- package/lib/vtxHls/PlayerManager.js.map +1 -0
- package/lib/vtxHls/WhepManager.d.ts +22 -0
- package/lib/vtxHls/WhepManager.js +377 -0
- package/lib/vtxHls/WhepManager.js.map +1 -0
- package/package.json +1 -1
- package/lib/new/PlayerManager.d.ts +0 -79
- package/lib/new/PlayerManager.js +0 -283
- package/lib/new/PlayerManager.js.map +0 -1
- package/lib/new/api.d.ts +0 -5
- package/lib/new/api.js +0 -32
- package/lib/new/api.js.map +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
|
|
10
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
+
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
|
|
14
|
+
var VtxHlsPlayerManager = /*#__PURE__*/function () {
|
|
15
|
+
function VtxHlsPlayerManager(opt) {
|
|
16
|
+
_classCallCheck(this, VtxHlsPlayerManager);
|
|
17
|
+
|
|
18
|
+
this.url = opt.url;
|
|
19
|
+
this.video = opt.video;
|
|
20
|
+
this.player = null;
|
|
21
|
+
this.initPlayer();
|
|
22
|
+
} //初始化视频插件
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
_createClass(VtxHlsPlayerManager, [{
|
|
26
|
+
key: "initPlayer",
|
|
27
|
+
value: function initPlayer() {
|
|
28
|
+
var _this = this;
|
|
29
|
+
|
|
30
|
+
var video = this.video;
|
|
31
|
+
var hls = new Hls({
|
|
32
|
+
maxLiveSyncPlaybackRate: 1.5
|
|
33
|
+
});
|
|
34
|
+
hls.on(Hls.Events.ERROR, function (evt, data) {
|
|
35
|
+
if (data.type === Hls.ErrorTypes.MEDIA_ERROR) hls.recoverMediaError();else if (data.fatal) {
|
|
36
|
+
hls.destroy();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
hls.on(Hls.Events.MEDIA_ATTACHED, function () {
|
|
40
|
+
hls.loadSource("".concat(_this.url, "index.m3u8"));
|
|
41
|
+
});
|
|
42
|
+
hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
|
43
|
+
video.play();
|
|
44
|
+
});
|
|
45
|
+
hls.attachMedia(video);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 倍速播放
|
|
49
|
+
* @param {number} speed 速率 0.125 0.25 0.5 1 2 4 8 共7种速率
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
}, {
|
|
53
|
+
key: "playSpeed",
|
|
54
|
+
value: function playSpeed(speed) {
|
|
55
|
+
this.recordPlayer && this.recordPlayer.playSpeed(speed);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 关闭播放器
|
|
59
|
+
* @param {number} index 可选,关闭指定索引的窗口的播放器,不传则表示关闭所有播放器
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
}, {
|
|
63
|
+
key: "close",
|
|
64
|
+
value: function close(index) {
|
|
65
|
+
this.player && this.player.reSetVideo(index);
|
|
66
|
+
|
|
67
|
+
if (this.dp) {
|
|
68
|
+
this.dp.ttxplayer.destroy();
|
|
69
|
+
this.dp.destroy();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
key: "resize",
|
|
74
|
+
value: function resize() {
|
|
75
|
+
this.player && this.player.setSize();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 设置全屏
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
}, {
|
|
82
|
+
key: "setFullScreen",
|
|
83
|
+
value: function setFullScreen() {
|
|
84
|
+
this.player.fullScreen();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 设置窗口自适应还是拉伸
|
|
88
|
+
* @param {string} playerAdapter selfAdaption 自适应 | stretching 拉伸
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
}, {
|
|
92
|
+
key: "setPlayerAdapter",
|
|
93
|
+
value: function setPlayerAdapter(playerAdapter) {
|
|
94
|
+
this.player.setPlayerAdapter(playerAdapter);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 控制视频播放器显示的路数: 1 4 9 16 25,不会超过最大显示路数
|
|
98
|
+
* @param {number} number
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
}, {
|
|
102
|
+
key: "setPlayerNum",
|
|
103
|
+
value: function setPlayerNum(number) {
|
|
104
|
+
this.player.setPlayerNum(number);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 设置选中的播放器的索引
|
|
108
|
+
* @param {number} index
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
}, {
|
|
112
|
+
key: "setSelectIndex",
|
|
113
|
+
value: function setSelectIndex(index) {
|
|
114
|
+
this.player.setSelectIndex(index);
|
|
115
|
+
}
|
|
116
|
+
}]);
|
|
117
|
+
|
|
118
|
+
return VtxHlsPlayerManager;
|
|
119
|
+
}();
|
|
120
|
+
|
|
121
|
+
var _default = VtxHlsPlayerManager;
|
|
122
|
+
exports["default"] = _default;
|
|
123
|
+
//# sourceMappingURL=PlayerManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlayerManager.js","names":["VtxHlsPlayerManager","opt","url","video","player","initPlayer","hls","Hls","maxLiveSyncPlaybackRate","on","Events","ERROR","evt","data","type","ErrorTypes","MEDIA_ERROR","recoverMediaError","fatal","destroy","MEDIA_ATTACHED","loadSource","MANIFEST_PARSED","play","attachMedia","speed","recordPlayer","playSpeed","index","reSetVideo","dp","ttxplayer","setSize","fullScreen","playerAdapter","setPlayerAdapter","number","setPlayerNum","setSelectIndex"],"sources":["vtxHls/PlayerManager.js"],"sourcesContent":["class VtxHlsPlayerManager {\n constructor(opt) {\n this.url = opt.url;\n this.video = opt.video;\n this.player = null;\n this.initPlayer();\n }\n //初始化视频插件\n initPlayer() {\n const video = this.video;\n const hls = new Hls({\n maxLiveSyncPlaybackRate: 1.5,\n });\n hls.on(Hls.Events.ERROR, (evt, data) => {\n if (data.type === Hls.ErrorTypes.MEDIA_ERROR)\n hls.recoverMediaError();\n else if (data.fatal) {\n hls.destroy();\n }\n });\n hls.on(Hls.Events.MEDIA_ATTACHED, () => {\n hls.loadSource(`${this.url}index.m3u8`);\n });\n hls.on(Hls.Events.MANIFEST_PARSED, () => {\n video.play();\n });\n hls.attachMedia(video);\n }\n /**\n * 倍速播放\n * @param {number} speed 速率 0.125 0.25 0.5 1 2 4 8 共7种速率\n */\n playSpeed(speed) {\n this.recordPlayer && this.recordPlayer.playSpeed(speed);\n }\n /**\n * 关闭播放器\n * @param {number} index 可选,关闭指定索引的窗口的播放器,不传则表示关闭所有播放器\n */\n close(index) {\n this.player && this.player.reSetVideo(index);\n if (this.dp) {\n this.dp.ttxplayer.destroy();\n this.dp.destroy();\n }\n }\n resize() {\n this.player && this.player.setSize();\n }\n /**\n * 设置全屏\n */\n setFullScreen() {\n this.player.fullScreen();\n }\n /**\n * 设置窗口自适应还是拉伸\n * @param {string} playerAdapter selfAdaption 自适应 | stretching 拉伸\n */\n setPlayerAdapter(playerAdapter) {\n this.player.setPlayerAdapter(playerAdapter);\n }\n /**\n * 控制视频播放器显示的路数: 1 4 9 16 25,不会超过最大显示路数\n * @param {number} number\n */\n setPlayerNum(number) {\n this.player.setPlayerNum(number);\n }\n /**\n * 设置选中的播放器的索引\n * @param {number} index\n */\n setSelectIndex(index) {\n this.player.setSelectIndex(index);\n }\n}\nexport default VtxHlsPlayerManager;\n"],"mappings":";;;;;;;;;;;;;IAAMA,mB;EACF,6BAAYC,GAAZ,EAAiB;IAAA;;IACb,KAAKC,GAAL,GAAWD,GAAG,CAACC,GAAf;IACA,KAAKC,KAAL,GAAaF,GAAG,CAACE,KAAjB;IACA,KAAKC,MAAL,GAAc,IAAd;IACA,KAAKC,UAAL;EACH,C,CACD;;;;;WACA,sBAAa;MAAA;;MACT,IAAMF,KAAK,GAAG,KAAKA,KAAnB;MACA,IAAMG,GAAG,GAAG,IAAIC,GAAJ,CAAQ;QAChBC,uBAAuB,EAAE;MADT,CAAR,CAAZ;MAGAF,GAAG,CAACG,EAAJ,CAAOF,GAAG,CAACG,MAAJ,CAAWC,KAAlB,EAAyB,UAACC,GAAD,EAAMC,IAAN,EAAe;QACpC,IAAIA,IAAI,CAACC,IAAL,KAAcP,GAAG,CAACQ,UAAJ,CAAeC,WAAjC,EACIV,GAAG,CAACW,iBAAJ,GADJ,KAEK,IAAIJ,IAAI,CAACK,KAAT,EAAgB;UACjBZ,GAAG,CAACa,OAAJ;QACH;MACJ,CAND;MAOAb,GAAG,CAACG,EAAJ,CAAOF,GAAG,CAACG,MAAJ,CAAWU,cAAlB,EAAkC,YAAM;QACpCd,GAAG,CAACe,UAAJ,WAAkB,KAAI,CAACnB,GAAvB;MACH,CAFD;MAGAI,GAAG,CAACG,EAAJ,CAAOF,GAAG,CAACG,MAAJ,CAAWY,eAAlB,EAAmC,YAAM;QACrCnB,KAAK,CAACoB,IAAN;MACH,CAFD;MAGAjB,GAAG,CAACkB,WAAJ,CAAgBrB,KAAhB;IACH;IACD;AACJ;AACA;AACA;;;;WACI,mBAAUsB,KAAV,EAAiB;MACb,KAAKC,YAAL,IAAqB,KAAKA,YAAL,CAAkBC,SAAlB,CAA4BF,KAA5B,CAArB;IACH;IACD;AACJ;AACA;AACA;;;;WACI,eAAMG,KAAN,EAAa;MACT,KAAKxB,MAAL,IAAe,KAAKA,MAAL,CAAYyB,UAAZ,CAAuBD,KAAvB,CAAf;;MACA,IAAI,KAAKE,EAAT,EAAa;QACT,KAAKA,EAAL,CAAQC,SAAR,CAAkBZ,OAAlB;QACA,KAAKW,EAAL,CAAQX,OAAR;MACH;IACJ;;;WACD,kBAAS;MACL,KAAKf,MAAL,IAAe,KAAKA,MAAL,CAAY4B,OAAZ,EAAf;IACH;IACD;AACJ;AACA;;;;WACI,yBAAgB;MACZ,KAAK5B,MAAL,CAAY6B,UAAZ;IACH;IACD;AACJ;AACA;AACA;;;;WACI,0BAAiBC,aAAjB,EAAgC;MAC5B,KAAK9B,MAAL,CAAY+B,gBAAZ,CAA6BD,aAA7B;IACH;IACD;AACJ;AACA;AACA;;;;WACI,sBAAaE,MAAb,EAAqB;MACjB,KAAKhC,MAAL,CAAYiC,YAAZ,CAAyBD,MAAzB;IACH;IACD;AACJ;AACA;AACA;;;;WACI,wBAAeR,KAAf,EAAsB;MAClB,KAAKxB,MAAL,CAAYkC,cAAZ,CAA2BV,KAA3B;IACH;;;;;;eAEU5B,mB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default class WHEPClient {
|
|
2
|
+
constructor(opt: any);
|
|
3
|
+
url: any;
|
|
4
|
+
video: any;
|
|
5
|
+
pc: RTCPeerConnection;
|
|
6
|
+
restartTimeout: any;
|
|
7
|
+
sessionUrl: string;
|
|
8
|
+
queuedCandidates: any[];
|
|
9
|
+
start(): void;
|
|
10
|
+
onIceServers(res: any): void;
|
|
11
|
+
onLocalOffer(offer: any): void;
|
|
12
|
+
offerData: {
|
|
13
|
+
iceUfrag: string;
|
|
14
|
+
icePwd: string;
|
|
15
|
+
medias: any[];
|
|
16
|
+
};
|
|
17
|
+
onConnectionState(): void;
|
|
18
|
+
onRemoteAnswer(answer: any): void;
|
|
19
|
+
onLocalCandidate(evt: any): void;
|
|
20
|
+
sendLocalCandidates(candidates: any): void;
|
|
21
|
+
scheduleRestart(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
|
|
10
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
+
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
|
|
14
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
15
|
+
|
|
16
|
+
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); }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
var restartPause = 2000;
|
|
21
|
+
|
|
22
|
+
var linkToIceServers = function linkToIceServers(links) {
|
|
23
|
+
return links !== null ? links.split(', ').map(function (link) {
|
|
24
|
+
var m = link.match(/^<(.+?)>; rel="ice-server"(; username="(.*?)"; credential="(.*?)"; credential-type="password")?/i);
|
|
25
|
+
var ret = {
|
|
26
|
+
urls: [m[1]]
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
if (m[3] !== undefined) {
|
|
30
|
+
ret.username = unquoteCredential(m[3]);
|
|
31
|
+
ret.credential = unquoteCredential(m[4]);
|
|
32
|
+
ret.credentialType = 'password';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return ret;
|
|
36
|
+
}) : [];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var editOffer = function editOffer(offer) {
|
|
40
|
+
var sections = offer.sdp.split('m=');
|
|
41
|
+
|
|
42
|
+
for (var i = 0; i < sections.length; i++) {
|
|
43
|
+
var section = sections[i];
|
|
44
|
+
|
|
45
|
+
if (section.startsWith('audio')) {
|
|
46
|
+
sections[i] = enableStereoOpus(section);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
offer.sdp = sections.join('m=');
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var enableStereoOpus = function enableStereoOpus(section) {
|
|
54
|
+
var opusPayloadFormat = '';
|
|
55
|
+
var lines = section.split('\r\n');
|
|
56
|
+
|
|
57
|
+
for (var i = 0; i < lines.length; i++) {
|
|
58
|
+
if (lines[i].startsWith('a=rtpmap:') && lines[i].toLowerCase().includes('opus/')) {
|
|
59
|
+
opusPayloadFormat = lines[i].slice('a=rtpmap:'.length).split(' ')[0];
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (opusPayloadFormat === '') {
|
|
65
|
+
return section;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
for (var _i = 0; _i < lines.length; _i++) {
|
|
69
|
+
if (lines[_i].startsWith('a=fmtp:' + opusPayloadFormat + ' ')) {
|
|
70
|
+
if (!lines[_i].includes('stereo')) {
|
|
71
|
+
lines[_i] += ';stereo=1';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!lines[_i].includes('sprop-stereo')) {
|
|
75
|
+
lines[_i] += ';sprop-stereo=1';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return lines.join('\r\n');
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
var parseOffer = function parseOffer(offer) {
|
|
84
|
+
var ret = {
|
|
85
|
+
iceUfrag: '',
|
|
86
|
+
icePwd: '',
|
|
87
|
+
medias: []
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
var _iterator = _createForOfIteratorHelper(offer.split('\r\n')),
|
|
91
|
+
_step;
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
95
|
+
var line = _step.value;
|
|
96
|
+
|
|
97
|
+
if (line.startsWith('m=')) {
|
|
98
|
+
ret.medias.push(line.slice('m='.length));
|
|
99
|
+
} else if (ret.iceUfrag === '' && line.startsWith('a=ice-ufrag:')) {
|
|
100
|
+
ret.iceUfrag = line.slice('a=ice-ufrag:'.length);
|
|
101
|
+
} else if (ret.icePwd === '' && line.startsWith('a=ice-pwd:')) {
|
|
102
|
+
ret.icePwd = line.slice('a=ice-pwd:'.length);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} catch (err) {
|
|
106
|
+
_iterator.e(err);
|
|
107
|
+
} finally {
|
|
108
|
+
_iterator.f();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return ret;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
var generateSdpFragment = function generateSdpFragment(offerData, candidates) {
|
|
115
|
+
var candidatesByMedia = {};
|
|
116
|
+
|
|
117
|
+
var _iterator2 = _createForOfIteratorHelper(candidates),
|
|
118
|
+
_step2;
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
122
|
+
var candidate = _step2.value;
|
|
123
|
+
var _mid = candidate.sdpMLineIndex;
|
|
124
|
+
|
|
125
|
+
if (candidatesByMedia[_mid] === undefined) {
|
|
126
|
+
candidatesByMedia[_mid] = [];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
candidatesByMedia[_mid].push(candidate);
|
|
130
|
+
}
|
|
131
|
+
} catch (err) {
|
|
132
|
+
_iterator2.e(err);
|
|
133
|
+
} finally {
|
|
134
|
+
_iterator2.f();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
var frag = 'a=ice-ufrag:' + offerData.iceUfrag + '\r\n' + 'a=ice-pwd:' + offerData.icePwd + '\r\n';
|
|
138
|
+
var mid = 0;
|
|
139
|
+
|
|
140
|
+
var _iterator3 = _createForOfIteratorHelper(offerData.medias),
|
|
141
|
+
_step3;
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
145
|
+
var media = _step3.value;
|
|
146
|
+
|
|
147
|
+
if (candidatesByMedia[mid] !== undefined) {
|
|
148
|
+
frag += 'm=' + media + '\r\n' + 'a=mid:' + mid + '\r\n';
|
|
149
|
+
|
|
150
|
+
var _iterator4 = _createForOfIteratorHelper(candidatesByMedia[mid]),
|
|
151
|
+
_step4;
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
155
|
+
var _candidate = _step4.value;
|
|
156
|
+
frag += 'a=' + _candidate.candidate + '\r\n';
|
|
157
|
+
}
|
|
158
|
+
} catch (err) {
|
|
159
|
+
_iterator4.e(err);
|
|
160
|
+
} finally {
|
|
161
|
+
_iterator4.f();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
mid++;
|
|
166
|
+
}
|
|
167
|
+
} catch (err) {
|
|
168
|
+
_iterator3.e(err);
|
|
169
|
+
} finally {
|
|
170
|
+
_iterator3.f();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return frag;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
var WHEPClient = /*#__PURE__*/function () {
|
|
177
|
+
function WHEPClient(opt) {
|
|
178
|
+
_classCallCheck(this, WHEPClient);
|
|
179
|
+
|
|
180
|
+
this.url = opt.url;
|
|
181
|
+
this.video = opt.video;
|
|
182
|
+
this.pc = null;
|
|
183
|
+
this.restartTimeout = null;
|
|
184
|
+
this.sessionUrl = '';
|
|
185
|
+
this.queuedCandidates = [];
|
|
186
|
+
this.start();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
_createClass(WHEPClient, [{
|
|
190
|
+
key: "start",
|
|
191
|
+
value: function start() {
|
|
192
|
+
var _this = this;
|
|
193
|
+
|
|
194
|
+
console.log('requesting ICE servers');
|
|
195
|
+
fetch(new URL('whep', this.url), {
|
|
196
|
+
method: 'OPTIONS'
|
|
197
|
+
}).then(function (res) {
|
|
198
|
+
return _this.onIceServers(res);
|
|
199
|
+
})["catch"](function (err) {
|
|
200
|
+
console.log('error: ' + err);
|
|
201
|
+
|
|
202
|
+
_this.scheduleRestart();
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}, {
|
|
206
|
+
key: "onIceServers",
|
|
207
|
+
value: function onIceServers(res) {
|
|
208
|
+
var _this2 = this;
|
|
209
|
+
|
|
210
|
+
this.pc = new RTCPeerConnection({
|
|
211
|
+
iceServers: linkToIceServers(res.headers.get('Link'))
|
|
212
|
+
});
|
|
213
|
+
var direction = 'sendrecv';
|
|
214
|
+
this.pc.addTransceiver('video', {
|
|
215
|
+
direction: direction
|
|
216
|
+
});
|
|
217
|
+
this.pc.addTransceiver('audio', {
|
|
218
|
+
direction: direction
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
this.pc.onicecandidate = function (evt) {
|
|
222
|
+
return _this2.onLocalCandidate(evt);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
this.pc.oniceconnectionstatechange = function () {
|
|
226
|
+
return _this2.onConnectionState();
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
this.pc.ontrack = function (evt) {
|
|
230
|
+
console.log('new track:', evt.track.kind);
|
|
231
|
+
_this2.video.srcObject = evt.streams[0];
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
this.pc.createOffer().then(function (offer) {
|
|
235
|
+
return _this2.onLocalOffer(offer);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
key: "onLocalOffer",
|
|
240
|
+
value: function onLocalOffer(offer) {
|
|
241
|
+
var _this3 = this;
|
|
242
|
+
|
|
243
|
+
editOffer(offer);
|
|
244
|
+
this.offerData = parseOffer(offer.sdp);
|
|
245
|
+
this.pc.setLocalDescription(offer);
|
|
246
|
+
console.log('sending offer');
|
|
247
|
+
fetch(new URL('whep', this.url), {
|
|
248
|
+
method: 'POST',
|
|
249
|
+
headers: {
|
|
250
|
+
'Content-Type': 'application/sdp'
|
|
251
|
+
},
|
|
252
|
+
body: offer.sdp
|
|
253
|
+
}).then(function (res) {
|
|
254
|
+
if (res.status !== 201) {
|
|
255
|
+
throw new Error('bad status code');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
_this3.sessionUrl = new URL(res.headers.get('location'), _this3.url).toString();
|
|
259
|
+
return res.text();
|
|
260
|
+
}).then(function (sdp) {
|
|
261
|
+
return _this3.onRemoteAnswer(new RTCSessionDescription({
|
|
262
|
+
type: 'answer',
|
|
263
|
+
sdp: sdp
|
|
264
|
+
}));
|
|
265
|
+
})["catch"](function (err) {
|
|
266
|
+
console.log('error: ' + err);
|
|
267
|
+
|
|
268
|
+
_this3.scheduleRestart();
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}, {
|
|
272
|
+
key: "onConnectionState",
|
|
273
|
+
value: function onConnectionState() {
|
|
274
|
+
if (this.restartTimeout !== null) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
console.log('peer connection state:', this.pc.iceConnectionState);
|
|
279
|
+
|
|
280
|
+
switch (this.pc.iceConnectionState) {
|
|
281
|
+
case 'disconnected':
|
|
282
|
+
this.scheduleRestart();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}, {
|
|
286
|
+
key: "onRemoteAnswer",
|
|
287
|
+
value: function onRemoteAnswer(answer) {
|
|
288
|
+
if (this.restartTimeout !== null) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
this.pc.setRemoteDescription(answer);
|
|
293
|
+
|
|
294
|
+
if (this.queuedCandidates.length !== 0) {
|
|
295
|
+
this.sendLocalCandidates(this.queuedCandidates);
|
|
296
|
+
this.queuedCandidates = [];
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}, {
|
|
300
|
+
key: "onLocalCandidate",
|
|
301
|
+
value: function onLocalCandidate(evt) {
|
|
302
|
+
if (this.restartTimeout !== null) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (evt.candidate !== null) {
|
|
307
|
+
if (this.sessionUrl === '') {
|
|
308
|
+
this.queuedCandidates.push(evt.candidate);
|
|
309
|
+
} else {
|
|
310
|
+
this.sendLocalCandidates([evt.candidate]);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}, {
|
|
315
|
+
key: "sendLocalCandidates",
|
|
316
|
+
value: function sendLocalCandidates(candidates) {
|
|
317
|
+
var _this4 = this;
|
|
318
|
+
|
|
319
|
+
fetch(this.sessionUrl + window.location.search, {
|
|
320
|
+
method: 'PATCH',
|
|
321
|
+
headers: {
|
|
322
|
+
'Content-Type': 'application/trickle-ice-sdpfrag',
|
|
323
|
+
'If-Match': '*'
|
|
324
|
+
},
|
|
325
|
+
body: generateSdpFragment(this.offerData, candidates)
|
|
326
|
+
}).then(function (res) {
|
|
327
|
+
if (res.status !== 204) {
|
|
328
|
+
throw new Error('bad status code');
|
|
329
|
+
}
|
|
330
|
+
})["catch"](function (err) {
|
|
331
|
+
console.log('error: ' + err);
|
|
332
|
+
|
|
333
|
+
_this4.scheduleRestart();
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}, {
|
|
337
|
+
key: "scheduleRestart",
|
|
338
|
+
value: function scheduleRestart() {
|
|
339
|
+
var _this5 = this;
|
|
340
|
+
|
|
341
|
+
if (this.restartTimeout !== null) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (this.pc !== null) {
|
|
346
|
+
this.pc.close();
|
|
347
|
+
this.pc = null;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
this.restartTimeout = window.setTimeout(function () {
|
|
351
|
+
_this5.restartTimeout = null;
|
|
352
|
+
|
|
353
|
+
_this5.start();
|
|
354
|
+
}, restartPause);
|
|
355
|
+
|
|
356
|
+
if (this.sessionUrl) {
|
|
357
|
+
fetch(this.sessionUrl, {
|
|
358
|
+
method: 'DELETE'
|
|
359
|
+
}).then(function (res) {
|
|
360
|
+
if (res.status !== 200) {
|
|
361
|
+
throw new Error('bad status code');
|
|
362
|
+
}
|
|
363
|
+
})["catch"](function (err) {
|
|
364
|
+
console.log('delete session error: ' + err);
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
this.sessionUrl = '';
|
|
369
|
+
this.queuedCandidates = [];
|
|
370
|
+
}
|
|
371
|
+
}]);
|
|
372
|
+
|
|
373
|
+
return WHEPClient;
|
|
374
|
+
}();
|
|
375
|
+
|
|
376
|
+
exports["default"] = WHEPClient;
|
|
377
|
+
//# sourceMappingURL=WhepManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WhepManager.js","names":["restartPause","linkToIceServers","links","split","map","link","m","match","ret","urls","undefined","username","unquoteCredential","credential","credentialType","editOffer","offer","sections","sdp","i","length","section","startsWith","enableStereoOpus","join","opusPayloadFormat","lines","toLowerCase","includes","slice","parseOffer","iceUfrag","icePwd","medias","line","push","generateSdpFragment","offerData","candidates","candidatesByMedia","candidate","mid","sdpMLineIndex","frag","media","WHEPClient","opt","url","video","pc","restartTimeout","sessionUrl","queuedCandidates","start","console","log","fetch","URL","method","then","res","onIceServers","err","scheduleRestart","RTCPeerConnection","iceServers","headers","get","direction","addTransceiver","onicecandidate","evt","onLocalCandidate","oniceconnectionstatechange","onConnectionState","ontrack","track","kind","srcObject","streams","createOffer","onLocalOffer","setLocalDescription","body","status","Error","toString","text","onRemoteAnswer","RTCSessionDescription","type","iceConnectionState","answer","setRemoteDescription","sendLocalCandidates","window","location","search","close","setTimeout"],"sources":["vtxHls/WhepManager.js"],"sourcesContent":["const restartPause = 2000;\nconst linkToIceServers = (links) => links !== null\n ? links.split(', ').map((link) => {\n const m = link.match(/^<(.+?)>; rel=\"ice-server\"(; username=\"(.*?)\"; credential=\"(.*?)\"; credential-type=\"password\")?/i);\n const ret = {\n urls: [m[1]],\n };\n if (m[3] !== undefined) {\n ret.username = unquoteCredential(m[3]);\n ret.credential = unquoteCredential(m[4]);\n ret.credentialType = 'password';\n }\n return ret;\n })\n : [];\nconst editOffer = (offer) => {\n const sections = offer.sdp.split('m=');\n for (let i = 0; i < sections.length; i++) {\n const section = sections[i];\n if (section.startsWith('audio')) {\n sections[i] = enableStereoOpus(section);\n }\n }\n offer.sdp = sections.join('m=');\n};\nconst enableStereoOpus = (section) => {\n let opusPayloadFormat = '';\n let lines = section.split('\\r\\n');\n for (let i = 0; i < lines.length; i++) {\n if (lines[i].startsWith('a=rtpmap:') && lines[i].toLowerCase().includes('opus/')) {\n opusPayloadFormat = lines[i].slice('a=rtpmap:'.length).split(' ')[0];\n break;\n }\n }\n if (opusPayloadFormat === '') {\n return section;\n }\n for (let i = 0; i < lines.length; i++) {\n if (lines[i].startsWith('a=fmtp:' + opusPayloadFormat + ' ')) {\n if (!lines[i].includes('stereo')) {\n lines[i] += ';stereo=1';\n }\n if (!lines[i].includes('sprop-stereo')) {\n lines[i] += ';sprop-stereo=1';\n }\n }\n }\n return lines.join('\\r\\n');\n};\nconst parseOffer = (offer) => {\n const ret = {\n iceUfrag: '',\n icePwd: '',\n medias: [],\n };\n for (const line of offer.split('\\r\\n')) {\n if (line.startsWith('m=')) {\n ret.medias.push(line.slice('m='.length));\n }\n else if (ret.iceUfrag === '' && line.startsWith('a=ice-ufrag:')) {\n ret.iceUfrag = line.slice('a=ice-ufrag:'.length);\n }\n else if (ret.icePwd === '' && line.startsWith('a=ice-pwd:')) {\n ret.icePwd = line.slice('a=ice-pwd:'.length);\n }\n }\n return ret;\n};\nconst generateSdpFragment = (offerData, candidates) => {\n const candidatesByMedia = {};\n for (const candidate of candidates) {\n const mid = candidate.sdpMLineIndex;\n if (candidatesByMedia[mid] === undefined) {\n candidatesByMedia[mid] = [];\n }\n candidatesByMedia[mid].push(candidate);\n }\n let frag = 'a=ice-ufrag:' + offerData.iceUfrag + '\\r\\n' + 'a=ice-pwd:' + offerData.icePwd + '\\r\\n';\n let mid = 0;\n for (const media of offerData.medias) {\n if (candidatesByMedia[mid] !== undefined) {\n frag += 'm=' + media + '\\r\\n' + 'a=mid:' + mid + '\\r\\n';\n for (const candidate of candidatesByMedia[mid]) {\n frag += 'a=' + candidate.candidate + '\\r\\n';\n }\n }\n mid++;\n }\n return frag;\n};\nexport default class WHEPClient {\n constructor(opt) {\n this.url = opt.url;\n this.video = opt.video;\n this.pc = null;\n this.restartTimeout = null;\n this.sessionUrl = '';\n this.queuedCandidates = [];\n this.start();\n }\n start() {\n console.log('requesting ICE servers');\n fetch(new URL('whep', this.url), {\n method: 'OPTIONS',\n })\n .then((res) => this.onIceServers(res))\n .catch((err) => {\n console.log('error: ' + err);\n this.scheduleRestart();\n });\n }\n onIceServers(res) {\n this.pc = new RTCPeerConnection({\n iceServers: linkToIceServers(res.headers.get('Link')),\n });\n const direction = 'sendrecv';\n this.pc.addTransceiver('video', { direction });\n this.pc.addTransceiver('audio', { direction });\n this.pc.onicecandidate = (evt) => this.onLocalCandidate(evt);\n this.pc.oniceconnectionstatechange = () => this.onConnectionState();\n this.pc.ontrack = (evt) => {\n console.log('new track:', evt.track.kind);\n this.video.srcObject = evt.streams[0];\n };\n this.pc.createOffer().then((offer) => this.onLocalOffer(offer));\n }\n onLocalOffer(offer) {\n editOffer(offer);\n this.offerData = parseOffer(offer.sdp);\n this.pc.setLocalDescription(offer);\n console.log('sending offer');\n fetch(new URL('whep', this.url), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/sdp',\n },\n body: offer.sdp,\n })\n .then((res) => {\n if (res.status !== 201) {\n throw new Error('bad status code');\n }\n this.sessionUrl = new URL(res.headers.get('location'), this.url).toString();\n return res.text();\n })\n .then((sdp) => this.onRemoteAnswer(new RTCSessionDescription({\n type: 'answer',\n sdp,\n })))\n .catch((err) => {\n console.log('error: ' + err);\n this.scheduleRestart();\n });\n }\n onConnectionState() {\n if (this.restartTimeout !== null) {\n return;\n }\n console.log('peer connection state:', this.pc.iceConnectionState);\n switch (this.pc.iceConnectionState) {\n case 'disconnected':\n this.scheduleRestart();\n }\n }\n onRemoteAnswer(answer) {\n if (this.restartTimeout !== null) {\n return;\n }\n this.pc.setRemoteDescription(answer);\n if (this.queuedCandidates.length !== 0) {\n this.sendLocalCandidates(this.queuedCandidates);\n this.queuedCandidates = [];\n }\n }\n onLocalCandidate(evt) {\n if (this.restartTimeout !== null) {\n return;\n }\n if (evt.candidate !== null) {\n if (this.sessionUrl === '') {\n this.queuedCandidates.push(evt.candidate);\n }\n else {\n this.sendLocalCandidates([evt.candidate]);\n }\n }\n }\n sendLocalCandidates(candidates) {\n fetch(this.sessionUrl + window.location.search, {\n method: 'PATCH',\n headers: {\n 'Content-Type': 'application/trickle-ice-sdpfrag',\n 'If-Match': '*',\n },\n body: generateSdpFragment(this.offerData, candidates),\n })\n .then((res) => {\n if (res.status !== 204) {\n throw new Error('bad status code');\n }\n })\n .catch((err) => {\n console.log('error: ' + err);\n this.scheduleRestart();\n });\n }\n scheduleRestart() {\n if (this.restartTimeout !== null) {\n return;\n }\n if (this.pc !== null) {\n this.pc.close();\n this.pc = null;\n }\n this.restartTimeout = window.setTimeout(() => {\n this.restartTimeout = null;\n this.start();\n }, restartPause);\n if (this.sessionUrl) {\n fetch(this.sessionUrl, {\n method: 'DELETE',\n })\n .then((res) => {\n if (res.status !== 200) {\n throw new Error('bad status code');\n }\n })\n .catch((err) => {\n console.log('delete session error: ' + err);\n });\n }\n this.sessionUrl = '';\n this.queuedCandidates = [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAMA,YAAY,GAAG,IAArB;;AACA,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,KAAD;EAAA,OAAWA,KAAK,KAAK,IAAV,GAC9BA,KAAK,CAACC,KAAN,CAAY,IAAZ,EAAkBC,GAAlB,CAAsB,UAACC,IAAD,EAAU;IAC9B,IAAMC,CAAC,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AU,IAAV;MACH;;MACD,KAAKC,cAAL,GAAsB6C,MAAM,CAACI,UAAP,CAAkB,YAAM;QAC1C,MAAI,CAACjD,cAAL,GAAsB,IAAtB;;QACA,MAAI,CAACG,KAAL;MACH,CAHqB,EAGnBrD,YAHmB,CAAtB;;MAIA,IAAI,KAAKmD,UAAT,EAAqB;QACjBK,KAAK,CAAC,KAAKL,UAAN,EAAkB;UACnBO,MAAM,EAAE;QADW,CAAlB,CAAL,CAGKC,IAHL,CAGU,UAACC,GAAD,EAAS;UACf,IAAIA,GAAG,CAACwB,MAAJ,KAAe,GAAnB,EAAwB;YACpB,MAAM,IAAIC,KAAJ,CAAU,iBAAV,CAAN;UACH;QACJ,CAPD,WAQW,UAACvB,GAAD,EAAS;UAChBR,OAAO,CAACC,GAAR,CAAY,2BAA2BO,GAAvC;QACH,CAVD;MAWH;;MACD,KAAKX,UAAL,GAAkB,EAAlB;MACA,KAAKC,gBAAL,GAAwB,EAAxB;IACH"}
|
package/package.json
CHANGED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
export default PlayerManager;
|
|
2
|
-
declare class PlayerManager {
|
|
3
|
-
constructor(opt: any);
|
|
4
|
-
el: any;
|
|
5
|
-
url: any;
|
|
6
|
-
realPlayer: any;
|
|
7
|
-
recordPlayer: any;
|
|
8
|
-
player: any;
|
|
9
|
-
type: any;
|
|
10
|
-
playNum: number;
|
|
11
|
-
playIndex: number;
|
|
12
|
-
dp: any;
|
|
13
|
-
initPlayer(): void;
|
|
14
|
-
/**
|
|
15
|
-
* 播放实时预览视频
|
|
16
|
-
* @param opt.streamType: {Number|String} 选填,码流类型,不填默认播放辅码流1,若不存在辅码流1,则自动切换到主码流 1-主码流 2-辅码流1 3-辅码流2
|
|
17
|
-
* @param opt.selectIndex: {Number} 选填,指定从哪个窗口开始播放。不填默认从选中的窗口开始播放
|
|
18
|
-
*/
|
|
19
|
-
playRealVideo(): void;
|
|
20
|
-
/**
|
|
21
|
-
* 播放录像回放
|
|
22
|
-
* @param opt.channelList {Array<Object>} 通道集合 必填
|
|
23
|
-
* @param opt.startTime {String|Number} 开始时间 必选 timestamp到秒
|
|
24
|
-
* @param opt.endTime {String|Number} 结束时间 必选 timestamp到秒
|
|
25
|
-
* @param opt.recordSource {String|Number} 录像来源 必选 2表示设备录像 3表示中心录像
|
|
26
|
-
* @param opt.streamType {String|Number} 码流类型 可选
|
|
27
|
-
* @param opt.recordType {String|Number} 录像类型 可选
|
|
28
|
-
*/
|
|
29
|
-
playRecordVideo(opt: any): void;
|
|
30
|
-
setVideoFrame(viewSize: any): void;
|
|
31
|
-
stopVideo(index: any): void;
|
|
32
|
-
/**
|
|
33
|
-
* 录像暂停
|
|
34
|
-
* 只有正在播放的录像调用才有效
|
|
35
|
-
*/
|
|
36
|
-
pause(): void;
|
|
37
|
-
/**
|
|
38
|
-
* 录像暂停后播放
|
|
39
|
-
* 只有暂停后的录像调用才有效
|
|
40
|
-
*/
|
|
41
|
-
play(): void;
|
|
42
|
-
/**
|
|
43
|
-
* 倍速播放
|
|
44
|
-
* @param {number} speed 速率 0.125 0.25 0.5 1 2 4 8 共7种速率
|
|
45
|
-
*/
|
|
46
|
-
playSpeed(speed: number): void;
|
|
47
|
-
/**
|
|
48
|
-
* 关闭播放器
|
|
49
|
-
* @param {number} index 可选,关闭指定索引的窗口的播放器,不传则表示关闭所有播放器
|
|
50
|
-
*/
|
|
51
|
-
close(index: number): void;
|
|
52
|
-
resize(): void;
|
|
53
|
-
/**
|
|
54
|
-
* 设置全屏
|
|
55
|
-
*/
|
|
56
|
-
setFullScreen(): void;
|
|
57
|
-
/**
|
|
58
|
-
* 设置窗口自适应还是拉伸
|
|
59
|
-
* @param {string} playerAdapter selfAdaption 自适应 | stretching 拉伸
|
|
60
|
-
*/
|
|
61
|
-
setPlayerAdapter(playerAdapter: string): void;
|
|
62
|
-
/**
|
|
63
|
-
* 控制视频播放器显示的路数: 1 4 9 16 25,不会超过最大显示路数
|
|
64
|
-
* @param {number} number
|
|
65
|
-
*/
|
|
66
|
-
setPlayerNum(number: number): void;
|
|
67
|
-
/**
|
|
68
|
-
* 设置选中的播放器的索引
|
|
69
|
-
* @param {number} index
|
|
70
|
-
*/
|
|
71
|
-
setSelectIndex(index: number): void;
|
|
72
|
-
/**
|
|
73
|
-
* 录像跳转播放
|
|
74
|
-
* @param {number} time HH:mm:ss格式
|
|
75
|
-
*/
|
|
76
|
-
jumpPlayByTime(time: number): void;
|
|
77
|
-
__receiveMessageFromWSPlayer(method: any, data: any): void;
|
|
78
|
-
currentChannelId: any;
|
|
79
|
-
}
|