zbzt-live-sdk 0.0.2
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/.babelrc +8 -0
- package/.editorconfig +13 -0
- package/.eslintrc.js +29 -0
- package/CHANGELOG.md +16 -0
- package/README.md +32 -0
- package/dist/zbzt-live-sdk.cjs.js +51 -0
- package/dist/zbzt-live-sdk.esm.js +51 -0
- package/dist/zbzt-live-sdk.umd.js +52 -0
- package/dist/zbzt-live-sdk.umd.js.map +1 -0
- package/example/app.js +133 -0
- package/example/bootstrap-3.4.1/css/bootstrap-theme.css +587 -0
- package/example/bootstrap-3.4.1/css/bootstrap-theme.css.map +1 -0
- package/example/bootstrap-3.4.1/css/bootstrap-theme.min.css +6 -0
- package/example/bootstrap-3.4.1/css/bootstrap-theme.min.css.map +1 -0
- package/example/bootstrap-3.4.1/css/bootstrap.css +6834 -0
- package/example/bootstrap-3.4.1/css/bootstrap.css.map +1 -0
- package/example/bootstrap-3.4.1/css/bootstrap.min.css +6 -0
- package/example/bootstrap-3.4.1/css/bootstrap.min.css.map +1 -0
- package/example/bootstrap-3.4.1/fonts/glyphicons-halflings-regular.eot +0 -0
- package/example/bootstrap-3.4.1/fonts/glyphicons-halflings-regular.svg +288 -0
- package/example/bootstrap-3.4.1/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/example/bootstrap-3.4.1/fonts/glyphicons-halflings-regular.woff +0 -0
- package/example/bootstrap-3.4.1/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/example/bootstrap-3.4.1/js/bootstrap.js +2580 -0
- package/example/bootstrap-3.4.1/js/bootstrap.min.js +6 -0
- package/example/bootstrap-3.4.1/js/npm.js +13 -0
- package/example/css/style.css +18 -0
- package/example/index.html +59 -0
- package/example/js/jquery-3.7.1.min.js +2 -0
- package/example/js/utils.js +25 -0
- package/example/js/variables.js +14 -0
- package/example/js/zegoApi.js +229 -0
- package/example/style.css +25 -0
- package/example/test.html +100 -0
- package/package.json +60 -0
- package/release.js +33 -0
- package/rollup-plugin-http.js +49 -0
- package/src/channel/getSendMsgParams.js +66 -0
- package/src/channel/index.js +135 -0
- package/src/channel/pomelo/index.js +182 -0
- package/src/channel/pomelo/latestQueue.js +150 -0
- package/src/channel/pomelo/polemo.js +730 -0
- package/src/channel/pomelo/util.js +54 -0
- package/src/channel/sdk-cb.js +73 -0
- package/src/channel/stream-msg.js +97 -0
- package/src/channel/zbzt/index.js +74 -0
- package/src/channel/zbzt/interactWithChannel.js +4 -0
- package/src/channel/zbzt/interactWithChannelControl.js +1568 -0
- package/src/channel/zbzt/interactWithChannelEntry.js +318 -0
- package/src/config/config.js +226 -0
- package/src/default/base.js +71 -0
- package/src/default/extend.js +36 -0
- package/src/default/index.js +10 -0
- package/src/live/base.js +43 -0
- package/src/live/call-method.js +10 -0
- package/src/live/extend.js +53 -0
- package/src/live/index.js +10 -0
- package/src/network/api.js +56 -0
- package/src/network/commonFetch.js +66 -0
- package/src/network/dataReport.js +448 -0
- package/src/notice.js +418 -0
- package/src/tool/base.js +74 -0
- package/src/tool/call-method.js +10 -0
- package/src/tool/extend.js +42 -0
- package/src/tool/index.js +10 -0
- package/src/util/bridge.js +87 -0
- package/src/util/bridge1.js +46 -0
- package/src/util/dict.js +51 -0
- package/src/util/sessionStorage.js +29 -0
- package/src/util/sha256.js +483 -0
- package/src/util/util.js +329 -0
- package/src/zbzt-av-sdk/default-sdk.js +192 -0
- package/src/zbzt-av-sdk/device.js +86 -0
- package/src/zbzt-av-sdk/rtc-sdk.js +2854 -0
- package/src/zbzt-av-sdk/talrtc-sdk.js +2620 -0
- package/src/zbzt-av-sdk/trtc-sdk.js +1802 -0
- package/src/zbzt-av-sdk/zbzt-av-sdk.js +2121 -0
- package/src/zbzt-av-sdk/zego-sdk.js +1718 -0
- package/src/zbzt-av-sdk/zego-sdk.js.bak +3133 -0
- package/src/zbzt-live-sdk.js +1484 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
const $container = $('body form').eq(1);
|
|
2
|
+
// 获取摄像头列表
|
|
3
|
+
$container.append('<button id="getCameraDeviceList" type="button" class="btn btn-primary">获取摄像头列表</button>');
|
|
4
|
+
$('#getCameraDeviceList').click(async () => {
|
|
5
|
+
const result = await zbztsdk.getCameraDeviceList();
|
|
6
|
+
console.warn('[获取摄像头列表]', result);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// 获取麦克风列表
|
|
10
|
+
$container.append('<button id="getMicrophoneDeviceList" type="button" class="btn btn-primary">获取麦克风列表</button>');
|
|
11
|
+
$('#getMicrophoneDeviceList').click(async () => {
|
|
12
|
+
const result = await zbztsdk.getMicrophoneDeviceList();
|
|
13
|
+
console.warn('[获取麦克风列表]', result);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// 获取扬声器列表
|
|
17
|
+
$container.append('<button id="getSpeakerDeviceList" type="button" class="btn btn-primary">获取扬声器列表</button>');
|
|
18
|
+
$('#getSpeakerDeviceList').click(async () => {
|
|
19
|
+
const result = await zbztsdk.getSpeakerDeviceList();
|
|
20
|
+
console.warn('[获取扬声器列表]', result);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// 登出房间
|
|
24
|
+
$container.append('<button id="leaveRoom" type="button" class="btn btn-primary">登出房间</button>');
|
|
25
|
+
$('#leaveRoom').click(async () => {
|
|
26
|
+
const result = await zbztsdk.leaveRoom();
|
|
27
|
+
console.warn('[登出房间]');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// 获取SDK版本
|
|
31
|
+
$container.append('<button id="getSDKVersion" type="button" class="btn btn-primary">获取SDK版本</button>');
|
|
32
|
+
$('#getSDKVersion').click(async () => {
|
|
33
|
+
const result = await zbztsdk.getSDKVersion();
|
|
34
|
+
console.warn('[获取SDK版本]', result);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// 预览镜像
|
|
38
|
+
$container.append('<button id="setPushViewMirror" type="button" class="btn btn-primary">预览镜像</button>');
|
|
39
|
+
let pushViewMirror = false;
|
|
40
|
+
$('#setPushViewMirror').click(async () => {
|
|
41
|
+
pushViewMirror = !pushViewMirror;
|
|
42
|
+
const result = await zbztsdk.setPushViewMirror(pushViewMirror);
|
|
43
|
+
console.warn('[预览镜像]', pushViewMirror);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// 修改推流码率
|
|
47
|
+
$container.append('<button id="setBitRate" type="button" class="btn btn-primary">修改推流码率</button>');
|
|
48
|
+
let pushVideoBitrate = 800000;
|
|
49
|
+
$('#setBitRate').click(async () => {
|
|
50
|
+
pushVideoBitrate = pushVideoBitrate == 800000 ? 200000 : 800000;
|
|
51
|
+
const result = await zbztsdk.setBitRate(pushVideoBitrate);
|
|
52
|
+
console.warn('[修改推流码率]', result, pushVideoBitrate);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// 修改采集/编码分辨率
|
|
56
|
+
$container.append('<button id="setCameraParams" type="button" class="btn btn-primary">修改分辨率(WEB只有目标分辨率)</button>');
|
|
57
|
+
let resolution = { width: 640, height: 480 };
|
|
58
|
+
$('#setCameraParams').click(async () => {
|
|
59
|
+
resolution = resolution.width == 640 ? { width: 300, height: 200 } : { width: 640, height: 480 };
|
|
60
|
+
const result = await zbztsdk.setCameraParams(resolution);
|
|
61
|
+
console.warn('[修改采集/编码分辨率]', result, resolution);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// 推流静音
|
|
65
|
+
$container.append('<button id="setMicrophoneMute" type="button" class="btn btn-primary">推流静音</button>');
|
|
66
|
+
let micMute = false;
|
|
67
|
+
$('#setMicrophoneMute').click(async () => {
|
|
68
|
+
micMute = !micMute;
|
|
69
|
+
const result = await zbztsdk.setMicrophoneMute(micMute);
|
|
70
|
+
console.warn('[推流静音]', result, micMute);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// 设置推流音量
|
|
74
|
+
$container.append('<button id="setMicrophoneVolume" type="button" class="btn btn-primary">设置推流音量</button>');
|
|
75
|
+
let micVolume = 100;
|
|
76
|
+
$('#setMicrophoneVolume').click(async () => {
|
|
77
|
+
micVolume = micVolume == 100 ? 50 : 100;
|
|
78
|
+
const result = await zbztsdk.setMicrophoneVolume(micVolume);
|
|
79
|
+
console.warn('[设置推流音量]', result, micVolume);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// 获取推流音量
|
|
83
|
+
$container.append('<button id="getMicrophoneVolume" type="button" class="btn btn-primary">获取推流音量</button>');
|
|
84
|
+
$('#getMicrophoneVolume').click(async () => {
|
|
85
|
+
const result = await zbztsdk.getMicrophoneVolume();
|
|
86
|
+
console.warn('[获取推流音量]', result);
|
|
87
|
+
});
|
|
88
|
+
// 初始化设备列表
|
|
89
|
+
$container.append('<button id="getDeviceList" type="button" class="btn btn-primary">初始化设备列表</button>');
|
|
90
|
+
$('#getDeviceList').click(async () => {
|
|
91
|
+
const result = initDeviceList();
|
|
92
|
+
console.warn('[初始化设备列表]', { cameraSelect, micphoneSelect, speakerSelect });
|
|
93
|
+
});
|
|
94
|
+
// 开关摄像头
|
|
95
|
+
$container.append('<button id="enableCamera" type="button" class="btn btn-primary">开关摄像头</button>');
|
|
96
|
+
let openCamera = true;
|
|
97
|
+
$('#enableCamera').click(async () => {
|
|
98
|
+
openCamera = !openCamera;
|
|
99
|
+
const result = zbztsdk.openOrCloseCamera(openCamera);
|
|
100
|
+
console.warn('[开关摄像头]');
|
|
101
|
+
});
|
|
102
|
+
// 开关麦克风
|
|
103
|
+
$container.append('<button id="enableMic" type="button" class="btn btn-primary">开关麦克风</button>');
|
|
104
|
+
let openMic = true;
|
|
105
|
+
$('#enableMic').click(async () => {
|
|
106
|
+
openMic = !openMic;
|
|
107
|
+
const result = zbztsdk.openOrCloseMicrophone(openMic);
|
|
108
|
+
console.warn('[开关麦克风]');
|
|
109
|
+
});
|
|
110
|
+
// 切换摄像头
|
|
111
|
+
$container.append('<button id="switchCamera" type="button" class="btn btn-primary">切换摄像头</button>');
|
|
112
|
+
let cameraIndex = 0;
|
|
113
|
+
$('#switchCamera').click(async () => {
|
|
114
|
+
cameraIndex = cameraIndex === 0 ? 1 : 0;
|
|
115
|
+
const device = (await zbztsdk.getCameraDeviceList())[cameraIndex];
|
|
116
|
+
if (device) {
|
|
117
|
+
const result = zbztsdk.setCameraDevice(device.deviceId);
|
|
118
|
+
}
|
|
119
|
+
console.warn('[切换摄像头]', device);
|
|
120
|
+
});
|
|
121
|
+
// 切换麦克风
|
|
122
|
+
$container.append('<button id="switchmic" type="button" class="btn btn-primary">切换麦克风</button>');
|
|
123
|
+
let micIndex = 0;
|
|
124
|
+
$('#switchmic').click(async () => {
|
|
125
|
+
micIndex = micIndex === 0 ? 1 : 0;
|
|
126
|
+
const device = (await zbztsdk.getMicrophoneDeviceList())[micIndex];
|
|
127
|
+
if (device) {
|
|
128
|
+
const result = zbztsdk.setMicrophoneDevice(device.deviceId);
|
|
129
|
+
}
|
|
130
|
+
console.warn('[切换麦克风]', device);
|
|
131
|
+
});
|
|
132
|
+
// 切换扬声器
|
|
133
|
+
$container.append('<button id="switchSpeaker" type="button" class="btn btn-primary">切换扬声器</button>');
|
|
134
|
+
let speakerIndex = 0;
|
|
135
|
+
$('#switchSpeaker').click(async () => {
|
|
136
|
+
speakerIndex = speakerIndex === 0 ? 1 : 0;
|
|
137
|
+
const device = (await zbztsdk.getSpeakerDeviceList())[speakerIndex];
|
|
138
|
+
if (device) {
|
|
139
|
+
const result = zbztsdk.setSpeakerDevice(device.deviceId);
|
|
140
|
+
}
|
|
141
|
+
console.warn('[切换扬声器]', device);
|
|
142
|
+
});
|
|
143
|
+
// 获取当前扬声器
|
|
144
|
+
$container.append('<button id="getSpeaker" type="button" class="btn btn-primary">获取当前扬声器</button>');
|
|
145
|
+
$('#getSpeaker').click(async () => {
|
|
146
|
+
const result = await zbztsdk.getSpeakerDevice();
|
|
147
|
+
console.warn('[获取当前扬声器]', result);
|
|
148
|
+
});
|
|
149
|
+
// 开关扬声器
|
|
150
|
+
$container.append('<button id="switchSpeakerMute" type="button" class="btn btn-primary">开关扬声器</button>');
|
|
151
|
+
let speakerMute = false;
|
|
152
|
+
$('#switchSpeakerMute').click(async () => {
|
|
153
|
+
speakerMute = !speakerMute;
|
|
154
|
+
const result = await zbztsdk.setSpeakerMute(speakerMute);
|
|
155
|
+
console.warn('[开关扬声器]');
|
|
156
|
+
});
|
|
157
|
+
// 拉流镜像
|
|
158
|
+
$container.append('<button id="setPlayViewMirror" type="button" class="btn btn-primary">拉流镜像</button>');
|
|
159
|
+
let playViewMirror = false;
|
|
160
|
+
$('#setPlayViewMirror').click(async () => {
|
|
161
|
+
playViewMirror = !playViewMirror;
|
|
162
|
+
const result = await zbztsdk.setPlayViewMirror(playViewMirror);
|
|
163
|
+
console.warn('[拉流镜像]', playViewMirror);
|
|
164
|
+
});
|
|
165
|
+
// 停所有的拉流
|
|
166
|
+
$container.append('<button id="stopAllPlay" type="button" class="btn btn-primary">停所有的拉流</button>');
|
|
167
|
+
$('#stopAllPlay').click(async () => {
|
|
168
|
+
const result = await zbztsdk.stopAllPullFlow();
|
|
169
|
+
$('#remote-player .remote-player').remove();
|
|
170
|
+
console.warn('[停所有的拉流]');
|
|
171
|
+
});
|
|
172
|
+
// 停推
|
|
173
|
+
$container.append('<button id="stopPush" type="button" class="btn btn-primary">停推(不结束预览)</button>');
|
|
174
|
+
$('#stopPush').click(async () => {
|
|
175
|
+
const result = await zbztsdk.stopPushFlow(-1, '3001_90002024_1576184_1');
|
|
176
|
+
console.warn('[停推]');
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// 跨房间拉流(42020009)
|
|
180
|
+
$container.append('<br><button id="pull3005_42020009_AAAAA_1" type="button" class="btn btn-primary">跨房间拉流(3005_42020009_AAAAA_1)</button>');
|
|
181
|
+
$('#pull3005_42020009_AAAAA_1').click(async () => {
|
|
182
|
+
// const result = await zbztsdk.getMicrophoneVolume();
|
|
183
|
+
handlePullFlow({ streamId: '3005_42020009_AAAAA_1', userId: 'AAAAA' });
|
|
184
|
+
console.warn('[跨房间拉流(3005_42020009_AAAAA_1)]');
|
|
185
|
+
});
|
|
186
|
+
// 停拉(42020009)
|
|
187
|
+
$container.append('<button id="stop3005_42020009_AAAAA_1" type="button" class="btn btn-primary">停拉(3005_42020009_AAAAA_1)</button>');
|
|
188
|
+
$('#stop3005_42020009_AAAAA_1').click(async () => {
|
|
189
|
+
// const result = await zbztsdk.getMicrophoneVolume();
|
|
190
|
+
handleStopPullFlow({ streamId: '3005_42020009_AAAAA_1', userId: 'AAAAA', roomId: '42020009' });
|
|
191
|
+
console.warn('[停拉(3005_42020009_AAAAA_1)]');
|
|
192
|
+
});
|
|
193
|
+
// 3005_42020009_AAAAA_1流的禁音开关
|
|
194
|
+
$container.append('<button id="mute3005_42020009_AAAAA_1" type="button" class="btn btn-primary">禁音开关(3005_42020009_AAAAA_1)</button>');
|
|
195
|
+
let mute3005_42020009_AAAAA_1 = true;
|
|
196
|
+
$('#mute3005_42020009_AAAAA_1').click(async () => {
|
|
197
|
+
mute3005_42020009_AAAAA_1 = !mute3005_42020009_AAAAA_1;
|
|
198
|
+
const result = await zbztsdk.setAudioMute('AAAAA', mute3005_42020009_AAAAA_1, null, '3005_42020009_AAAAA_1');
|
|
199
|
+
console.warn('[禁音开关(3005_42020009_AAAAA_1)]', mute3005_42020009_AAAAA_1);
|
|
200
|
+
});
|
|
201
|
+
// 拉纯音频(3005_42020009_AAAAA_1)
|
|
202
|
+
$container.append('<button id="pullAudioStream" type="button" class="btn btn-primary">拉纯音频(3005_42020009_AAAAA_1)</button>');
|
|
203
|
+
$('#pullAudioStream').click(async () => {
|
|
204
|
+
const result = await zbztsdk.pullAudioFlow(15, false, '3005_42020009_AAAAA_1');
|
|
205
|
+
console.warn('[拉纯音频]', '3005_42020009_AAAAA_1');
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// 跨房间拉流(420200091)
|
|
209
|
+
$container.append('<br><button id="pullxxx_420200091_BBBBB_1" type="button" class="btn btn-primary">跨房间拉流(xxx_420200091_BBBBB_1)</button>');
|
|
210
|
+
$('#pullxxx_420200091_BBBBB_1').click(async () => {
|
|
211
|
+
// const result = await zbztsdk.getMicrophoneVolume();
|
|
212
|
+
handlePullFlow({ streamId: 'xxx_420200091_BBBBB_1', userId: 'BBBBB' });
|
|
213
|
+
console.warn('[跨房间拉流(pullxxx_420200091_BBBBB_1)]');
|
|
214
|
+
});
|
|
215
|
+
// 停拉(420200091)
|
|
216
|
+
$container.append('<button id="stopxxx_420200091_BBBBB_1" type="button" class="btn btn-primary">停拉(xxx_420200091_BBBBB_1)</button>');
|
|
217
|
+
$('#stopxxx_420200091_BBBBB_1').click(async () => {
|
|
218
|
+
// const result = await zbztsdk.getMicrophoneVolume();
|
|
219
|
+
handleStopPullFlow({ streamId: 'xxx_420200091_BBBBB_1', userId: 'BBBBB', roomId: '420200091' });
|
|
220
|
+
console.warn('[停拉(xxx_420200091_BBBBB_1)]');
|
|
221
|
+
});
|
|
222
|
+
// 开启屏幕共享
|
|
223
|
+
$container.append('<br><button id="startScreen" type="button" class="btn btn-primary">开启屏幕共享</button>');
|
|
224
|
+
$('#local-player').append('<div id="screen-player"></div>');
|
|
225
|
+
$('#startScreen').click(async () => {
|
|
226
|
+
const result = await zbztsdk.startPushFlow('2023_90002024_189504_106971200_1', 1);
|
|
227
|
+
console.warn('[开启屏幕共享]');
|
|
228
|
+
});
|
|
229
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
* { padding: 0; margin: 0; box-sizing: border-box; }
|
|
2
|
+
html, body, .container {
|
|
3
|
+
height: 100%;
|
|
4
|
+
width: 100%;
|
|
5
|
+
}
|
|
6
|
+
header {
|
|
7
|
+
height: 64px;
|
|
8
|
+
background-color: #ccc;
|
|
9
|
+
position: relative;
|
|
10
|
+
z-index: 1;
|
|
11
|
+
}
|
|
12
|
+
main {
|
|
13
|
+
height: 100%;
|
|
14
|
+
margin-top: -64px;
|
|
15
|
+
padding-top: 64px;
|
|
16
|
+
background-color: #eee;
|
|
17
|
+
display: flex;
|
|
18
|
+
}
|
|
19
|
+
.tool {
|
|
20
|
+
width: 30px;
|
|
21
|
+
background-color: #ddd;
|
|
22
|
+
}
|
|
23
|
+
.rtc {
|
|
24
|
+
width: 360px;
|
|
25
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>1v1 测试</title>
|
|
5
|
+
<script type="text/javascript" src="https://zego-public.oss-cn-shanghai.aliyuncs.com/ZegoExpressWebRTC/ZegoExpressWebRTC-3.1.0.js"></script>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<h1>测试房间</h1>
|
|
9
|
+
<label>
|
|
10
|
+
<input type="radio" name="paras">roomID:42020009; userID:AAAAA; streamID:3005_42020009_AAAAA_1
|
|
11
|
+
</label>
|
|
12
|
+
<br>
|
|
13
|
+
<label>
|
|
14
|
+
<input type="radio" name="paras">roomID:420200091; userID:BBBBB; streamID:xxx_420200091_BBBBB_1
|
|
15
|
+
</label>
|
|
16
|
+
<br>
|
|
17
|
+
<label>
|
|
18
|
+
<input type="radio" name="paras">roomID:90002024; userID:CCCCC; streamID:3005_90002024_CCCCC_1
|
|
19
|
+
</label>
|
|
20
|
+
<br>
|
|
21
|
+
<input placeholder="Enter userId">
|
|
22
|
+
<input placeholder="Enter roomId">
|
|
23
|
+
<input placeholder="Enter streamId">
|
|
24
|
+
<button>登录</button>
|
|
25
|
+
<button>推流</button>
|
|
26
|
+
<div style="display: flex">
|
|
27
|
+
<video id="localView" autoplay muted playsinline controls></video>
|
|
28
|
+
</div>
|
|
29
|
+
</body>
|
|
30
|
+
<script>
|
|
31
|
+
let userID;
|
|
32
|
+
let userName;
|
|
33
|
+
let roomID;
|
|
34
|
+
let streamID;
|
|
35
|
+
//初始化信息
|
|
36
|
+
let appID = 1739272706;
|
|
37
|
+
let server = 'wss://webliveroom-test.zego.im/ws';
|
|
38
|
+
// 初始化实例
|
|
39
|
+
const zg = new ZegoExpressEngine(appID, server);
|
|
40
|
+
zg.setDebugVerbose(false);
|
|
41
|
+
zg.setLogConfig({ logLevel: 'disable' });
|
|
42
|
+
|
|
43
|
+
const params = [
|
|
44
|
+
{ roomID: 42020009, userID: 'AAAAA', streamID: '3005_42020009_AAAAA_1' },
|
|
45
|
+
{ roomID: 420200091, userID: 'BBBBB', streamID: 'xxx_420200091_BBBBB_1' },
|
|
46
|
+
{ roomID: 90002024, userID: 'CCCCC', streamID: '3005_90002024_CCCCC_1' }
|
|
47
|
+
];
|
|
48
|
+
document.querySelectorAll('label').forEach((label, index)=> {
|
|
49
|
+
(function(index) {
|
|
50
|
+
label.addEventListener('click', ()=> {
|
|
51
|
+
document.querySelectorAll('input')[3].value = params[index].userID;
|
|
52
|
+
document.querySelectorAll('input')[4].value = params[index].roomID;
|
|
53
|
+
document.querySelectorAll('input')[5].value = params[index].streamID;
|
|
54
|
+
})
|
|
55
|
+
})(index);
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
// 登录
|
|
59
|
+
document.querySelector('button').addEventListener('click', ()=> {
|
|
60
|
+
userID = document.querySelectorAll('input')[3].value;
|
|
61
|
+
roomID = document.querySelectorAll('input')[4].value;
|
|
62
|
+
streamID = document.querySelectorAll('input')[5].value;
|
|
63
|
+
userName = userID;
|
|
64
|
+
// 加入房间
|
|
65
|
+
fetch(`https://wsliveroom-alpha.zego.im:8282/token?app_id=${appID}&id_name=${userID}`)
|
|
66
|
+
.then(rsp=> rsp.text())
|
|
67
|
+
.then(token=> {
|
|
68
|
+
console.warn('[登录]', roomID, userID, userName );
|
|
69
|
+
zg.loginRoom(roomID, token, { userID, userName }, { userUpdate: true })
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// 推流
|
|
74
|
+
document.querySelectorAll('button')[1].addEventListener('click', async ()=> {
|
|
75
|
+
const localStream = await zg.createStream({ camera:{ audio: true, video: true, } });
|
|
76
|
+
const localVideo = document.getElementById('localView');
|
|
77
|
+
localVideo.srcObject = localStream;
|
|
78
|
+
zg.startPublishingStream(streamID, localStream);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
zg.on('roomStreamUpdate', async (roomID, updateType, streamList, extendedData) => {
|
|
82
|
+
console.error(roomID, updateType, streamList, extendedData);
|
|
83
|
+
if (updateType == 'ADD') {
|
|
84
|
+
const streamID = streamList[0].streamID;
|
|
85
|
+
const remoteStream = await zg.startPlayingStream(streamID);
|
|
86
|
+
const $video = document.createElement('video');
|
|
87
|
+
$video.id = streamID;
|
|
88
|
+
$video.setAttribute('autoplay', 'true');
|
|
89
|
+
$video.setAttribute('muted', 'true');
|
|
90
|
+
$video.setAttribute('playsinline', 'true');
|
|
91
|
+
$video.setAttribute('controls', 'true');
|
|
92
|
+
document.querySelector('div').appendChild($video);
|
|
93
|
+
$video.srcObject = remoteStream;
|
|
94
|
+
} else if (updateType == 'DELETE') {
|
|
95
|
+
const streamID = streamList[0].streamID;
|
|
96
|
+
zg.stopPlayingStream(streamID)
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
</script>
|
|
100
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zbzt-live-sdk",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"main": "dist/zbzt-live-sdk.cjs.js",
|
|
5
|
+
"module": "dist/zbzt-live-sdk.esm.js",
|
|
6
|
+
"browsers": "dist/zbzt-live-sdk.umd.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"release": "node ./release.js",
|
|
9
|
+
"start": "cross-env NODE_ENV=development npx rollup -w -c",
|
|
10
|
+
"build": "cross-env NODE_ENV=development npx rollup -c",
|
|
11
|
+
"build:dev": "cross-env NODE_ENV=development npx rollup -c",
|
|
12
|
+
"build:pro": "cross-env NODE_ENV=production npx rollup -c",
|
|
13
|
+
"prebuild": "cross-env NODE_ENV=development npm run release",
|
|
14
|
+
"lint:js": "# 检查 js \n eslint ./src/**/*.js && eslint ./src/*.js"
|
|
15
|
+
},
|
|
16
|
+
"husky": {
|
|
17
|
+
"hooks": {
|
|
18
|
+
"pre-commit": "npm run lint:js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"author": "lanlonggang@tal.com",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@babel/core": "^7.2.2",
|
|
25
|
+
"@babel/plugin-transform-runtime": "^7.23.7",
|
|
26
|
+
"@babel/preset-env": "^7.2.3",
|
|
27
|
+
"@babel/runtime": "^7.23.8",
|
|
28
|
+
"cross-env": "^5.2.0",
|
|
29
|
+
"express": "^4.18.2",
|
|
30
|
+
"http-proxy-middleware": "^2.0.6",
|
|
31
|
+
"rollup": "^1.1.0",
|
|
32
|
+
"rollup-plugin-babel": "^4.0.3",
|
|
33
|
+
"rollup-plugin-commonjs": "^9.1.6",
|
|
34
|
+
"rollup-plugin-eslint": "^5.0.0",
|
|
35
|
+
"rollup-plugin-json": "^3.0.0",
|
|
36
|
+
"rollup-plugin-node-resolve": "^3.4.0",
|
|
37
|
+
"rollup-plugin-replace": "^2.0.0",
|
|
38
|
+
"rollup-plugin-uglify-es": "0.0.1",
|
|
39
|
+
"rollup-pluginutils": "^2.3.1",
|
|
40
|
+
"standard-version": "^4.4.0"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"axios": "^0.18.1",
|
|
44
|
+
"debug": "^3.1.0",
|
|
45
|
+
"md5": "^2.2.1",
|
|
46
|
+
"omnirtc-web": "^0.0.19",
|
|
47
|
+
"pako": "^1.0.11",
|
|
48
|
+
"pomelo-protobuf": "^0.4.0",
|
|
49
|
+
"pomelo-protocol": "^0.1.6",
|
|
50
|
+
"qs": "^6.9.4",
|
|
51
|
+
"socket.io": "^2.1.1",
|
|
52
|
+
"zego-express-engine-webrtc": "^3.1.3"
|
|
53
|
+
},
|
|
54
|
+
"description": "This is a live SDK.",
|
|
55
|
+
"keywords": [
|
|
56
|
+
"zbzt-live-sdk",
|
|
57
|
+
"tal",
|
|
58
|
+
"online-class"
|
|
59
|
+
]
|
|
60
|
+
}
|
package/release.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const standardVersion = require('standard-version');
|
|
2
|
+
// const pkg = require('./package.json');
|
|
3
|
+
|
|
4
|
+
// function getDate() {
|
|
5
|
+
// const date = new Date().toLocaleDateString('zh-CN');
|
|
6
|
+
// return date.split('/').map((item) => item.padStart(2, '0')).join('');
|
|
7
|
+
// }
|
|
8
|
+
|
|
9
|
+
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
10
|
+
// const date = getDate();
|
|
11
|
+
// let version = `1.0.49-beta-${date}`;
|
|
12
|
+
// if (version === pkg.version) {
|
|
13
|
+
// version = `${version}-1`;
|
|
14
|
+
// } else if (version.length < pkg.version.length) {
|
|
15
|
+
// const last = pkg.version.split('-').pop();
|
|
16
|
+
// version = `${version}-${Number(last) + 1}`;
|
|
17
|
+
// }
|
|
18
|
+
|
|
19
|
+
standardVersion({
|
|
20
|
+
noVerify: true,
|
|
21
|
+
infile: 'CHANGELOG.md',
|
|
22
|
+
silent: true,
|
|
23
|
+
skip: {
|
|
24
|
+
changelog: isDevelopment,
|
|
25
|
+
tag: isDevelopment,
|
|
26
|
+
commit: isDevelopment,
|
|
27
|
+
}
|
|
28
|
+
}).then(async () => {
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}).catch(async (err) => {
|
|
31
|
+
console.error(err);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const http = require('http');
|
|
2
|
+
const express = require('express');
|
|
3
|
+
const { createProxyMiddleware, fixRequestBody } = require('http-proxy-middleware');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
|
|
7
|
+
app.use('/saas', createProxyMiddleware({
|
|
8
|
+
target: 'https://test-api-cloud-control-zhibo.saasp.vdyoo.com',
|
|
9
|
+
changeOrigin: true,
|
|
10
|
+
pathRewrite: {
|
|
11
|
+
'^/saas': '/',
|
|
12
|
+
},
|
|
13
|
+
}));
|
|
14
|
+
app.use('/peiyou', createProxyMiddleware({
|
|
15
|
+
target: 'https://test-api-cloud-control-zhibo.speiyou.com',
|
|
16
|
+
changeOrigin: true,
|
|
17
|
+
pathRewrite: {
|
|
18
|
+
'^/peiyou': '/',
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
app.use(express.static('dist'));
|
|
23
|
+
app.use(express.static('example'));
|
|
24
|
+
|
|
25
|
+
const server = http.createServer(app);
|
|
26
|
+
server.on('error', err => {
|
|
27
|
+
if (err.code === 'EADDRINUSE') {
|
|
28
|
+
server.listen(++err.port);
|
|
29
|
+
} else {
|
|
30
|
+
console.log(err.code);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
server.on('listening', () => {
|
|
35
|
+
console.log(
|
|
36
|
+
`\r\nListening: http://localhost:${server.address().port}\r\n`
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
module.exports = function serverPlugin(options) {
|
|
41
|
+
return {
|
|
42
|
+
name: 'server', // this name will show up in warnings and errors
|
|
43
|
+
buildStart: function(rollupOptions) {
|
|
44
|
+
if (this.watcher && !server.listening) {
|
|
45
|
+
server.listen(options.port);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import util from '../util/util';
|
|
2
|
+
|
|
3
|
+
function getParams(baseInfo) {
|
|
4
|
+
const {userId, target, userName, role, roomId, institutionId} = baseInfo;
|
|
5
|
+
return {
|
|
6
|
+
appId: institutionId,
|
|
7
|
+
actorId: userId,
|
|
8
|
+
actorName: userName,
|
|
9
|
+
actorType: role,
|
|
10
|
+
roomId,
|
|
11
|
+
streamUrl: util.getStreamId(baseInfo),
|
|
12
|
+
streamService: window.zbztAVSDK_init_sdk_type,
|
|
13
|
+
version: 1,
|
|
14
|
+
target
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
sendJoinAck(baseInfo) {
|
|
20
|
+
const data = {
|
|
21
|
+
'api':'joinAck',
|
|
22
|
+
...getParams(baseInfo)
|
|
23
|
+
};
|
|
24
|
+
//无target代表广播消息,target代表有定向发送消息
|
|
25
|
+
return data;
|
|
26
|
+
},
|
|
27
|
+
sendAddStream(baseInfo) {
|
|
28
|
+
const data = {
|
|
29
|
+
'api': 'addStream',
|
|
30
|
+
'playMode': '2', //播放流的模式,1全屏播放,2在其视频区正常播放3.只播放音频不播放视频
|
|
31
|
+
...getParams(baseInfo)
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
},
|
|
35
|
+
sendUpdateStreamDeviceStatus(baseInfo) {
|
|
36
|
+
const {deviceType, deviceStatus} = baseInfo;
|
|
37
|
+
const data ={
|
|
38
|
+
'api':'updateStreamDeviceStatus',
|
|
39
|
+
'streamType': deviceType, // string 流设备对应类型:1:视频 2:音频 3:音视频 4:截屏 5:截屏+视频 6:截屏+音频
|
|
40
|
+
'status': deviceStatus, // string 流设备状态 1开启 2关闭 3未找到
|
|
41
|
+
...getParams(baseInfo)
|
|
42
|
+
};
|
|
43
|
+
return data;
|
|
44
|
+
},
|
|
45
|
+
sendRemoveStream(baseInfo) {
|
|
46
|
+
let data = {
|
|
47
|
+
'api':'removeStream',
|
|
48
|
+
...getParams(baseInfo)
|
|
49
|
+
};
|
|
50
|
+
return data;
|
|
51
|
+
},
|
|
52
|
+
sendJoin(baseInfo) {
|
|
53
|
+
const data = {
|
|
54
|
+
'api':'join',
|
|
55
|
+
...getParams(baseInfo)
|
|
56
|
+
};
|
|
57
|
+
return data;
|
|
58
|
+
},
|
|
59
|
+
sendLeave(baseInfo) {
|
|
60
|
+
const data = {
|
|
61
|
+
'api':'leave',
|
|
62
|
+
...getParams(baseInfo)
|
|
63
|
+
};
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
};
|