Explorar el Código

feat: Extends JitsiConference.getLocalTracks() with an optional media type parameter.

dev1
Boris Grozev hace 9 años
padre
commit
39b18c4675
Se han modificado 1 ficheros con 13 adiciones y 6 borrados
  1. 13
    6
      JitsiConference.js

+ 13
- 6
JitsiConference.js Ver fichero

@@ -244,17 +244,24 @@ JitsiConference.prototype.getExternalAuthUrl = function (urlForPopup) {
244 244
 };
245 245
 
246 246
 /**
247
- * Returns the local tracks.
247
+ * Returns the local tracks of the given media type, or all local tracks if no
248
+ * specific type is given.
249
+ * @param mediaType {MediaType} Optional media type (audio or video).
248 250
  */
249
-JitsiConference.prototype.getLocalTracks = function () {
251
+JitsiConference.prototype.getLocalTracks = function (mediaType) {
252
+    let tracks = [];
250 253
     if (this.rtc) {
251
-        return this.rtc.localTracks.slice();
252
-    } else {
253
-        return [];
254
+        tracks = this.rtc.localTracks.slice();
255
+    }
256
+    if (mediaType !== undefined) {
257
+        tracks = tracks.filter(
258
+            (track) => {
259
+                return track && track.getType && track.getType() === mediaType;
260
+            });
254 261
     }
262
+    return tracks;
255 263
 };
256 264
 
257
-
258 265
 /**
259 266
  * Attaches a handler for events(For example - "participant joined".) in the conference. All possible event are defined
260 267
  * in JitsiConferenceEvents.

Loading…
Cancelar
Guardar