@zegocloud/zego-uikit-prebuilt 1.3.5 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/1On1Call.html +49 -0
- package/groupCall.html +49 -0
- package/liveStream.html +68 -0
- package/package.json +1 -1
- package/videoConference.html +49 -0
- package/zego-uikit-prebuilt.js +1 -1
- package/index.html +0 -119
package/1On1Call.html
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
|
|
3
|
+
<head>
|
|
4
|
+
<style>
|
|
5
|
+
#root {
|
|
6
|
+
width: 100vw;
|
|
7
|
+
height: 100vh;
|
|
8
|
+
}
|
|
9
|
+
</style>
|
|
10
|
+
</head>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
<div id="root"></div>
|
|
15
|
+
</body>
|
|
16
|
+
<script src="https://resource.zegocloud.com/prebuilt/crypto-js.js"></script>
|
|
17
|
+
<script src="https://resource.zegocloud.com/prebuilt/prebuiltToken.js"></script>
|
|
18
|
+
<script src="https://unpkg.com/@zegocloud/zego-uikit-prebuilt@beta/zego-uikit-prebuilt.js"></script>
|
|
19
|
+
<script>
|
|
20
|
+
// Generate a Token by calling a method.
|
|
21
|
+
// @param 1: appID
|
|
22
|
+
// @param 2: serverSecret
|
|
23
|
+
// @param 3: Room ID
|
|
24
|
+
// @param 4: User ID
|
|
25
|
+
// @param 5: Username
|
|
26
|
+
const roomID = 'room01';
|
|
27
|
+
const userID = Math.floor(Math.random() * 10000) + "";
|
|
28
|
+
const userName = "userName" + userID;
|
|
29
|
+
const appID = 11111;
|
|
30
|
+
const serverSecret = "22076fd0a8388.......";
|
|
31
|
+
const TOKEN = generatePrebuiltToken(appID, serverSecret, roomID, userID, userName);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const zp = ZegoUIKitPrebuilt.create(TOKEN);
|
|
36
|
+
zp.joinRoom({
|
|
37
|
+
container: document.querySelector("#root"),
|
|
38
|
+
sharedLinks: [{
|
|
39
|
+
name: 'Join as Host',
|
|
40
|
+
url: window.location.origin + window.location.pathname + '?roomID=' + roomID,
|
|
41
|
+
}],
|
|
42
|
+
scenario: {
|
|
43
|
+
mode: ZegoUIKitPrebuilt.OneONoneCall, // To implement group calls, modify the parameter here to [ZegoUIKitPrebuilt.GroupCall].
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
</html>
|
package/groupCall.html
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
|
|
3
|
+
<head>
|
|
4
|
+
<style>
|
|
5
|
+
#root {
|
|
6
|
+
width: 100vw;
|
|
7
|
+
height: 100vh;
|
|
8
|
+
}
|
|
9
|
+
</style>
|
|
10
|
+
</head>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
<div id="root"></div>
|
|
15
|
+
</body>
|
|
16
|
+
<script src="https://resource.zegocloud.com/prebuilt/crypto-js.js"></script>
|
|
17
|
+
<script src="https://resource.zegocloud.com/prebuilt/prebuiltToken.js"></script>
|
|
18
|
+
<script src="https://unpkg.com/@zegocloud/zego-uikit-prebuilt@beta/zego-uikit-prebuilt.js"></script>
|
|
19
|
+
<script>
|
|
20
|
+
// Generate a Token by calling a method.
|
|
21
|
+
// @param 1: appID
|
|
22
|
+
// @param 2: serverSecret
|
|
23
|
+
// @param 3: Room ID
|
|
24
|
+
// @param 4: User ID
|
|
25
|
+
// @param 5: Username
|
|
26
|
+
const roomID = 'room01';
|
|
27
|
+
const userID = Math.floor(Math.random() * 10000) + "";
|
|
28
|
+
const userName = "userName" + userID;
|
|
29
|
+
const appID = 11111;
|
|
30
|
+
const serverSecret = "22076fd0a8388.......";
|
|
31
|
+
const TOKEN = generatePrebuiltToken(appID, serverSecret, roomID, userID, userName);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const zp = ZegoUIKitPrebuilt.create(TOKEN);
|
|
36
|
+
zp.joinRoom({
|
|
37
|
+
container: document.querySelector("#root"),
|
|
38
|
+
sharedLinks: [{
|
|
39
|
+
name: 'Join as Host',
|
|
40
|
+
url: window.location.origin + window.location.pathname + '?roomID=' + roomID,
|
|
41
|
+
}],
|
|
42
|
+
scenario: {
|
|
43
|
+
mode: ZegoUIKitPrebuilt.GroupCall, // To implement 1-on-1 calls, modify the parameter here to [ZegoUIKitPrebuilt.OneONoneCall].
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
</html>
|
package/liveStream.html
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
|
|
3
|
+
<head>
|
|
4
|
+
<style>
|
|
5
|
+
#root {
|
|
6
|
+
width: 100vw;
|
|
7
|
+
height: 100vh;
|
|
8
|
+
}
|
|
9
|
+
</style>
|
|
10
|
+
</head>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
<div id="root"></div>
|
|
15
|
+
</body>
|
|
16
|
+
<script src="https://resource.zegocloud.com/prebuilt/crypto-js.js"></script>
|
|
17
|
+
<script src="https://resource.zegocloud.com/prebuilt/prebuiltToken.js"></script>
|
|
18
|
+
<script src="https://unpkg.com/@zegocloud/zego-uikit-prebuilt@beta/zego-uikit-prebuilt.js"></script>
|
|
19
|
+
<script>
|
|
20
|
+
|
|
21
|
+
function getUrlParams(url) {
|
|
22
|
+
let urlStr = url.split('?')[1];
|
|
23
|
+
const urlSearchParams = new URLSearchParams(urlStr);
|
|
24
|
+
const result = Object.fromEntries(urlSearchParams.entries());
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// Generate a Token by calling a method.
|
|
30
|
+
// @param 1: appID
|
|
31
|
+
// @param 2: serverSecret
|
|
32
|
+
// @param 3: Room ID
|
|
33
|
+
// @param 4: User ID
|
|
34
|
+
// @param 5: Username
|
|
35
|
+
const roomID = 'room01';
|
|
36
|
+
const userID = Math.floor(Math.random() * 10000) + "";
|
|
37
|
+
const userName = "userName" + userID;
|
|
38
|
+
const appID = 11111;
|
|
39
|
+
const serverSecret = "22076fd0a83......";
|
|
40
|
+
const TOKEN = generatePrebuiltToken(appID, serverSecret, roomID, userID, userName);
|
|
41
|
+
|
|
42
|
+
// You can assign different roles based on url parameters.
|
|
43
|
+
let role = getUrlParams(window.location.href)['role'] || 'Host';
|
|
44
|
+
role = role === 'Host' ? ZegoUIKitPrebuilt.Host : ZegoUIKitPrebuilt.Audience;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const zp = ZegoUIKitPrebuilt.create(TOKEN);
|
|
48
|
+
zp.joinRoom({
|
|
49
|
+
container: document.querySelector("#root"),
|
|
50
|
+
scenario: {
|
|
51
|
+
mode: ZegoUIKitPrebuilt.LiveStreaming,
|
|
52
|
+
config: {
|
|
53
|
+
role,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
sharedLinks: [{
|
|
57
|
+
name: 'Join as audience',
|
|
58
|
+
url:
|
|
59
|
+
window.location.origin +
|
|
60
|
+
window.location.pathname +
|
|
61
|
+
'?roomID=' +
|
|
62
|
+
roomID +
|
|
63
|
+
'&role=Audience',
|
|
64
|
+
}]
|
|
65
|
+
});
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
</html>
|
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
|
|
3
|
+
<head>
|
|
4
|
+
<style>
|
|
5
|
+
#root {
|
|
6
|
+
width: 100vw;
|
|
7
|
+
height: 100vh;
|
|
8
|
+
}
|
|
9
|
+
</style>
|
|
10
|
+
</head>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
<div id="root"></div>
|
|
15
|
+
</body>
|
|
16
|
+
<script src="https://resource.zegocloud.com/prebuilt/crypto-js.js"></script>
|
|
17
|
+
<script src="https://resource.zegocloud.com/prebuilt/prebuiltToken.js"></script>
|
|
18
|
+
<script src="https://unpkg.com/@zegocloud/zego-uikit-prebuilt@beta/zego-uikit-prebuilt.js"></script>
|
|
19
|
+
<script>
|
|
20
|
+
// Generate a Token by calling a method.
|
|
21
|
+
// @param 1: appID
|
|
22
|
+
// @param 2: serverSecret
|
|
23
|
+
// @param 3: Room ID
|
|
24
|
+
// @param 4: User ID
|
|
25
|
+
// @param 5: Username
|
|
26
|
+
const roomID = 'room01';
|
|
27
|
+
const userID = Math.floor(Math.random() * 10000) + "";
|
|
28
|
+
const userName = "userName" + userID;
|
|
29
|
+
const appID = 11111;
|
|
30
|
+
const serverSecret = "22076fd0a8388.......";
|
|
31
|
+
const TOKEN = generatePrebuiltToken(appID, serverSecret, roomID, userID, userName);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const zp = ZegoUIKitPrebuilt.create(TOKEN);
|
|
36
|
+
zp.joinRoom({
|
|
37
|
+
container: document.querySelector("#root"),
|
|
38
|
+
sharedLinks: [{
|
|
39
|
+
name: 'Join as Host',
|
|
40
|
+
url: window.location.origin + window.location.pathname + '?roomID=' + roomID,
|
|
41
|
+
}],
|
|
42
|
+
scenario: {
|
|
43
|
+
mode: ZegoUIKitPrebuilt.VideoConference,
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
</html>
|
package/zego-uikit-prebuilt.js
CHANGED
|
@@ -1566,7 +1566,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
1566
1566
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1567
1567
|
|
|
1568
1568
|
"use strict";
|
|
1569
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ZegoCloudRTCCore\": function() { return /* binding */ ZegoCloudRTCCore; }\n/* harmony export */ });\n/* harmony import */ var _tools_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools/util */ \"./src/sdk/modules/tools/util.ts\");\n/* harmony import */ var zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! zego-express-engine-webrtc */ \"./node_modules/zego-express-engine-webrtc/ZegoExpressWebRTC.js\");\n/* harmony import */ var zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../model */ \"./src/sdk/model/index.ts\");\n/* harmony import */ var _tools_UserListManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tools/UserListManager */ \"./src/sdk/modules/tools/UserListManager.ts\");\nvar __assign = (undefined && undefined.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n};\n\n\n\n\nvar ZegoCloudRTCCore = /** @class */ (function () {\n function ZegoCloudRTCCore() {\n var _this = this;\n this.status = {\n loginRsp: false,\n videoRefuse: false,\n audioRefuse: false,\n };\n this.remoteStreamMap = {};\n this._config = {\n // @ts-ignore\n container: undefined,\n preJoinViewConfig: {\n title: \"Join Room\",\n invitationLink: window.location.href, // 邀请链接,空则不显示,默认空\n },\n showPreJoinView: true,\n turnOnMicrophoneWhenJoining: true,\n turnOnCameraWhenJoining: true,\n showMyCameraToggleButton: true,\n showMyMicrophoneToggleButton: true,\n showAudioVideoSettingsButton: true,\n showTextChat: true,\n showUserList: true,\n lowerLeftNotification: {\n showUserJoinAndLeave: true,\n showTextChat: true, // 是否显示未读消息,默认显示\n },\n branding: {\n logoURL: \"\",\n },\n showLeavingView: true,\n maxUsers: 2,\n layout: \"Auto\",\n showNonVideoUser: true,\n showOnlyAudioUser: false,\n useFrontFacingCamera: true,\n onJoinRoom: function () { },\n onLeaveRoom: function () { },\n onUserJoin: function (user) { },\n onUserLeave: function (user) { },\n sharedLinks: [],\n showScreenSharingButton: true,\n scenario: {\n mode: _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall,\n config: { role: _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host }, // 对应场景专有配置\n },\n facingMode: \"user\",\n joinRoomCallback: function () { },\n leaveRoomCallback: function () { },\n userUpdateCallback: function () { },\n showLayoutButton: true,\n showPinButton: true, // 是否显pin按钮\n };\n this._currentPage = \"BrowserCheckPage\";\n this.extraInfoKey = \"extra_info\";\n this._roomExtraInfo = {\n live_status: {\n v: 0,\n u: \"xxx\",\n r: 0,\n },\n };\n this.waitingHandlerStreams = { add: [], delete: [] };\n this.onRemoteMediaUpdateCallBack = function (updateType, streamList) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.zum.mainStreamUpdate(updateType, streamList)];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.zum.screenStreamUpdate(updateType, streamList)];\n case 2:\n _a.sent();\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n this.subscribeScreenStreamCallBack &&\n this.subscribeScreenStreamCallBack(__spreadArray([], this.zum.remoteScreenStreamList, true));\n return [2 /*return*/];\n }\n });\n }); };\n this.NetworkStatusTimer = null;\n }\n // static _soundMeter: SoundMeter;\n ZegoCloudRTCCore.getInstance = function (token) {\n var config = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.getConfig)(token);\n if (!ZegoCloudRTCCore._instance && config) {\n ZegoCloudRTCCore._instance = new ZegoCloudRTCCore();\n ZegoCloudRTCCore._instance._expressConfig = config;\n // ZegoCloudRTCCore._soundMeter = new SoundMeter();\n ZegoCloudRTCCore._zg = new zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1__.ZegoExpressEngine(ZegoCloudRTCCore._instance._expressConfig.appID, \"wss://webliveroom\" +\n ZegoCloudRTCCore._instance._expressConfig.appID +\n \"-api.zegocloud.com/ws\");\n ZegoCloudRTCCore._instance.zum = new _tools_UserListManager__WEBPACK_IMPORTED_MODULE_3__.ZegoCloudUserListManager(ZegoCloudRTCCore._zg);\n }\n return ZegoCloudRTCCore._instance;\n };\n ZegoCloudRTCCore.prototype.checkWebRTC = function () {\n return __awaiter(this, void 0, void 0, function () {\n var result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, ZegoCloudRTCCore._zg.checkSystemRequirements(\"webRTC\")];\n case 1:\n result = _a.sent();\n return [2 /*return*/, !!result.result];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.setConfig = function (config) {\n var _a, _b, _c, _d;\n if (config.scenario &&\n config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming) {\n if (config.showNonVideoUser === true) {\n console.error(\"【ZEGOCLOUD】 showNonVideoUser have be false scenario.mode is LiveStreaming!!\");\n return false;\n }\n config.showNonVideoUser = false;\n config.showOnlyAudioUser = true;\n if (config.scenario.config &&\n config.scenario.config.role === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host) {\n if (config.turnOnMicrophoneWhenJoining === false &&\n config.turnOnCameraWhenJoining === false &&\n config.showMyCameraToggleButton === false &&\n config.showAudioVideoSettingsButton === false) {\n console.error(\"【ZEGOCLOUD】 Host could turn on at least one of the camera and the microphone!!\");\n return false;\n }\n }\n else if (config.scenario.config &&\n config.scenario.config.role === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience) {\n if (config.turnOnMicrophoneWhenJoining === true ||\n config.turnOnCameraWhenJoining === true ||\n config.showMyCameraToggleButton === true ||\n config.showMyMicrophoneToggleButton === true ||\n config.showAudioVideoSettingsButton === true ||\n config.showScreenSharingButton === true ||\n config.useFrontFacingCamera === true ||\n (!!config.layout && config.layout !== \"Grid\")) {\n console.error(\"【ZEGOCLOUD】 Audience cannot configure camera and microphone related params\");\n return false;\n }\n }\n if (!config.maxUsers) {\n config.maxUsers = 5000;\n }\n if (config.scenario.config &&\n config.scenario.config.role === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience) {\n config.turnOnMicrophoneWhenJoining = false;\n config.turnOnCameraWhenJoining = false;\n config.showMyCameraToggleButton = false;\n config.showMyMicrophoneToggleButton = false;\n config.showAudioVideoSettingsButton = false;\n config.showScreenSharingButton = false;\n config.useFrontFacingCamera = false;\n config.useFrontFacingCamera = false;\n config.showUserList = false;\n config.showPinButton = false;\n config.showLayoutButton = false;\n config.layout = \"Grid\";\n config.lowerLeftNotification = {\n showTextChat: false,\n showUserJoinAndLeave: false,\n };\n }\n }\n if (config.scenario &&\n config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall) {\n if (!config.maxUsers) {\n config.maxUsers = 2;\n }\n config.showLayoutButton = false;\n config.showPinButton = false;\n }\n if (config.scenario && config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.GroupCall) {\n if (!config.maxUsers) {\n config.maxUsers = 50;\n }\n }\n config.facingMode &&\n (config.useFrontFacingCamera = config.facingMode === \"user\");\n config.joinRoomCallback && (config.onJoinRoom = config.joinRoomCallback);\n config.leaveRoomCallback && (config.onLeaveRoom = config.leaveRoomCallback);\n if (config.userUpdateCallback) {\n config.onUserJoin = function (users) {\n config.userUpdateCallback && config.userUpdateCallback(\"ADD\", users);\n };\n config.onUserLeave = function (users) {\n config.userUpdateCallback && config.userUpdateCallback(\"DELETE\", users);\n };\n }\n if (config.preJoinViewConfig && config.preJoinViewConfig.invitationLink) {\n config.sharedLinks = [\n {\n name: \"Share the link\",\n url: config.preJoinViewConfig.invitationLink,\n },\n ];\n }\n config.preJoinViewConfig &&\n (config.preJoinViewConfig = __assign(__assign({}, this._config.preJoinViewConfig), config.preJoinViewConfig));\n config.scenario &&\n config.scenario.config &&\n (config.scenario.config = __assign(__assign({}, (_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.config), config.scenario.config));\n this._config = __assign(__assign({}, this._config), config);\n this.zum.scenario =\n ((_b = this._config.scenario) === null || _b === void 0 ? void 0 : _b.mode) || _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall;\n this.zum.role = ((_d = (_c = this._config.scenario) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.role) || _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host;\n this.zum.showOnlyAudioUser = !!this._config.showOnlyAudioUser;\n this.zum.setShowNonVideo(!!this._config.showNonVideoUser);\n return true;\n };\n ZegoCloudRTCCore.prototype.setPin = function (userID, pined) {\n this.zum.setPin(userID, pined);\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n };\n ZegoCloudRTCCore.prototype.setMaxScreenNum = function (num) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.zum.setMaxScreenNum(num)];\n case 1:\n _a.sent();\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n return [2 /*return*/];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.setSidebarLayOut = function (enable) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.zum.setSidebarLayOut(enable)];\n case 1:\n _a.sent();\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n return [2 /*return*/];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.setShowNonVideo = function (enable) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.zum.setShowNonVideo(enable)];\n case 1:\n _a.sent();\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n return [2 /*return*/];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.setCurrentPage = function (page) {\n this._currentPage = page;\n };\n ZegoCloudRTCCore.prototype.getCameras = function () {\n return ZegoCloudRTCCore._zg.getCameras();\n };\n ZegoCloudRTCCore.prototype.useVideoDevice = function (localStream, deviceID) {\n return ZegoCloudRTCCore._zg.useVideoDevice(localStream, deviceID);\n };\n ZegoCloudRTCCore.prototype.getMicrophones = function () {\n return ZegoCloudRTCCore._zg.getMicrophones();\n };\n ZegoCloudRTCCore.prototype.getSpeakers = function () {\n return ZegoCloudRTCCore._zg.getSpeakers();\n };\n ZegoCloudRTCCore.prototype.setVolume = function (media, volume) {\n media.volume = volume;\n };\n ZegoCloudRTCCore.prototype.createStream = function (source) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.createStream(source)];\n });\n });\n };\n ZegoCloudRTCCore.prototype.setVideoConfig = function (media, constraints) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.setVideoConfig(media, constraints)];\n });\n });\n };\n ZegoCloudRTCCore.prototype.stopPublishingStream = function (streamID) {\n return ZegoCloudRTCCore._zg.stopPublishingStream(streamID);\n };\n ZegoCloudRTCCore.prototype.destroyStream = function (stream) {\n ZegoCloudRTCCore._zg.destroyStream(stream);\n };\n ZegoCloudRTCCore.prototype.useCameraDevice = function (media, deviceID) {\n return ZegoCloudRTCCore._zg.useVideoDevice(media, deviceID);\n };\n ZegoCloudRTCCore.prototype.useMicrophoneDevice = function (media, deviceID) {\n return ZegoCloudRTCCore._zg.useAudioDevice(media, deviceID);\n };\n ZegoCloudRTCCore.prototype.useSpeakerDevice = function (media, deviceID) {\n return __awaiter(this, void 0, void 0, function () {\n var res, error_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!media.srcObject) {\n return [2 /*return*/, Promise.resolve({ errorCode: -1 })];\n }\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n return [4 /*yield*/, ZegoCloudRTCCore._zg.useAudioOutputDevice(media, deviceID)];\n case 2:\n res = _a.sent();\n return [2 /*return*/, { errorCode: res ? 0 : -1 }];\n case 3:\n error_1 = _a.sent();\n return [2 /*return*/, { errorCode: -1 }];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.enableVideoCaptureDevice = function (localStream, enable) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.enableVideoCaptureDevice(localStream, enable)];\n });\n });\n };\n ZegoCloudRTCCore.prototype.mutePublishStreamVideo = function (localStream, enable) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.mutePublishStreamVideo(localStream, enable)];\n });\n });\n };\n ZegoCloudRTCCore.prototype.mutePublishStreamAudio = function (localStream, enable) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.mutePublishStreamAudio(localStream, enable)];\n });\n });\n };\n ZegoCloudRTCCore.prototype.muteMicrophone = function (enable) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.muteMicrophone(enable)];\n });\n });\n };\n Object.defineProperty(ZegoCloudRTCCore.prototype, \"roomExtraInfo\", {\n get: function () {\n return this._roomExtraInfo;\n },\n set: function (value) {\n var _this = this;\n if (this._currentPage === \"Room\") {\n this._roomExtraInfo = value;\n this.zum.setLiveStates(this._roomExtraInfo.live_status.v);\n console.error(\"【ZEGOCLOUD】roomExtraInfo choui\", value, this.onRoomLiveStateUpdateCallBack);\n this.onRoomLiveStateUpdateCallBack &&\n this.onRoomLiveStateUpdateCallBack(this._roomExtraInfo.live_status.v);\n }\n else if (this._currentPage === \"BrowserCheckPage\") {\n setTimeout(function () {\n _this.roomExtraInfo = value;\n }, 1000);\n }\n },\n enumerable: false,\n configurable: true\n });\n ZegoCloudRTCCore.prototype.setLive = function (status) {\n var _a, _b, _c, _d;\n return __awaiter(this, void 0, void 0, function () {\n var setRoomExtraInfo, res;\n return __generator(this, function (_e) {\n switch (_e.label) {\n case 0:\n setRoomExtraInfo = __assign(__assign({}, this._roomExtraInfo), {\n live_status: {\n v: status === \"live\" ? 1 : 0,\n u: ZegoCloudRTCCore._instance._expressConfig.userID,\n r: ((_b = (_a = ZegoCloudRTCCore._instance._config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.role) ===\n _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host\n ? 1\n : ((_d = (_c = ZegoCloudRTCCore._instance._config.scenario) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.role) ===\n _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience\n ? 2\n : 3,\n },\n });\n return [4 /*yield*/, ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo))];\n case 1:\n res = _e.sent();\n res.errorCode === 0 && (this.roomExtraInfo = setRoomExtraInfo);\n return [2 /*return*/, res.errorCode === 0];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.enterRoom = function () {\n return __awaiter(this, void 0, void 0, function () {\n var resp;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n // 已经登陆过不再登录\n if (this.status.loginRsp)\n return [2 /*return*/, Promise.resolve(0)];\n ZegoCloudRTCCore._zg.off(\"roomExtraInfoUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomStreamUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteCameraStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteMicStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"playerStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomUserUpdate\");\n ZegoCloudRTCCore._zg.off(\"IMRecvBroadcastMessage\");\n ZegoCloudRTCCore._zg.off(\"roomStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publisherStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publishQualityUpdate\");\n ZegoCloudRTCCore._zg.off(\"soundLevelUpdate\");\n ZegoCloudRTCCore._zg.on(\"roomStreamUpdate\", function (roomID, updateType, streamList, extendedData) { return __awaiter(_this, void 0, void 0, function () {\n var willDelete_1;\n return __generator(this, function (_a) {\n console.warn(\"【ZEGOCLOUD】roomStreamUpdate\", updateType, streamList);\n if (updateType === \"ADD\") {\n this.waitingHandlerStreams.add = __spreadArray(__spreadArray([], this.waitingHandlerStreams.add, true), streamList, true);\n this.waitingHandlerStreams.delete =\n this.waitingHandlerStreams.delete.filter(function (stream) {\n if (streamList.some(function (add_stream) { return add_stream.streamID === stream.streamID; })) {\n return false;\n }\n else {\n return true;\n }\n });\n }\n else {\n willDelete_1 = [];\n // 新增流中,删除下线的流\n this.waitingHandlerStreams.add =\n this.waitingHandlerStreams.add.filter(function (stream) {\n if (streamList.some(function (delete_stream) {\n if (delete_stream.streamID === stream.streamID) {\n willDelete_1.push(delete_stream.streamID);\n return true;\n }\n else {\n return false;\n }\n })) {\n return false;\n }\n else {\n return true;\n }\n });\n // 删除流中,去除上次要新增的\n streamList = streamList.filter(function (s) {\n if (willDelete_1.some(function (wd) { return wd == s.streamID; })) {\n return false;\n }\n else {\n return true;\n }\n });\n this.waitingHandlerStreams.delete = __spreadArray(__spreadArray([], this.waitingHandlerStreams.delete, true), streamList, true);\n }\n return [2 /*return*/];\n });\n }); });\n ZegoCloudRTCCore._zg.on(\"roomExtraInfoUpdate\", function (roomID, roomExtraInfoList) {\n roomExtraInfoList.forEach(function (info) {\n if (info.key === _this.extraInfoKey) {\n console.error(\"【ZEGOCLOUD】choui\", info.value);\n _this.roomExtraInfo = JSON.parse(info.value);\n }\n });\n });\n ZegoCloudRTCCore._zg.on(\"remoteCameraStatusUpdate\", function (streamID, status) {\n if (_this.remoteStreamMap[streamID]) {\n _this.remoteStreamMap[streamID].cameraStatus = status;\n _this.onRemoteMediaUpdateCallBack &&\n _this.onRemoteMediaUpdateCallBack(\"UPDATE\", [\n _this.remoteStreamMap[streamID],\n ]);\n }\n });\n ZegoCloudRTCCore._zg.on(\"remoteMicStatusUpdate\", function (streamID, status) {\n if (_this.remoteStreamMap[streamID]) {\n _this.remoteStreamMap[streamID].micStatus = status;\n _this.onRemoteMediaUpdateCallBack &&\n _this.onRemoteMediaUpdateCallBack(\"UPDATE\", [\n _this.remoteStreamMap[streamID],\n ]);\n }\n });\n ZegoCloudRTCCore._zg.on(\"playerStateUpdate\", function (streamInfo) {\n console.warn(\"【ZEGOCLOUD】\", streamInfo);\n if (_this.remoteStreamMap[streamInfo.streamID]) {\n _this.remoteStreamMap[streamInfo.streamID].state = streamInfo.state;\n _this.onRemoteMediaUpdateCallBack &&\n _this.onRemoteMediaUpdateCallBack(\"UPDATE\", [\n _this.remoteStreamMap[streamInfo.streamID],\n ]);\n }\n });\n ZegoCloudRTCCore._zg.on(\"roomUserUpdate\", function (roomID, updateType, userList) {\n console.warn(\"【ZEGOCLOUD】roomUserUpdate\", updateType, userList);\n _this.onRemoteUserUpdateCallBack &&\n _this.onRemoteUserUpdateCallBack(roomID, updateType, userList);\n setTimeout(function () {\n if (updateType === \"ADD\") {\n _this._config.onUserJoin && _this._config.onUserJoin(userList);\n }\n else {\n _this._config.onUserLeave && _this._config.onUserLeave(userList);\n }\n }, 0);\n });\n ZegoCloudRTCCore._zg.on(\"IMRecvBroadcastMessage\", function (roomID, chatData) {\n _this.onRoomMessageUpdateCallBack &&\n _this.onRoomMessageUpdateCallBack(roomID, chatData);\n });\n ZegoCloudRTCCore._zg.on(\"publisherStateUpdate\", function (streamInfo) {\n var state = \"DISCONNECTED\";\n if (streamInfo.state === \"PUBLISHING\") {\n state = \"CONNECTED\";\n }\n else if (streamInfo.state === \"NO_PUBLISH\") {\n state = \"DISCONNECTED\";\n }\n else if (streamInfo.state === \"PUBLISH_REQUESTING\") {\n state = \"CONNECTING\";\n }\n _this.onNetworkStatusCallBack &&\n _this.onNetworkStatusCallBack(ZegoCloudRTCCore._instance._expressConfig.roomID, \"STREAM\", state);\n });\n ZegoCloudRTCCore._zg.on(\"playQualityUpdate\", function (streamID, stats) {\n _this.onNetworkStatusQualityCallBack &&\n _this.onNetworkStatusQualityCallBack(streamID, Math.max(stats.video.videoQuality, stats.audio.audioQuality));\n });\n ZegoCloudRTCCore._zg.on(\"publishQualityUpdate\", function (streamID, stats) {\n _this.onNetworkStatusQualityCallBack &&\n _this.onNetworkStatusQualityCallBack(streamID, Math.max(stats.video.videoQuality, stats.audio.audioQuality));\n });\n ZegoCloudRTCCore._zg.on(\"soundLevelUpdate\", function (soundLevelList) {\n _this.onSoundLevelUpdateCallBack &&\n _this.onSoundLevelUpdateCallBack(soundLevelList);\n });\n ZegoCloudRTCCore._zg.on(\"screenSharingEnded\", function (stream) {\n _this.onScreenSharingEndedCallBack &&\n _this.onScreenSharingEndedCallBack(stream);\n });\n return [4 /*yield*/, new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n ZegoCloudRTCCore._zg.on(\"roomStateUpdate\", function (roomID, state, errorCode, extendedData) {\n _this.onNetworkStatusCallBack &&\n _this.onNetworkStatusCallBack(roomID, \"ROOM\", state);\n if (state === \"CONNECTED\" || state === \"DISCONNECTED\") {\n _this.status.loginRsp = errorCode === 0;\n res(errorCode);\n }\n });\n return [4 /*yield*/, ZegoCloudRTCCore._zg.loginRoom(ZegoCloudRTCCore._instance._expressConfig.roomID, ZegoCloudRTCCore._instance._expressConfig.token, {\n userID: ZegoCloudRTCCore._instance._expressConfig.userID,\n userName: ZegoCloudRTCCore._instance._expressConfig.userName,\n }, {\n userUpdate: true,\n maxMemberCount: ZegoCloudRTCCore._instance._config.maxUsers,\n })];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n }); })];\n case 1:\n resp = _a.sent();\n ZegoCloudRTCCore._zg.setSoundLevelDelegate(true, 300);\n this.streamUpdateTimer(this.waitingHandlerStreams);\n return [2 /*return*/, resp];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.streamUpdateTimer = function (_waitingHandlerStreams) {\n return __awaiter(this, void 0, void 0, function () {\n var _streamList, i, streamInfo, stream, error_2, i, streamInfo;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(this._currentPage === \"Room\")) return [3 /*break*/, 13];\n _streamList = [];\n if (!(_waitingHandlerStreams.add.length > 0)) return [3 /*break*/, 7];\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < _waitingHandlerStreams.add.length)) return [3 /*break*/, 6];\n streamInfo = _waitingHandlerStreams.add[i];\n _a.label = 2;\n case 2:\n _a.trys.push([2, 4, , 5]);\n return [4 /*yield*/, this.zum.startPullStream(streamInfo.user.userID, streamInfo.streamID)];\n case 3:\n stream = _a.sent();\n this.remoteStreamMap[streamInfo.streamID] = {\n fromUser: streamInfo.user,\n media: stream,\n micStatus: stream && stream.getAudioTracks().length > 0 ? \"OPEN\" : \"MUTE\",\n cameraStatus: stream && stream.getVideoTracks().length > 0 ? \"OPEN\" : \"MUTE\",\n state: \"PLAYING\",\n streamID: streamInfo.streamID,\n };\n _streamList.push(this.remoteStreamMap[streamInfo.streamID]);\n return [3 /*break*/, 5];\n case 4:\n error_2 = _a.sent();\n console.warn(\"【ZEGOCLOUD】:startPlayingStream error\", error_2);\n return [3 /*break*/, 5];\n case 5:\n i++;\n return [3 /*break*/, 1];\n case 6:\n this.onRemoteMediaUpdateCallBack &&\n _streamList.length > 0 &&\n this.onRemoteMediaUpdateCallBack(\"ADD\", _streamList);\n _a.label = 7;\n case 7:\n if (!(_waitingHandlerStreams.delete.length > 0)) return [3 /*break*/, 12];\n _streamList = [];\n i = 0;\n _a.label = 8;\n case 8:\n if (!(i < _waitingHandlerStreams.delete.length)) return [3 /*break*/, 11];\n streamInfo = _waitingHandlerStreams.delete[i];\n if (!this.remoteStreamMap[streamInfo.streamID]) {\n debugger;\n }\n this.remoteStreamMap[streamInfo.streamID] &&\n _streamList.push(this.remoteStreamMap[streamInfo.streamID]);\n return [4 /*yield*/, this.zum.stopPullStream(streamInfo.user.userID, streamInfo.streamID)];\n case 9:\n _a.sent();\n delete this.remoteStreamMap[streamInfo.streamID];\n _a.label = 10;\n case 10:\n i++;\n return [3 /*break*/, 8];\n case 11:\n this.onRemoteMediaUpdateCallBack &&\n _streamList.length > 0 &&\n this.onRemoteMediaUpdateCallBack(\"DELETE\", _streamList);\n _a.label = 12;\n case 12:\n setTimeout(function () {\n var nextWaitingHandlerStreams = {\n add: __spreadArray([], _this.waitingHandlerStreams.add, true),\n delete: __spreadArray([], _this.waitingHandlerStreams.delete, true),\n };\n _this.waitingHandlerStreams = {\n add: [],\n delete: [],\n };\n _this.streamUpdateTimer(nextWaitingHandlerStreams);\n }, 700);\n return [3 /*break*/, 14];\n case 13:\n if (this._currentPage === \"BrowserCheckPage\") {\n setTimeout(function () {\n _this.streamUpdateTimer(_waitingHandlerStreams);\n }, 1000);\n }\n _a.label = 14;\n case 14: return [2 /*return*/];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.publishLocalStream = function (media, streamType) {\n if (!media)\n return false;\n var streamID = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.generateStreamID)(this._expressConfig.userID, this._expressConfig.roomID, streamType);\n var res = ZegoCloudRTCCore._zg.startPublishingStream(streamID, media);\n return res && streamID;\n };\n ZegoCloudRTCCore.prototype.replaceTrack = function (media, mediaStreamTrack) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.replaceTrack(media, mediaStreamTrack)];\n });\n });\n };\n ZegoCloudRTCCore.prototype.subscribeUserList = function (callback) {\n this.subscribeUserListCallBack = callback;\n };\n ZegoCloudRTCCore.prototype.subscribeScreenStream = function (callback) {\n this.subscribeScreenStreamCallBack = callback;\n };\n ZegoCloudRTCCore.prototype.onRemoteMediaUpdate = function (func) {\n var _this = this;\n this.onRemoteMediaUpdateCallBack = function (updateType, streamList) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n func(updateType, streamList);\n return [4 /*yield*/, this.zum.mainStreamUpdate(updateType, streamList)];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.zum.screenStreamUpdate(updateType, streamList)];\n case 2:\n _a.sent();\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n this.subscribeScreenStreamCallBack &&\n this.subscribeScreenStreamCallBack(__spreadArray([], this.zum.remoteScreenStreamList, true));\n return [2 /*return*/];\n }\n });\n }); };\n };\n ZegoCloudRTCCore.prototype.onNetworkStatusQuality = function (func) {\n this.onNetworkStatusQualityCallBack = func;\n };\n ZegoCloudRTCCore.prototype.onRemoteUserUpdate = function (func) {\n var _this = this;\n this.onRemoteUserUpdateCallBack = function (roomID, updateType, users) { return __awaiter(_this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(this._currentPage === \"BrowserCheckPage\")) return [3 /*break*/, 1];\n setTimeout(function () {\n _this.onRemoteUserUpdateCallBack(roomID, updateType, users);\n }, 1000);\n return [3 /*break*/, 3];\n case 1:\n if (!(this._currentPage === \"Room\")) return [3 /*break*/, 3];\n func(roomID, updateType, users);\n return [4 /*yield*/, this.zum.userUpdate(roomID, updateType, users)];\n case 2:\n _a.sent();\n setTimeout(function () {\n console.warn(\"【ZEGOCLOUD】roomUserUpdate\", __spreadArray([], _this.zum.remoteUserList, true), __spreadArray([], _this.zum.remoteUserList, true).length);\n _this.subscribeUserListCallBack &&\n _this.subscribeUserListCallBack(__spreadArray([], _this.zum.remoteUserList, true));\n }, 0);\n _a.label = 3;\n case 3: return [2 /*return*/];\n }\n });\n }); };\n };\n ZegoCloudRTCCore.prototype.onSoundLevelUpdate = function (func) {\n this.onSoundLevelUpdateCallBack = func;\n };\n ZegoCloudRTCCore.prototype.onRoomLiveStateUpdate = function (func) {\n this.onRoomLiveStateUpdateCallBack = func;\n };\n ZegoCloudRTCCore.prototype.sendRoomMessage = function (message) {\n return ZegoCloudRTCCore._zg.sendBroadcastMessage(ZegoCloudRTCCore._instance._expressConfig.roomID, message);\n };\n ZegoCloudRTCCore.prototype.onRoomMessageUpdate = function (func) {\n this.onRoomMessageUpdateCallBack = func;\n };\n ZegoCloudRTCCore.prototype.onScreenSharingEnded = function (func) {\n this.onScreenSharingEndedCallBack = func;\n };\n ZegoCloudRTCCore.prototype.onNetworkStatus = function (func) {\n var _this = this;\n this.onNetworkStatusCallBack = function (roomID, type, status) {\n if (status === \"CONNECTING\") {\n !_this.NetworkStatusTimer &&\n (_this.NetworkStatusTimer = setTimeout(function () {\n func(roomID, type, \"DISCONNECTED\");\n }, 60000));\n }\n else {\n if (_this.NetworkStatusTimer) {\n clearTimeout(_this.NetworkStatusTimer);\n _this.NetworkStatusTimer = null;\n }\n }\n func(roomID, type, status);\n };\n };\n ZegoCloudRTCCore.prototype.leaveRoom = function () {\n var _this = this;\n if (!this.status.loginRsp)\n return;\n ZegoCloudRTCCore._zg.off(\"roomExtraInfoUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomStreamUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteCameraStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteMicStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"playerStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomUserUpdate\");\n ZegoCloudRTCCore._zg.off(\"IMRecvBroadcastMessage\");\n ZegoCloudRTCCore._zg.off(\"roomStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publisherStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publishQualityUpdate\");\n ZegoCloudRTCCore._zg.off(\"soundLevelUpdate\");\n ZegoCloudRTCCore._zg.off(\"screenSharingEnded\");\n ZegoCloudRTCCore._zg.setSoundLevelDelegate(false);\n this.onNetworkStatusCallBack = function () { };\n this.onRemoteMediaUpdateCallBack = function (updateType, streamList) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.zum.mainStreamUpdate(updateType, streamList)];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.zum.screenStreamUpdate(updateType, streamList)];\n case 2:\n _a.sent();\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n this.subscribeScreenStreamCallBack &&\n this.subscribeScreenStreamCallBack(__spreadArray([], this.zum.remoteScreenStreamList, true));\n return [2 /*return*/];\n }\n });\n }); };\n this.onRemoteUserUpdateCallBack = function () { };\n this.onRoomMessageUpdateCallBack = function () { };\n this.onRoomLiveStateUpdateCallBack = function () { };\n this.subscribeUserListCallBack = function () { };\n this.zum.reset();\n for (var key in this.remoteStreamMap) {\n ZegoCloudRTCCore._zg.stopPlayingStream(key);\n }\n this.remoteStreamMap = {};\n ZegoCloudRTCCore._zg.logoutRoom();\n this.status.loginRsp = false;\n };\n return ZegoCloudRTCCore;\n}());\n\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/modules/index.ts?");
|
|
1569
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ZegoCloudRTCCore\": function() { return /* binding */ ZegoCloudRTCCore; }\n/* harmony export */ });\n/* harmony import */ var _tools_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools/util */ \"./src/sdk/modules/tools/util.ts\");\n/* harmony import */ var zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! zego-express-engine-webrtc */ \"./node_modules/zego-express-engine-webrtc/ZegoExpressWebRTC.js\");\n/* harmony import */ var zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../model */ \"./src/sdk/model/index.ts\");\n/* harmony import */ var _tools_UserListManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tools/UserListManager */ \"./src/sdk/modules/tools/UserListManager.ts\");\nvar __assign = (undefined && undefined.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n};\n\n\n\n\nvar ZegoCloudRTCCore = /** @class */ (function () {\n function ZegoCloudRTCCore() {\n var _this = this;\n this.status = {\n loginRsp: false,\n videoRefuse: false,\n audioRefuse: false,\n };\n this.remoteStreamMap = {};\n this._config = {\n // @ts-ignore\n container: undefined,\n preJoinViewConfig: {\n title: \"Join Room\",\n invitationLink: window.location.href, // 邀请链接,空则不显示,默认空\n },\n showPreJoinView: true,\n turnOnMicrophoneWhenJoining: true,\n turnOnCameraWhenJoining: true,\n showMyCameraToggleButton: true,\n showMyMicrophoneToggleButton: true,\n showAudioVideoSettingsButton: true,\n showTextChat: true,\n showUserList: true,\n lowerLeftNotification: {\n showUserJoinAndLeave: true,\n showTextChat: true, // 是否显示未读消息,默认显示\n },\n branding: {\n logoURL: \"\",\n },\n showLeavingView: true,\n maxUsers: 2,\n layout: \"Auto\",\n showNonVideoUser: true,\n showOnlyAudioUser: false,\n useFrontFacingCamera: true,\n onJoinRoom: function () { },\n onLeaveRoom: function () { },\n onUserJoin: function (user) { },\n onUserLeave: function (user) { },\n sharedLinks: [],\n showScreenSharingButton: true,\n scenario: {\n mode: _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall,\n config: { role: _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host }, // 对应场景专有配置\n },\n facingMode: \"user\",\n joinRoomCallback: function () { },\n leaveRoomCallback: function () { },\n userUpdateCallback: function () { },\n showLayoutButton: true,\n showPinButton: true, // 是否显pin按钮\n };\n this._currentPage = \"BrowserCheckPage\";\n this.extraInfoKey = \"extra_info\";\n this._roomExtraInfo = {\n live_status: {\n v: 0,\n u: \"xxx\",\n r: 0,\n },\n };\n this.waitingHandlerStreams = { add: [], delete: [] };\n this.onRemoteMediaUpdateCallBack = function (updateType, streamList) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.zum.mainStreamUpdate(updateType, streamList)];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.zum.screenStreamUpdate(updateType, streamList)];\n case 2:\n _a.sent();\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n this.subscribeScreenStreamCallBack &&\n this.subscribeScreenStreamCallBack(__spreadArray([], this.zum.remoteScreenStreamList, true));\n return [2 /*return*/];\n }\n });\n }); };\n this.NetworkStatusTimer = null;\n }\n // static _soundMeter: SoundMeter;\n ZegoCloudRTCCore.getInstance = function (token) {\n var config = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.getConfig)(token);\n if (!ZegoCloudRTCCore._instance && config) {\n ZegoCloudRTCCore._instance = new ZegoCloudRTCCore();\n ZegoCloudRTCCore._instance._expressConfig = config;\n // ZegoCloudRTCCore._soundMeter = new SoundMeter();\n ZegoCloudRTCCore._zg = new zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1__.ZegoExpressEngine(ZegoCloudRTCCore._instance._expressConfig.appID, \"wss://webliveroom\" +\n ZegoCloudRTCCore._instance._expressConfig.appID +\n \"-api.zegocloud.com/ws\");\n ZegoCloudRTCCore._instance.zum = new _tools_UserListManager__WEBPACK_IMPORTED_MODULE_3__.ZegoCloudUserListManager(ZegoCloudRTCCore._zg);\n }\n return ZegoCloudRTCCore._instance;\n };\n ZegoCloudRTCCore.prototype.checkWebRTC = function () {\n return __awaiter(this, void 0, void 0, function () {\n var result;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, ZegoCloudRTCCore._zg.checkSystemRequirements(\"webRTC\")];\n case 1:\n result = _a.sent();\n return [2 /*return*/, !!result.result];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.setConfig = function (config) {\n var _a, _b, _c, _d;\n if (config.scenario &&\n config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming) {\n if (config.showNonVideoUser === true) {\n console.error(\"【ZEGOCLOUD】 showNonVideoUser have be false scenario.mode is LiveStreaming!!\");\n return false;\n }\n config.showNonVideoUser = false;\n config.showOnlyAudioUser = true;\n if (config.scenario.config &&\n config.scenario.config.role === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host) {\n if (config.turnOnMicrophoneWhenJoining === false &&\n config.turnOnCameraWhenJoining === false &&\n config.showMyCameraToggleButton === false &&\n config.showAudioVideoSettingsButton === false) {\n console.error(\"【ZEGOCLOUD】 Host could turn on at least one of the camera and the microphone!!\");\n return false;\n }\n }\n else if (config.scenario.config &&\n config.scenario.config.role === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience) {\n if (config.turnOnMicrophoneWhenJoining === true ||\n config.turnOnCameraWhenJoining === true ||\n config.showMyCameraToggleButton === true ||\n config.showMyMicrophoneToggleButton === true ||\n config.showAudioVideoSettingsButton === true ||\n config.showScreenSharingButton === true ||\n config.useFrontFacingCamera === true ||\n (!!config.layout && config.layout !== \"Grid\")) {\n console.error(\"【ZEGOCLOUD】 Audience cannot configure camera and microphone related params\");\n return false;\n }\n }\n if (!config.maxUsers) {\n config.maxUsers = 5000;\n }\n if (config.scenario.config &&\n config.scenario.config.role === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience) {\n config.turnOnMicrophoneWhenJoining = false;\n config.turnOnCameraWhenJoining = false;\n config.showMyCameraToggleButton = false;\n config.showMyMicrophoneToggleButton = false;\n config.showAudioVideoSettingsButton = false;\n config.showScreenSharingButton = false;\n config.useFrontFacingCamera = false;\n config.useFrontFacingCamera = false;\n config.showUserList = false;\n config.showPinButton = false;\n config.showLayoutButton = false;\n config.layout = \"Grid\";\n config.lowerLeftNotification = {\n showTextChat: false,\n showUserJoinAndLeave: false,\n };\n }\n }\n if (config.scenario &&\n config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall) {\n if (!config.maxUsers) {\n config.maxUsers = 2;\n }\n config.showLayoutButton = false;\n config.showPinButton = false;\n }\n if (config.scenario && config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.GroupCall) {\n if (!config.maxUsers) {\n config.maxUsers = 50;\n }\n }\n config.facingMode &&\n (config.useFrontFacingCamera = config.facingMode === \"user\");\n config.joinRoomCallback && (config.onJoinRoom = config.joinRoomCallback);\n config.leaveRoomCallback && (config.onLeaveRoom = config.leaveRoomCallback);\n if (config.userUpdateCallback) {\n config.onUserJoin = function (users) {\n config.userUpdateCallback && config.userUpdateCallback(\"ADD\", users);\n };\n config.onUserLeave = function (users) {\n config.userUpdateCallback && config.userUpdateCallback(\"DELETE\", users);\n };\n }\n if (config.preJoinViewConfig && config.preJoinViewConfig.invitationLink) {\n config.sharedLinks = [\n {\n name: \"Share the link\",\n url: config.preJoinViewConfig.invitationLink,\n },\n ];\n }\n config.preJoinViewConfig &&\n (config.preJoinViewConfig = __assign(__assign({}, this._config.preJoinViewConfig), config.preJoinViewConfig));\n config.scenario &&\n config.scenario.config &&\n (config.scenario.config = __assign(__assign({}, (_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.config), config.scenario.config));\n this._config = __assign(__assign({}, this._config), config);\n this.zum.scenario =\n ((_b = this._config.scenario) === null || _b === void 0 ? void 0 : _b.mode) || _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall;\n this.zum.role = ((_d = (_c = this._config.scenario) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.role) || _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host;\n this.zum.showOnlyAudioUser = !!this._config.showOnlyAudioUser;\n this.zum.setShowNonVideo(!!this._config.showNonVideoUser);\n return true;\n };\n ZegoCloudRTCCore.prototype.setPin = function (userID, pined) {\n this.zum.setPin(userID, pined);\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n };\n ZegoCloudRTCCore.prototype.setMaxScreenNum = function (num) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.zum.setMaxScreenNum(num)];\n case 1:\n _a.sent();\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n return [2 /*return*/];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.setSidebarLayOut = function (enable) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.zum.setSidebarLayOut(enable)];\n case 1:\n _a.sent();\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n return [2 /*return*/];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.setShowNonVideo = function (enable) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.zum.setShowNonVideo(enable)];\n case 1:\n _a.sent();\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n return [2 /*return*/];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.setCurrentPage = function (page) {\n this._currentPage = page;\n };\n ZegoCloudRTCCore.prototype.getCameras = function () {\n return ZegoCloudRTCCore._zg.getCameras();\n };\n ZegoCloudRTCCore.prototype.useVideoDevice = function (localStream, deviceID) {\n return ZegoCloudRTCCore._zg.useVideoDevice(localStream, deviceID);\n };\n ZegoCloudRTCCore.prototype.getMicrophones = function () {\n return ZegoCloudRTCCore._zg.getMicrophones();\n };\n ZegoCloudRTCCore.prototype.getSpeakers = function () {\n return ZegoCloudRTCCore._zg.getSpeakers();\n };\n ZegoCloudRTCCore.prototype.setVolume = function (media, volume) {\n media.volume = volume;\n };\n ZegoCloudRTCCore.prototype.createStream = function (source) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.createStream(source)];\n });\n });\n };\n ZegoCloudRTCCore.prototype.setVideoConfig = function (media, constraints) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.setVideoConfig(media, constraints)];\n });\n });\n };\n ZegoCloudRTCCore.prototype.stopPublishingStream = function (streamID) {\n return ZegoCloudRTCCore._zg.stopPublishingStream(streamID);\n };\n ZegoCloudRTCCore.prototype.destroyStream = function (stream) {\n ZegoCloudRTCCore._zg.destroyStream(stream);\n };\n ZegoCloudRTCCore.prototype.useCameraDevice = function (media, deviceID) {\n return ZegoCloudRTCCore._zg.useVideoDevice(media, deviceID);\n };\n ZegoCloudRTCCore.prototype.useMicrophoneDevice = function (media, deviceID) {\n return ZegoCloudRTCCore._zg.useAudioDevice(media, deviceID);\n };\n ZegoCloudRTCCore.prototype.useSpeakerDevice = function (media, deviceID) {\n return __awaiter(this, void 0, void 0, function () {\n var res, error_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!media.srcObject) {\n return [2 /*return*/, Promise.resolve({ errorCode: -1 })];\n }\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n return [4 /*yield*/, ZegoCloudRTCCore._zg.useAudioOutputDevice(media, deviceID)];\n case 2:\n res = _a.sent();\n return [2 /*return*/, { errorCode: res ? 0 : -1 }];\n case 3:\n error_1 = _a.sent();\n return [2 /*return*/, { errorCode: -1 }];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.enableVideoCaptureDevice = function (localStream, enable) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.enableVideoCaptureDevice(localStream, enable)];\n });\n });\n };\n ZegoCloudRTCCore.prototype.mutePublishStreamVideo = function (localStream, enable) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.mutePublishStreamVideo(localStream, enable)];\n });\n });\n };\n ZegoCloudRTCCore.prototype.mutePublishStreamAudio = function (localStream, enable) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.mutePublishStreamAudio(localStream, enable)];\n });\n });\n };\n ZegoCloudRTCCore.prototype.muteMicrophone = function (enable) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.muteMicrophone(enable)];\n });\n });\n };\n Object.defineProperty(ZegoCloudRTCCore.prototype, \"roomExtraInfo\", {\n get: function () {\n return this._roomExtraInfo;\n },\n set: function (value) {\n var _this = this;\n if (this._currentPage === \"Room\") {\n this._roomExtraInfo = value;\n this.zum.setLiveStates(this._roomExtraInfo.live_status.v);\n console.error(\"【ZEGOCLOUD】roomExtraInfo choui\", value, this.onRoomLiveStateUpdateCallBack);\n this.onRoomLiveStateUpdateCallBack &&\n this.onRoomLiveStateUpdateCallBack(this._roomExtraInfo.live_status.v);\n }\n else if (this._currentPage === \"BrowserCheckPage\" ||\n this._currentPage === \"RejoinRoom\") {\n setTimeout(function () {\n _this.roomExtraInfo = value;\n }, 1000);\n }\n },\n enumerable: false,\n configurable: true\n });\n ZegoCloudRTCCore.prototype.setLive = function (status) {\n var _a, _b, _c, _d;\n return __awaiter(this, void 0, void 0, function () {\n var setRoomExtraInfo, res;\n return __generator(this, function (_e) {\n switch (_e.label) {\n case 0:\n setRoomExtraInfo = __assign(__assign({}, this._roomExtraInfo), {\n live_status: {\n v: status === \"live\" ? 1 : 0,\n u: ZegoCloudRTCCore._instance._expressConfig.userID,\n r: ((_b = (_a = ZegoCloudRTCCore._instance._config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.role) ===\n _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host\n ? 1\n : ((_d = (_c = ZegoCloudRTCCore._instance._config.scenario) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.role) ===\n _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience\n ? 2\n : 3,\n },\n });\n return [4 /*yield*/, ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo))];\n case 1:\n res = _e.sent();\n res.errorCode === 0 && (this.roomExtraInfo = setRoomExtraInfo);\n return [2 /*return*/, res.errorCode === 0];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.enterRoom = function () {\n return __awaiter(this, void 0, void 0, function () {\n var resp;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n // 已经登陆过不再登录\n if (this.status.loginRsp)\n return [2 /*return*/, Promise.resolve(0)];\n ZegoCloudRTCCore._zg.off(\"roomExtraInfoUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomStreamUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteCameraStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteMicStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"playerStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomUserUpdate\");\n ZegoCloudRTCCore._zg.off(\"IMRecvBroadcastMessage\");\n ZegoCloudRTCCore._zg.off(\"roomStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publisherStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publishQualityUpdate\");\n ZegoCloudRTCCore._zg.off(\"soundLevelUpdate\");\n ZegoCloudRTCCore._zg.on(\"roomStreamUpdate\", function (roomID, updateType, streamList, extendedData) { return __awaiter(_this, void 0, void 0, function () {\n var willDelete_1;\n return __generator(this, function (_a) {\n console.warn(\"【ZEGOCLOUD】roomStreamUpdate\", updateType, streamList);\n if (updateType === \"ADD\") {\n this.waitingHandlerStreams.add = __spreadArray(__spreadArray([], this.waitingHandlerStreams.add, true), streamList, true);\n this.waitingHandlerStreams.delete =\n this.waitingHandlerStreams.delete.filter(function (stream) {\n if (streamList.some(function (add_stream) { return add_stream.streamID === stream.streamID; })) {\n return false;\n }\n else {\n return true;\n }\n });\n }\n else {\n willDelete_1 = [];\n // 新增流中,删除下线的流\n this.waitingHandlerStreams.add =\n this.waitingHandlerStreams.add.filter(function (stream) {\n if (streamList.some(function (delete_stream) {\n if (delete_stream.streamID === stream.streamID) {\n willDelete_1.push(delete_stream.streamID);\n return true;\n }\n else {\n return false;\n }\n })) {\n return false;\n }\n else {\n return true;\n }\n });\n // 删除流中,去除上次要新增的\n streamList = streamList.filter(function (s) {\n if (willDelete_1.some(function (wd) { return wd == s.streamID; })) {\n return false;\n }\n else {\n return true;\n }\n });\n this.waitingHandlerStreams.delete = __spreadArray(__spreadArray([], this.waitingHandlerStreams.delete, true), streamList, true);\n }\n return [2 /*return*/];\n });\n }); });\n ZegoCloudRTCCore._zg.on(\"roomExtraInfoUpdate\", function (roomID, roomExtraInfoList) {\n roomExtraInfoList.forEach(function (info) {\n if (info.key === _this.extraInfoKey) {\n console.error(\"【ZEGOCLOUD】choui\", info.value);\n _this.roomExtraInfo = JSON.parse(info.value);\n }\n });\n });\n ZegoCloudRTCCore._zg.on(\"remoteCameraStatusUpdate\", function (streamID, status) {\n if (_this.remoteStreamMap[streamID]) {\n _this.remoteStreamMap[streamID].cameraStatus = status;\n _this.onRemoteMediaUpdateCallBack &&\n _this.onRemoteMediaUpdateCallBack(\"UPDATE\", [\n _this.remoteStreamMap[streamID],\n ]);\n }\n });\n ZegoCloudRTCCore._zg.on(\"remoteMicStatusUpdate\", function (streamID, status) {\n if (_this.remoteStreamMap[streamID]) {\n _this.remoteStreamMap[streamID].micStatus = status;\n _this.onRemoteMediaUpdateCallBack &&\n _this.onRemoteMediaUpdateCallBack(\"UPDATE\", [\n _this.remoteStreamMap[streamID],\n ]);\n }\n });\n ZegoCloudRTCCore._zg.on(\"playerStateUpdate\", function (streamInfo) {\n console.warn(\"【ZEGOCLOUD】\", streamInfo);\n if (_this.remoteStreamMap[streamInfo.streamID]) {\n _this.remoteStreamMap[streamInfo.streamID].state = streamInfo.state;\n _this.onRemoteMediaUpdateCallBack &&\n _this.onRemoteMediaUpdateCallBack(\"UPDATE\", [\n _this.remoteStreamMap[streamInfo.streamID],\n ]);\n }\n });\n ZegoCloudRTCCore._zg.on(\"roomUserUpdate\", function (roomID, updateType, userList) {\n console.warn(\"【ZEGOCLOUD】roomUserUpdate\", updateType, userList);\n _this.onRemoteUserUpdateCallBack &&\n _this.onRemoteUserUpdateCallBack(roomID, updateType, userList);\n setTimeout(function () {\n if (updateType === \"ADD\") {\n _this._config.onUserJoin && _this._config.onUserJoin(userList);\n }\n else {\n _this._config.onUserLeave && _this._config.onUserLeave(userList);\n }\n }, 0);\n });\n ZegoCloudRTCCore._zg.on(\"IMRecvBroadcastMessage\", function (roomID, chatData) {\n _this.onRoomMessageUpdateCallBack &&\n _this.onRoomMessageUpdateCallBack(roomID, chatData);\n });\n ZegoCloudRTCCore._zg.on(\"publisherStateUpdate\", function (streamInfo) {\n var state = \"DISCONNECTED\";\n if (streamInfo.state === \"PUBLISHING\") {\n state = \"CONNECTED\";\n }\n else if (streamInfo.state === \"NO_PUBLISH\") {\n state = \"DISCONNECTED\";\n }\n else if (streamInfo.state === \"PUBLISH_REQUESTING\") {\n state = \"CONNECTING\";\n }\n _this.onNetworkStatusCallBack &&\n _this.onNetworkStatusCallBack(ZegoCloudRTCCore._instance._expressConfig.roomID, \"STREAM\", state);\n });\n ZegoCloudRTCCore._zg.on(\"playQualityUpdate\", function (streamID, stats) {\n _this.onNetworkStatusQualityCallBack &&\n _this.onNetworkStatusQualityCallBack(streamID, Math.max(stats.video.videoQuality, stats.audio.audioQuality));\n });\n ZegoCloudRTCCore._zg.on(\"publishQualityUpdate\", function (streamID, stats) {\n _this.onNetworkStatusQualityCallBack &&\n _this.onNetworkStatusQualityCallBack(streamID, Math.max(stats.video.videoQuality, stats.audio.audioQuality));\n });\n ZegoCloudRTCCore._zg.on(\"soundLevelUpdate\", function (soundLevelList) {\n _this.onSoundLevelUpdateCallBack &&\n _this.onSoundLevelUpdateCallBack(soundLevelList);\n });\n ZegoCloudRTCCore._zg.on(\"screenSharingEnded\", function (stream) {\n _this.onScreenSharingEndedCallBack &&\n _this.onScreenSharingEndedCallBack(stream);\n });\n return [4 /*yield*/, new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n ZegoCloudRTCCore._zg.on(\"roomStateUpdate\", function (roomID, state, errorCode, extendedData) {\n _this.onNetworkStatusCallBack &&\n _this.onNetworkStatusCallBack(roomID, \"ROOM\", state);\n if (state === \"CONNECTED\" || state === \"DISCONNECTED\") {\n _this.status.loginRsp = errorCode === 0;\n res(errorCode);\n }\n });\n return [4 /*yield*/, ZegoCloudRTCCore._zg.loginRoom(ZegoCloudRTCCore._instance._expressConfig.roomID, ZegoCloudRTCCore._instance._expressConfig.token, {\n userID: ZegoCloudRTCCore._instance._expressConfig.userID,\n userName: ZegoCloudRTCCore._instance._expressConfig.userName,\n }, {\n userUpdate: true,\n maxMemberCount: ZegoCloudRTCCore._instance._config.maxUsers,\n })];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n }); })];\n case 1:\n resp = _a.sent();\n ZegoCloudRTCCore._zg.setSoundLevelDelegate(true, 300);\n this.streamUpdateTimer(this.waitingHandlerStreams);\n return [2 /*return*/, resp];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.streamUpdateTimer = function (_waitingHandlerStreams) {\n return __awaiter(this, void 0, void 0, function () {\n var _streamList, i, streamInfo, stream, error_2, i, streamInfo;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(this._currentPage === \"Room\")) return [3 /*break*/, 13];\n _streamList = [];\n if (!(_waitingHandlerStreams.add.length > 0)) return [3 /*break*/, 7];\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < _waitingHandlerStreams.add.length)) return [3 /*break*/, 6];\n streamInfo = _waitingHandlerStreams.add[i];\n _a.label = 2;\n case 2:\n _a.trys.push([2, 4, , 5]);\n return [4 /*yield*/, this.zum.startPullStream(streamInfo.user.userID, streamInfo.streamID)];\n case 3:\n stream = _a.sent();\n this.remoteStreamMap[streamInfo.streamID] = {\n fromUser: streamInfo.user,\n media: stream,\n micStatus: stream && stream.getAudioTracks().length > 0 ? \"OPEN\" : \"MUTE\",\n cameraStatus: stream && stream.getVideoTracks().length > 0 ? \"OPEN\" : \"MUTE\",\n state: \"PLAYING\",\n streamID: streamInfo.streamID,\n };\n _streamList.push(this.remoteStreamMap[streamInfo.streamID]);\n return [3 /*break*/, 5];\n case 4:\n error_2 = _a.sent();\n console.warn(\"【ZEGOCLOUD】:startPlayingStream error\", error_2);\n return [3 /*break*/, 5];\n case 5:\n i++;\n return [3 /*break*/, 1];\n case 6:\n this.onRemoteMediaUpdateCallBack &&\n _streamList.length > 0 &&\n this.onRemoteMediaUpdateCallBack(\"ADD\", _streamList);\n _a.label = 7;\n case 7:\n if (!(_waitingHandlerStreams.delete.length > 0)) return [3 /*break*/, 12];\n _streamList = [];\n i = 0;\n _a.label = 8;\n case 8:\n if (!(i < _waitingHandlerStreams.delete.length)) return [3 /*break*/, 11];\n streamInfo = _waitingHandlerStreams.delete[i];\n if (!this.remoteStreamMap[streamInfo.streamID]) {\n debugger;\n }\n this.remoteStreamMap[streamInfo.streamID] &&\n _streamList.push(this.remoteStreamMap[streamInfo.streamID]);\n return [4 /*yield*/, this.zum.stopPullStream(streamInfo.user.userID, streamInfo.streamID)];\n case 9:\n _a.sent();\n delete this.remoteStreamMap[streamInfo.streamID];\n _a.label = 10;\n case 10:\n i++;\n return [3 /*break*/, 8];\n case 11:\n this.onRemoteMediaUpdateCallBack &&\n _streamList.length > 0 &&\n this.onRemoteMediaUpdateCallBack(\"DELETE\", _streamList);\n _a.label = 12;\n case 12:\n setTimeout(function () {\n var nextWaitingHandlerStreams = {\n add: __spreadArray([], _this.waitingHandlerStreams.add, true),\n delete: __spreadArray([], _this.waitingHandlerStreams.delete, true),\n };\n _this.waitingHandlerStreams = {\n add: [],\n delete: [],\n };\n _this.streamUpdateTimer(nextWaitingHandlerStreams);\n }, 700);\n return [3 /*break*/, 14];\n case 13:\n if (this._currentPage === \"BrowserCheckPage\" ||\n this._currentPage === \"RejoinRoom\") {\n setTimeout(function () {\n _this.streamUpdateTimer(_waitingHandlerStreams);\n }, 1000);\n }\n _a.label = 14;\n case 14: return [2 /*return*/];\n }\n });\n });\n };\n ZegoCloudRTCCore.prototype.publishLocalStream = function (media, streamType) {\n if (!media)\n return false;\n var streamID = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.generateStreamID)(this._expressConfig.userID, this._expressConfig.roomID, streamType);\n var res = ZegoCloudRTCCore._zg.startPublishingStream(streamID, media);\n return res && streamID;\n };\n ZegoCloudRTCCore.prototype.replaceTrack = function (media, mediaStreamTrack) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n return [2 /*return*/, ZegoCloudRTCCore._zg.replaceTrack(media, mediaStreamTrack)];\n });\n });\n };\n ZegoCloudRTCCore.prototype.subscribeUserList = function (callback) {\n this.subscribeUserListCallBack = callback;\n };\n ZegoCloudRTCCore.prototype.subscribeScreenStream = function (callback) {\n this.subscribeScreenStreamCallBack = callback;\n };\n ZegoCloudRTCCore.prototype.onRemoteMediaUpdate = function (func) {\n var _this = this;\n this.onRemoteMediaUpdateCallBack = function (updateType, streamList) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n func(updateType, streamList);\n return [4 /*yield*/, this.zum.mainStreamUpdate(updateType, streamList)];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.zum.screenStreamUpdate(updateType, streamList)];\n case 2:\n _a.sent();\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n this.subscribeScreenStreamCallBack &&\n this.subscribeScreenStreamCallBack(__spreadArray([], this.zum.remoteScreenStreamList, true));\n return [2 /*return*/];\n }\n });\n }); };\n };\n ZegoCloudRTCCore.prototype.onNetworkStatusQuality = function (func) {\n this.onNetworkStatusQualityCallBack = func;\n };\n ZegoCloudRTCCore.prototype.onRemoteUserUpdate = function (func) {\n var _this = this;\n this.onRemoteUserUpdateCallBack = function (roomID, updateType, users) { return __awaiter(_this, void 0, void 0, function () {\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(this._currentPage === \"BrowserCheckPage\" ||\n this._currentPage === \"RejoinRoom\")) return [3 /*break*/, 1];\n setTimeout(function () {\n _this.onRemoteUserUpdateCallBack(roomID, updateType, users);\n }, 1000);\n return [3 /*break*/, 3];\n case 1:\n if (!(this._currentPage === \"Room\")) return [3 /*break*/, 3];\n func(roomID, updateType, users);\n return [4 /*yield*/, this.zum.userUpdate(roomID, updateType, users)];\n case 2:\n _a.sent();\n setTimeout(function () {\n console.warn(\"【ZEGOCLOUD】roomUserUpdate\", __spreadArray([], _this.zum.remoteUserList, true), __spreadArray([], _this.zum.remoteUserList, true).length);\n _this.subscribeUserListCallBack &&\n _this.subscribeUserListCallBack(__spreadArray([], _this.zum.remoteUserList, true));\n }, 0);\n _a.label = 3;\n case 3: return [2 /*return*/];\n }\n });\n }); };\n };\n ZegoCloudRTCCore.prototype.onSoundLevelUpdate = function (func) {\n this.onSoundLevelUpdateCallBack = func;\n };\n ZegoCloudRTCCore.prototype.onRoomLiveStateUpdate = function (func) {\n this.onRoomLiveStateUpdateCallBack = func;\n };\n ZegoCloudRTCCore.prototype.sendRoomMessage = function (message) {\n return ZegoCloudRTCCore._zg.sendBroadcastMessage(ZegoCloudRTCCore._instance._expressConfig.roomID, message);\n };\n ZegoCloudRTCCore.prototype.onRoomMessageUpdate = function (func) {\n this.onRoomMessageUpdateCallBack = func;\n };\n ZegoCloudRTCCore.prototype.onScreenSharingEnded = function (func) {\n this.onScreenSharingEndedCallBack = func;\n };\n ZegoCloudRTCCore.prototype.onNetworkStatus = function (func) {\n var _this = this;\n this.onNetworkStatusCallBack = function (roomID, type, status) {\n if (status === \"CONNECTING\") {\n !_this.NetworkStatusTimer &&\n (_this.NetworkStatusTimer = setTimeout(function () {\n func(roomID, type, \"DISCONNECTED\");\n }, 60000));\n }\n else {\n if (_this.NetworkStatusTimer) {\n clearTimeout(_this.NetworkStatusTimer);\n _this.NetworkStatusTimer = null;\n }\n }\n func(roomID, type, status);\n };\n };\n ZegoCloudRTCCore.prototype.leaveRoom = function () {\n var _this = this;\n if (!this.status.loginRsp)\n return;\n ZegoCloudRTCCore._zg.off(\"roomExtraInfoUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomStreamUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteCameraStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteMicStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"playerStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomUserUpdate\");\n ZegoCloudRTCCore._zg.off(\"IMRecvBroadcastMessage\");\n ZegoCloudRTCCore._zg.off(\"roomStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publisherStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publishQualityUpdate\");\n ZegoCloudRTCCore._zg.off(\"soundLevelUpdate\");\n ZegoCloudRTCCore._zg.off(\"screenSharingEnded\");\n ZegoCloudRTCCore._zg.setSoundLevelDelegate(false);\n this.onNetworkStatusCallBack = function () { };\n this.onRemoteMediaUpdateCallBack = function (updateType, streamList) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.zum.mainStreamUpdate(updateType, streamList)];\n case 1:\n _a.sent();\n return [4 /*yield*/, this.zum.screenStreamUpdate(updateType, streamList)];\n case 2:\n _a.sent();\n this.subscribeUserListCallBack &&\n this.subscribeUserListCallBack(__spreadArray([], this.zum.remoteUserList, true));\n this.subscribeScreenStreamCallBack &&\n this.subscribeScreenStreamCallBack(__spreadArray([], this.zum.remoteScreenStreamList, true));\n return [2 /*return*/];\n }\n });\n }); };\n this.onRemoteUserUpdateCallBack = function () { };\n this.onRoomMessageUpdateCallBack = function () { };\n this.onRoomLiveStateUpdateCallBack = function () { };\n this.subscribeUserListCallBack = function () { };\n this.zum.reset();\n for (var key in this.remoteStreamMap) {\n ZegoCloudRTCCore._zg.stopPlayingStream(key);\n }\n this.remoteStreamMap = {};\n ZegoCloudRTCCore._zg.logoutRoom();\n this.status.loginRsp = false;\n };\n return ZegoCloudRTCCore;\n}());\n\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/modules/index.ts?");
|
|
1570
1570
|
|
|
1571
1571
|
/***/ }),
|
|
1572
1572
|
|
package/index.html
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8" />
|
|
6
|
-
|
|
7
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
8
|
-
<meta name="theme-color" content="#000000" />
|
|
9
|
-
<meta name="description" content="Web site created using create-react-app" />
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<!--
|
|
13
|
-
Notice the use of %PUBLIC_URL% in the tags above.
|
|
14
|
-
It will be replaced with the URL of the `public` folder during the build.
|
|
15
|
-
Only files inside the `public` folder can be referenced from the HTML.
|
|
16
|
-
|
|
17
|
-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
18
|
-
work correctly both with client-side routing and a non-root public URL.
|
|
19
|
-
Learn how to configure a non-root public URL by running `npm run build`.
|
|
20
|
-
-->
|
|
21
|
-
<title>ZEGOCLOUD video call Demo(prebuilt)</title>
|
|
22
|
-
<style>
|
|
23
|
-
#root {
|
|
24
|
-
width: 100vw;
|
|
25
|
-
height: 100vh;
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@font-face {
|
|
30
|
-
font-family: Emoji;
|
|
31
|
-
src: local("Apple Color Emoji"), local("Segoe UI Emoji"),
|
|
32
|
-
local("Segoe UI Symbol"), local("Noto Color Emoji");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
body {
|
|
36
|
-
margin: 0;
|
|
37
|
-
font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system,
|
|
38
|
-
"Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans",
|
|
39
|
-
"Droid Sans", "Helvetica Neue", sans-serif, Arial, Emoji;
|
|
40
|
-
-webkit-font-smoothing: antialiased;
|
|
41
|
-
-moz-osx-font-smoothing: grayscale;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
code {
|
|
45
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
|
46
|
-
monospace;
|
|
47
|
-
}
|
|
48
|
-
</style>
|
|
49
|
-
</head>
|
|
50
|
-
|
|
51
|
-
<body>
|
|
52
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
53
|
-
<div id="root"></div>
|
|
54
|
-
<!--
|
|
55
|
-
This HTML file is a template.
|
|
56
|
-
If you open it directly in the browser, you will see an empty page.
|
|
57
|
-
|
|
58
|
-
You can add webfonts, meta tags, or analytics to this file.
|
|
59
|
-
The build step will place the bundled scripts into the <body> tag.
|
|
60
|
-
|
|
61
|
-
To begin the development, run `npm start` or `yarn start`.
|
|
62
|
-
To create a production bundle, use `npm run build` or `yarn build`.
|
|
63
|
-
-->
|
|
64
|
-
</body>
|
|
65
|
-
<script src="./zego-uikit-prebuilt.js"></script>
|
|
66
|
-
<script>
|
|
67
|
-
// get token
|
|
68
|
-
function generateToken(tokenServerUrl, userID, roomID, userName) {
|
|
69
|
-
// Obtain the token interface provided by the App Server
|
|
70
|
-
return fetch(
|
|
71
|
-
`${tokenServerUrl}/access_token?userID=${userID}&userName=${userName}&roomID=${roomID}&expired_ts=7200`, {
|
|
72
|
-
method: 'GET',
|
|
73
|
-
}
|
|
74
|
-
).then((res) => res.json());
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function randomID(len) {
|
|
78
|
-
let result = '';
|
|
79
|
-
if (result) return result;
|
|
80
|
-
var chars = '12345qwertyuiopasdfgh67890jklmnbvcxzMNBVCZXASDQWERTYHGFUIOLKJP',
|
|
81
|
-
maxPos = chars.length,
|
|
82
|
-
i;
|
|
83
|
-
len = len || 5;
|
|
84
|
-
for (i = 0; i < len; i++) {
|
|
85
|
-
result += chars.charAt(Math.floor(Math.random() * maxPos));
|
|
86
|
-
}
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function getUrlParams(url) {
|
|
91
|
-
let urlStr = url.split('?')[1];
|
|
92
|
-
const urlSearchParams = new URLSearchParams(urlStr);
|
|
93
|
-
const result = Object.fromEntries(urlSearchParams.entries());
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async function init() {
|
|
98
|
-
const roomID = getUrlParams(window.location.href)['roomID'] || randomID(5);
|
|
99
|
-
const {
|
|
100
|
-
token
|
|
101
|
-
} = await generateToken(
|
|
102
|
-
'https://choui-prebuilt.herokuapp.com',
|
|
103
|
-
randomID(5),
|
|
104
|
-
roomID,
|
|
105
|
-
randomID(5)
|
|
106
|
-
);
|
|
107
|
-
const zp = ZegoUIKitPrebuilt.create(token);
|
|
108
|
-
zp.joinRoom({
|
|
109
|
-
container: document.querySelector("#root"),
|
|
110
|
-
preJoinViewConfig: {
|
|
111
|
-
invitationLink: window.location.origin + window.location.pathname + '?roomID=' + roomID,
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
window.onload = init;
|
|
117
|
-
</script>
|
|
118
|
-
|
|
119
|
-
</html>
|