瀏覽代碼

docs(api.md): Comply with our coding style.

j8
Hristo Terezov 6 年之前
父節點
當前提交
f12317dc59
共有 1 個檔案被更改,包括 125 行新增116 行删除
  1. 125
    116
      doc/api.md

+ 125
- 116
doc/api.md 查看文件

@@ -7,7 +7,7 @@ You can use the Jitsi Meet API to embed Jitsi Meet in to your application. You a
7 7
 To embed Jitsi Meet in your application you need to add the Jitsi Meet API library:
8 8
 
9 9
 ```javascript
10
-<script src="https://meet.jit.si/external_api.js"></script>
10
+<script src='https://meet.jit.si/external_api.js'></script>
11 11
 ```
12 12
 ## API
13 13
 
@@ -16,7 +16,7 @@ To embed Jitsi Meet in your application you need to add the Jitsi Meet API libra
16 16
 The next step for embedding Jitsi Meet is to create the Jitsi Meet API object.
17 17
 Its constructor gets a number of options:
18 18
 
19
-* **domain**: domain used to build the conference URL, "meet.jit.si" for
19
+* **domain**: domain used to build the conference URL, 'meet.jit.si' for
20 20
   example.
21 21
 * **options**: object with properties - the optional arguments:
22 22
     * **roomName**: (optional) name of the room to join.
@@ -34,49 +34,54 @@ Its constructor gets a number of options:
34 34
 Example:
35 35
 
36 36
 ```javascript
37
-var domain = "meet.jit.si";
38
-var options = {
39
-    roomName: "JitsiMeetAPIExample",
37
+const domain = 'meet.jit.si';
38
+const options = {
39
+    roomName: 'JitsiMeetAPIExample',
40 40
     width: 700,
41 41
     height: 700,
42 42
     parentNode: document.querySelector('#meet')
43
-}
44
-var api = new JitsiMeetExternalAPI(domain, options);
43
+};
44
+const api = new JitsiMeetExternalAPI(domain, options);
45 45
 ```
46 46
 
47 47
 You can set the initial media devices for the call:
48 48
 
49 49
 ```javascript
50
-var domain = "meet.jit.si";
51
-var options = {
50
+const domain = 'meet.jit.si';
51
+const options = {
52 52
     ...
53 53
     devices: {
54
-        'audioInput': '<deviceLabel>',
55
-        'audioOutput': '<deviceLabel>',
56
-        'videoInput': '<deviceLabel>'
57
-    }
58
-}
59
-var api = new JitsiMeetExternalAPI(domain, options);
54
+        audioInput: '<deviceLabel>',
55
+        audioOutput: '<deviceLabel>',
56
+        videoInput: '<deviceLabel>'
57
+    },
58
+    ...
59
+};
60
+const api = new JitsiMeetExternalAPI(domain, options);
60 61
 ```
61 62
 
62 63
 You can overwrite options set in [config.js] and [interface_config.js].
63 64
 For example, to enable the filmstrip-only interface mode, you can use:
64 65
 
65 66
 ```javascript
66
-var options = {
67
-    interfaceConfigOverwrite: {filmStripOnly: true}
67
+const options = {
68
+    ...
69
+    interfaceConfigOverwrite: { filmStripOnly: true },
70
+    ...
68 71
 };
69
-var api = new JitsiMeetExternalAPI(domain, options);
72
+const api = new JitsiMeetExternalAPI(domain, options);
70 73
 ```
71 74
 
72 75
 You can also pass a jwt token to Jitsi Meet:
73 76
 
74 77
  ```javascript
75
-var options = {
76
-    jwt: "<jwt_token>",
77
-    noSsl: false
78
+const options = {
79
+    ...
80
+    jwt: '<jwt_token>',
81
+    noSsl: false,
82
+    ...
78 83
 };
79
-var api = new JitsiMeetExternalAPI(domain, options);
84
+const api = new JitsiMeetExternalAPI(domain, options);
80 85
  ```
81 86
 
82 87
 ### Controlling the embedded Jitsi Meet Conference
@@ -85,25 +90,25 @@ Device management `JitsiMeetExternalAPI` methods:
85 90
 * **getAvailableDevices** - Retrieve a list of available devices.
86 91
 
87 92
 ```javascript
88
-api.getAvailableDevices().then(function(devices) {
93
+api.getAvailableDevices().then(devices => {
89 94
     // devices = {
90
-    //     'audioInput': [{
91
-    //         deviceId: "ID"
92
-    //         groupId: "grpID"
93
-    //         kind: "audioinput"
94
-    //         label: "Label"
95
+    //     audioInput: [{
96
+    //         deviceId: 'ID'
97
+    //         groupId: 'grpID'
98
+    //         kind: 'audioinput'
99
+    //         label: 'label'
95 100
     //     },....],
96
-    //     'audioOutput': [{
97
-    //         deviceId: "ID"
98
-    //         groupId: "grpID"
99
-    //         kind: "audioOutput"
100
-    //         label: "Label"
101
+    //     audioOutput: [{
102
+    //         deviceId: 'ID'
103
+    //         groupId: 'grpID'
104
+    //         kind: 'audioOutput'
105
+    //         label: 'label'
101 106
     //     },....],
102
-    //     'videoInput': [{
103
-    //         deviceId: "ID"
104
-    //         groupId: "grpID"
105
-    //         kind: "videoInput"
106
-    //         label: "Label"
107
+    //     videoInput: [{
108
+    //         deviceId: 'ID'
109
+    //         groupId: 'grpID'
110
+    //         kind: 'videoInput'
111
+    //         label: 'label'
107 112
     //     },....]
108 113
     // }
109 114
     ...
@@ -112,25 +117,25 @@ api.getAvailableDevices().then(function(devices) {
112 117
 * **getCurrentDevices** - Retrieve a list with the devices that are currently selected.
113 118
 
114 119
 ```javascript
115
-api.getCurrentDevices().then(function(devices) {
120
+api.getCurrentDevices().then(devices => {
116 121
     // devices = {
117
-    //     'audioInput': {
118
-    //         deviceId: "ID"
119
-    //         groupId: "grpID"
120
-    //         kind: "videoInput"
121
-    //         label: "Label"
122
+    //     audioInput: {
123
+    //         deviceId: 'ID'
124
+    //         groupId: 'grpID'
125
+    //         kind: 'videoInput'
126
+    //         label: 'label'
122 127
     //     },
123
-    //     'audioOutput': {
124
-    //         deviceId: "ID"
125
-    //         groupId: "grpID"
126
-    //         kind: "videoInput"
127
-    //         label: "Label"
128
+    //     audioOutput: {
129
+    //         deviceId: 'ID'
130
+    //         groupId: 'grpID'
131
+    //         kind: 'videoInput'
132
+    //         label: 'label'
128 133
     //     },
129
-    //     'videoInput': {
130
-    //         deviceId: "ID"
131
-    //         groupId: "grpID"
132
-    //         kind: "videoInput"
133
-    //         label: "Label"
134
+    //     videoInput: {
135
+    //         deviceId: 'ID'
136
+    //         groupId: 'grpID'
137
+    //         kind: 'videoInput'
138
+    //         label: 'label'
134 139
     //     }
135 140
     // }
136 141
     ...
@@ -140,21 +145,21 @@ api.getCurrentDevices().then(function(devices) {
140 145
 
141 146
 ```javascript
142 147
 // The accepted deviceType values are - 'output', 'input' or undefined.
143
-api.isDeviceChangeAvailable(deviceType).then(function(isDeviceChangeAvailable) {
148
+api.isDeviceChangeAvailable(deviceType).then(isDeviceChangeAvailable => {
144 149
     ...
145 150
 });
146 151
 ```
147 152
 * **isDeviceListAvailable** - Resolves with true if the device list is available and with false if not.
148 153
 
149 154
 ```javascript
150
-api.isDeviceListAvailable().then(function(isDeviceListAvailable) {
155
+api.isDeviceListAvailable().then(isDeviceListAvailable => {
151 156
     ...
152 157
 });
153 158
 ```
154 159
 * **isMultipleAudioInputSupported** - Resolves with true if multiple audio input is supported and with false if not.
155 160
 
156 161
 ```javascript
157
-api.isMultipleAudioInputSupported().then(function(isMultipleAudioInputSupported) {
162
+api.isMultipleAudioInputSupported().then(isMultipleAudioInputSupported => {
158 163
     ...
159 164
 });
160 165
 ```
@@ -177,7 +182,7 @@ api.setVideoInputDevice(deviceLabel, deviceId);
177 182
 You can control the embedded Jitsi Meet conference using the `JitsiMeetExternalAPI` object by using `executeCommand`:
178 183
 
179 184
 ```javascript
180
-api.executeCommand(command, ...arguments)
185
+api.executeCommand(command, ...arguments);
181 186
 ```
182 187
 
183 188
 The `command` parameter is String object with the name of the command. The following commands are currently supported:
@@ -194,57 +199,60 @@ api.executeCommand('subject', 'New Conference Subject');
194 199
 
195 200
 * **toggleAudio** - Mutes / unmutes the audio for the local participant. No arguments are required.
196 201
 ```javascript
197
-api.executeCommand('toggleAudio')
202
+api.executeCommand('toggleAudio');
198 203
 ```
199 204
 
200 205
 * **toggleVideo** - Mutes / unmutes the video for the local participant. No arguments are required.
201 206
 ```javascript
202
-api.executeCommand('toggleVideo')
207
+api.executeCommand('toggleVideo');
203 208
 ```
204 209
 
205 210
 * **toggleFilmStrip** - Hides / shows the filmstrip. No arguments are required.
206 211
 ```javascript
207
-api.executeCommand('toggleFilmStrip')
212
+api.executeCommand('toggleFilmStrip');
208 213
 ```
209 214
 
210 215
 * **toggleChat** - Hides / shows the chat. No arguments are required.
211 216
 ```javascript
212
-api.executeCommand('toggleChat')
217
+api.executeCommand('toggleChat');
213 218
 ```
214 219
 
215 220
 * **toggleShareScreen** - Starts / stops screen sharing. No arguments are required.
216 221
 ```javascript
217
-api.executeCommand('toggleShareScreen')
222
+api.executeCommand('toggleShareScreen');
218 223
 ```
219 224
 
220 225
 * **hangup** - Hangups the call. No arguments are required.
221 226
 ```javascript
222
-api.executeCommand('hangup')
227
+api.executeCommand('hangup');
223 228
 ```
224 229
 
225 230
 * **email** - Changes the local email address. This command requires one argument - the new email address to be set.
226 231
 ```javascript
227
-api.executeCommand('email', 'example@example.com')
232
+api.executeCommand('email', 'example@example.com');
228 233
 ```
229 234
 
230 235
 * **avatarUrl** - Changes the local avatar URL. This command requires one argument - the new avatar URL to be set.
231 236
 ```javascript
232
-api.executeCommand('avatarUrl', 'https://avatars0.githubusercontent.com/u/3671647')
237
+api.executeCommand('avatarUrl', 'https://avatars0.githubusercontent.com/u/3671647');
233 238
 ```
234 239
 
235 240
 You can also execute multiple commands using the `executeCommands` method:
236 241
 ```javascript
237
-api.executeCommands(commands)
242
+api.executeCommands(commands);
238 243
 ```
239 244
 The `commands` parameter is an object with the names of the commands as keys and the arguments for the commands as values:
240 245
 ```javascript
241
-api.executeCommands({displayName: ['nickname'], toggleAudio: []});
246
+api.executeCommands({
247
+    displayName: [ 'nickname' ],
248
+    toggleAudio: []
249
+});
242 250
 ```
243 251
 
244 252
 You can add event listeners to the embedded Jitsi Meet using the `addEventListener` method.
245 253
 **NOTE: This method still exists but it is deprecated. JitsiMeetExternalAPI class extends [EventEmitter]. Use [EventEmitter] methods (`addListener` or `on`).**
246 254
 ```javascript
247
-api.addEventListener(event, listener)
255
+api.addEventListener(event, listener);
248 256
 ```
249 257
 
250 258
 The `event` parameter is a String object with the name of the event.
@@ -255,36 +263,36 @@ The following events are currently supported:
255 263
 changes. The listener will receive an object with the following structure:
256 264
 ```javascript
257 265
 {
258
-"id": id, // the id of the participant that changed his avatar.
259
-"avatarURL": avatarURL // the new avatar URL.
266
+    id: string, // the id of the participant that changed his avatar.
267
+    avatarURL: string // the new avatar URL.
260 268
 }
261 269
 ```
262 270
 
263 271
 * **audioAvailabilityChanged** - event notifications about audio availability status changes. The listener will receive an object with the following structure:
264 272
 ```javascript
265 273
 {
266
-"available": available // new available status - boolean
274
+    available: boolean // new available status - boolean
267 275
 }
268 276
 ```
269 277
 
270 278
 * **audioMuteStatusChanged** - event notifications about audio mute status changes. The listener will receive an object with the following structure:
271 279
 ```javascript
272 280
 {
273
-"muted": muted // new muted status - boolean
281
+    muted: boolean // new muted status - boolean
274 282
 }
275 283
 ```
276 284
 
277 285
 * **screenSharingStatusChanged** - receives event notifications about turning on/off the local user screen sharing. The listener will receive object with the following structure:
278 286
 ```javascript
279 287
 {
280
-"on": on, //whether screen sharing is on
281
-"details": {
288
+    on: boolean, //whether screen sharing is on
289
+    details: {
282 290
 
283
-    // From where the screen sharing is capturing, if known. Values which are
284
-    // passed include "window", "screen", "proxy", "device". The value undefined
285
-    // will be passed if the source type is unknown or screen share is off.
286
-    sourceType: sourceType
287
-}
291
+        // From where the screen sharing is capturing, if known. Values which are
292
+        // passed include 'window', 'screen', 'proxy', 'device'. The value undefined
293
+        // will be passed if the source type is unknown or screen share is off.
294
+        sourceType: string|undefined
295
+    }
288 296
 }
289 297
 ```
290 298
 
@@ -292,9 +300,9 @@ changes. The listener will receive an object with the following structure:
292 300
 messages. The listener will receive an object with the following structure:
293 301
 ```javascript
294 302
 {
295
-"from": from, // The id of the user that sent the message
296
-"nick": nick, // the nickname of the user that sent the message
297
-"message": txt // the text of the message
303
+    from: string, // The id of the user that sent the message
304
+    nick: string, // the nickname of the user that sent the message
305
+    message: string // the text of the message
298 306
 }
299 307
 ```
300 308
 
@@ -302,7 +310,7 @@ messages. The listener will receive an object with the following structure:
302 310
 messages. The listener will receive an object with the following structure:
303 311
 ```javascript
304 312
 {
305
-"message": txt // the text of the message
313
+    message: string // the text of the message
306 314
 }
307 315
 ```
308 316
 
@@ -310,15 +318,15 @@ messages. The listener will receive an object with the following structure:
310 318
 changes. The listener will receive an object with the following structure:
311 319
 ```javascript
312 320
 {
313
-"id": id, // the id of the participant that changed his display name
314
-"displayname": displayName // the new display name
321
+    id: string, // the id of the participant that changed his display name
322
+    displayname: string // the new display name
315 323
 }
316 324
 ```
317 325
 
318 326
 * **deviceListChanged** - event notifications about device list changes. The listener will receive an object with the following structure:
319 327
 ```javascript
320 328
 {
321
-"devices": devices // the new list of available devices.
329
+    devices: Object // the new list of available devices.
322 330
 }
323 331
 ```
324 332
 NOTE: The devices object has the same format as the getAvailableDevices result format.
@@ -327,60 +335,60 @@ NOTE: The devices object has the same format as the getAvailableDevices result f
327 335
 changes. The listener will receive an object with the following structure:
328 336
 ```javascript
329 337
 {
330
-"id": id, // the id of the participant that changed his email
331
-"email": email // the new email
338
+    id: string, // the id of the participant that changed his email
339
+    email: string // the new email
332 340
 }
333 341
 ```
334 342
 * **filmstripDisplayChanged** - event notifications about the visibility of the filmstrip being updated.
335 343
 ```javascript
336 344
 {
337
-"visible": visible, // Whether or not the filmstrip is displayed or hidden.
345
+    visible: boolean // Whether or not the filmstrip is displayed or hidden.
338 346
 }
339 347
 ```
340 348
 
341 349
 * **participantJoined** - event notifications about new participants who join the room. The listener will receive an object with the following structure:
342 350
 ```javascript
343 351
 {
344
-"id": id, // the id of the participant
345
-"displayName": displayName // the display name of the participant
352
+    id: string, // the id of the participant
353
+    displayName: string // the display name of the participant
346 354
 }
347 355
 ```
348 356
 
349 357
 * **participantLeft** - event notifications about participants that leave the room. The listener will receive an object with the following structure:
350 358
 ```javascript
351 359
 {
352
-"id": id // the id of the participant
360
+    id: string // the id of the participant
353 361
 }
354 362
 ```
355 363
 
356 364
 * **videoConferenceJoined** - event notifications fired when the local user has joined the video conference. The listener will receive an object with the following structure:
357 365
 ```javascript
358 366
 {
359
-"roomName": room, // the room name of the conference
360
-"id": id, // the id of the local participant
361
-"displayName": displayName, // the display name of the local participant
362
-"avatarURL": avatarURL // the avatar URL of the local participant
367
+    roomName: string, // the room name of the conference
368
+    id: string, // the id of the local participant
369
+    displayName: string, // the display name of the local participant
370
+    avatarURL: string // the avatar URL of the local participant
363 371
 }
364 372
 ```
365 373
 
366 374
 * **videoConferenceLeft** - event notifications fired when the local user has left the video conference. The listener will receive an object with the following structure:
367 375
 ```javascript
368 376
 {
369
-"roomName": room // the room name of the conference
377
+    roomName: string // the room name of the conference
370 378
 }
371 379
 ```
372 380
 
373 381
 * **videoAvailabilityChanged** - event notifications about video availability status changes. The listener will receive an object with the following structure:
374 382
 ```javascript
375 383
 {
376
-"available": available // new available status - boolean
384
+    available: boolean // new available status - boolean
377 385
 }
378 386
 ```
379 387
 
380 388
 * **videoMuteStatusChanged** - event notifications about video mute status changes. The listener will receive an object with the following structure:
381 389
 ```javascript
382 390
 {
383
-"muted": muted // new muted status - boolean
391
+    muted: boolean // new muted status - boolean
384 392
 }
385 393
 ```
386 394
 
@@ -390,7 +398,7 @@ changes. The listener will receive an object with the following structure:
390 398
 The listener will receive an object with the following structure:
391 399
 ```javascript
392 400
 {
393
-"subject": subject // the new subject
401
+    subject: string // the new subject
394 402
 }
395 403
 ```
396 404
 
@@ -412,79 +420,80 @@ function outgoingMessageListener(object)
412 420
 
413 421
 api.addEventListeners({
414 422
     incomingMessage: incomingMessageListener,
415
-    outgoingMessage: outgoingMessageListener})
423
+    outgoingMessage: outgoingMessageListener
424
+});
416 425
 ```
417 426
 
418 427
 If you want to remove a listener you can use `removeEventListener` method with argument the name of the event.
419 428
 **NOTE: This method still exists but it is deprecated. JitsiMeetExternalAPI class extends [EventEmitter]. Use [EventEmitter] methods( `removeListener`).**
420 429
 ```javascript
421
-api.removeEventListener("incomingMessage");
430
+api.removeEventListener('incomingMessage');
422 431
 ```
423 432
 
424 433
 If you want to remove more than one event you can use `removeEventListeners` method with an Array with the names of the events as an argument.
425 434
 **NOTE: This method still exists but it is deprecated. JitsiMeetExternalAPI class extends [EventEmitter]. Use [EventEmitter] methods.**
426 435
 ```javascript
427
-api.removeEventListeners(["incomingMessage", "outgoingMessageListener"]);
436
+api.removeEventListeners([ 'incomingMessage', 'outgoingMessageListener' ]);
428 437
 ```
429 438
 
430 439
 You can get the number of participants in the conference with the following API function:
431 440
 ```javascript
432
-var numberOfParticipants = api.getNumberOfParticipants();
441
+const numberOfParticipants = api.getNumberOfParticipants();
433 442
 ```
434 443
 
435 444
 You can get the avatar URL of a participant in the conference with the following API function:
436 445
 ```javascript
437
-var avatarURL = api.getAvatarURL(participantId);
446
+const avatarURL = api.getAvatarURL(participantId);
438 447
 ```
439 448
 
440 449
 You can get the display name of a participant in the conference with the following API function:
441 450
 ```javascript
442
-var displayName = api.getDisplayName(participantId);
451
+const displayName = api.getDisplayName(participantId);
443 452
 ```
444 453
 
445 454
 You can get the email of a participant in the conference with the following API function:
446 455
 ```javascript
447
-var email = api.getEmail(participantId);
456
+const email = api.getEmail(participantId);
448 457
 ```
449 458
 
450 459
 You can get the iframe HTML element where Jitsi Meet is loaded with the following API function:
451 460
 ```javascript
452
-var iframe = api.getIFrame();
461
+const iframe = api.getIFrame();
453 462
 ```
454 463
 
455 464
 You can check whether the audio is muted with the following API function:
456 465
 ```javascript
457
-api.isAudioMuted().then(function(muted) {
466
+api.isAudioMuted().then(muted => {
458 467
     ...
459 468
 });
460 469
 ```
461 470
 
462 471
 You can check whether the video is muted with the following API function:
463 472
 ```javascript
464
-api.isVideoMuted().then(function(muted) {
473
+api.isVideoMuted().then(muted => {
465 474
     ...
466 475
 });
467 476
 ```
468 477
 
469 478
 You can check whether the audio is available with the following API function:
470 479
 ```javascript
471
-api.isAudioAvailable().then(function(available) {
480
+api.isAudioAvailable().then(available => {
472 481
     ...
473 482
 });
474 483
 ```
475 484
 
476 485
 You can check whether the video is available with the following API function:
477 486
 ```javascript
478
-api.isVideoAvailable().then(function(available) {
487
+api.isVideoAvailable().then(available => {
479 488
     ...
480 489
 });
481 490
 ```
482 491
 
483 492
 You can invite new participants to the call with the following API function:
484 493
 ```javascript
485
-api.invite([{...}, {...}, {...}]).then(function() {
494
+api.invite([ {...}, {...}, {...} ]).then(() => {
486 495
     // success
487
-}).catch(function() {
496
+}).catch(() => {
488 497
     // failure
489 498
 });
490 499
 ```
@@ -492,7 +501,7 @@ api.invite([{...}, {...}, {...}]).then(function() {
492 501
 
493 502
 You can remove the embedded Jitsi Meet Conference with the following API function:
494 503
 ```javascript
495
-api.dispose()
504
+api.dispose();
496 505
 ```
497 506
 
498 507
 NOTE: It's a good practice to remove the conference before the page is unloaded.

Loading…
取消
儲存