Kaynağa Gözat

feat(iframe_api): get number of participants

j8
hristoterezov 8 yıl önce
ebeveyn
işleme
6bf0f9b2ec
2 değiştirilmiş dosya ile 39 ekleme ve 0 silme
  1. 5
    0
      doc/api.md
  2. 34
    0
      modules/API/external/external_api.js

+ 5
- 0
doc/api.md Dosyayı Görüntüle

@@ -202,6 +202,11 @@ If you want to remove more than one event you can use ```removeEventListeners```
202 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 210
 You can remove the embedded Jitsi Meet Conference with the following code:
206 211
 ```
207 212
 api.dispose()

+ 34
- 0
modules/API/external/external_api.js Dosyayı Görüntüle

@@ -85,6 +85,18 @@ function changeEventStatus(postis, event, status) {
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 101
  * Constructs new API instance. Creates iframe element that loads
90 102
  * Jitsi Meet.
@@ -161,6 +173,9 @@ function JitsiMeetExternalAPI(domain, room_name, width, height, parentNode,
161 173
 
162 174
     this.eventHandlers = {};
163 175
 
176
+    this.numberOfParticipants = 1;
177
+    this._setupListeners();
178
+
164 179
     id++;
165 180
 }
166 181
 
@@ -346,6 +361,25 @@ JitsiMeetExternalAPI.prototype.removeEventListeners = function(events) {
346 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 384
  * Removes the listeners and removes the Jitsi Meet frame.
351 385
  */

Loading…
İptal
Kaydet