瀏覽代碼

fix(VideoLayout): muted for no tracks

Will make the UI display audio/video muted icon for remote participants
with no audio/video track.
j8
paweldomas 8 年之前
父節點
當前提交
00d3d3c09a
共有 2 個檔案被更改,包括 32 行新增9 行删除
  1. 0
    2
      conference.js
  2. 32
    7
      modules/UI/videolayout/VideoLayout.js

+ 0
- 2
conference.js 查看文件

486
         // First try to retrieve both audio and video.
486
         // First try to retrieve both audio and video.
487
         let tryCreateLocalTracks;
487
         let tryCreateLocalTracks;
488
 
488
 
489
-        // FIXME there is no video muted indication visible on the remote side,
490
-        // after starting in audio only (there's no video track)
491
         // FIXME the logic about trying to go audio only on error is duplicated
489
         // FIXME the logic about trying to go audio only on error is duplicated
492
         if (options.startAudioOnly) {
490
         if (options.startAudioOnly) {
493
             tryCreateLocalTracks
491
             tryCreateLocalTracks

+ 32
- 7
modules/UI/videolayout/VideoLayout.js 查看文件

331
 
331
 
332
         remoteVideo.addRemoteStreamElement(stream);
332
         remoteVideo.addRemoteStreamElement(stream);
333
 
333
 
334
-        // if track is muted make sure we reflect that
335
-        if(stream.isMuted())
336
-        {
337
-            if(stream.getType() === "audio")
338
-                this.onAudioMute(stream.getParticipantId(), true);
339
-            else
340
-                this.onVideoMute(stream.getParticipantId(), true);
334
+        // Make sure track's muted state is reflected
335
+        if (stream.getType() === "audio") {
336
+            this.onAudioMute(stream.getParticipantId(), stream.isMuted());
337
+        } else {
338
+            this.onVideoMute(stream.getParticipantId(), stream.isMuted());
341
         }
339
         }
342
     },
340
     },
343
 
341
 
348
         if (remoteVideo) {
346
         if (remoteVideo) {
349
             remoteVideo.removeRemoteStreamElement(stream);
347
             remoteVideo.removeRemoteStreamElement(stream);
350
         }
348
         }
349
+        this.updateMutedForNoTracks(id, stream.getType());
350
+    },
351
+
352
+    /**
353
+     * FIXME get rid of this method once muted indicator are reactified (by
354
+     * making sure that user with no tracks is displayed as muted )
355
+     *
356
+     * If participant has no tracks will make the UI display muted status.
357
+     * @param {string} participantId
358
+     * @param {string} mediaType 'audio' or 'video'
359
+     */
360
+    updateMutedForNoTracks(participantId, mediaType) {
361
+        const participant = APP.conference.getParticipantById(participantId);
362
+
363
+        if (participant
364
+                && !participant.getTracksByMediaType(mediaType).length) {
365
+            if (mediaType === 'audio') {
366
+                APP.UI.setAudioMuted(participantId, true);
367
+            } else if (mediaType === 'video') {
368
+                APP.UI.setVideoMuted(participantId, true);
369
+            } else {
370
+                logger.error(`Unsupported media type: ${mediaType}`);
371
+            }
372
+        }
351
     },
373
     },
352
 
374
 
353
     /**
375
     /**
441
         this._setRemoteControlProperties(user, remoteVideo);
463
         this._setRemoteControlProperties(user, remoteVideo);
442
         this.addRemoteVideoContainer(id, remoteVideo);
464
         this.addRemoteVideoContainer(id, remoteVideo);
443
 
465
 
466
+        this.updateMutedForNoTracks(id, 'audio');
467
+        this.updateMutedForNoTracks(id, 'video');
468
+
444
         const remoteVideosCount = Object.keys(remoteVideos).length;
469
         const remoteVideosCount = Object.keys(remoteVideos).length;
445
 
470
 
446
         if (remoteVideosCount === 1) {
471
         if (remoteVideosCount === 1) {

Loading…
取消
儲存