浏览代码

feat(iframe_api): get number of participants

j8
hristoterezov 8 年前
父节点
当前提交
6bf0f9b2ec
共有 2 个文件被更改,包括 39 次插入0 次删除
  1. 5
    0
      doc/api.md
  2. 34
    0
      modules/API/external/external_api.js

+ 5
- 0
doc/api.md 查看文件

202
 api.removeEventListeners(["incomingMessage", "outgoingMessageListener"]);
202
 api.removeEventListeners(["incomingMessage", "outgoingMessageListener"]);
203
 ```
203
 ```
204
 
204
 
205
+You can get the number of participants in the conference with the following code:
206
+```
207
+var numberOfParticipants = api.getNumberOfParticipant();
208
+```
209
+
205
 You can remove the embedded Jitsi Meet Conference with the following code:
210
 You can remove the embedded Jitsi Meet Conference with the following code:
206
 ```
211
 ```
207
 api.dispose()
212
 api.dispose()

+ 34
- 0
modules/API/external/external_api.js 查看文件

85
     });
85
     });
86
 }
86
 }
87
 
87
 
88
+/**
89
+ * Adds given number to the numberOfParticipants property of given APIInstance.
90
+ * @param {JitsiMeetExternalAPI} APIInstance the instance of the
91
+ * JitsiMeetExternalAPI
92
+ * @param {int} number - the number of participants to be added to
93
+ * numberOfParticipants property (this parameter can be negative number if the
94
+ * numberOfParticipants should be decreased).
95
+ */
96
+function changeParticipantNumber(APIInstance, number) {
97
+    APIInstance.numberOfParticipants += number;
98
+}
99
+
88
 /**
100
 /**
89
  * Constructs new API instance. Creates iframe element that loads
101
  * Constructs new API instance. Creates iframe element that loads
90
  * Jitsi Meet.
102
  * Jitsi Meet.
161
 
173
 
162
     this.eventHandlers = {};
174
     this.eventHandlers = {};
163
 
175
 
176
+    this.numberOfParticipants = 1;
177
+    this._setupListeners();
178
+
164
     id++;
179
     id++;
165
 }
180
 }
166
 
181
 
346
         this.removeEventListener(events[i]);
361
         this.removeEventListener(events[i]);
347
 };
362
 };
348
 
363
 
364
+/**
365
+ * Returns the number of participants in the conference.
366
+ * NOTE: the local participant is included.
367
+ * @returns {int} the number of participants in the conference.
368
+ */
369
+JitsiMeetExternalAPI.prototype.getNumberOfParticipant = function() {
370
+    return this.numberOfParticipants;
371
+};
372
+
373
+/**
374
+ * Setups listeners that are used internally for JitsiMeetExternalAPI.
375
+ */
376
+JitsiMeetExternalAPI.prototype._setupListeners = function() {
377
+    this.postis.listen("participant-joined",
378
+        changeParticipantNumber.bind(null, this, 1));
379
+    this.postis.listen("participant-left",
380
+        changeParticipantNumber.bind(null, this, -1));
381
+};
382
+
349
 /**
383
 /**
350
  * Removes the listeners and removes the Jitsi Meet frame.
384
  * Removes the listeners and removes the Jitsi Meet frame.
351
  */
385
  */

正在加载...
取消
保存