From 00d3d3c09adb12bfb1ff5a320511b8483ca1cd95 Mon Sep 17 00:00:00 2001 From: paweldomas Date: Wed, 19 Jul 2017 12:08:51 +0200 Subject: [PATCH] fix(VideoLayout): muted for no tracks Will make the UI display audio/video muted icon for remote participants with no audio/video track. --- conference.js | 2 -- modules/UI/videolayout/VideoLayout.js | 39 ++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/conference.js b/conference.js index ef1099acc..06bcf4287 100644 --- a/conference.js +++ b/conference.js @@ -486,8 +486,6 @@ export default { // First try to retrieve both audio and video. let tryCreateLocalTracks; - // FIXME there is no video muted indication visible on the remote side, - // after starting in audio only (there's no video track) // FIXME the logic about trying to go audio only on error is duplicated if (options.startAudioOnly) { tryCreateLocalTracks diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.js index 03872a3fe..de3232634 100644 --- a/modules/UI/videolayout/VideoLayout.js +++ b/modules/UI/videolayout/VideoLayout.js @@ -331,13 +331,11 @@ var VideoLayout = { remoteVideo.addRemoteStreamElement(stream); - // if track is muted make sure we reflect that - if(stream.isMuted()) - { - if(stream.getType() === "audio") - this.onAudioMute(stream.getParticipantId(), true); - else - this.onVideoMute(stream.getParticipantId(), true); + // Make sure track's muted state is reflected + if (stream.getType() === "audio") { + this.onAudioMute(stream.getParticipantId(), stream.isMuted()); + } else { + this.onVideoMute(stream.getParticipantId(), stream.isMuted()); } }, @@ -348,6 +346,30 @@ var VideoLayout = { if (remoteVideo) { remoteVideo.removeRemoteStreamElement(stream); } + this.updateMutedForNoTracks(id, stream.getType()); + }, + + /** + * FIXME get rid of this method once muted indicator are reactified (by + * making sure that user with no tracks is displayed as muted ) + * + * If participant has no tracks will make the UI display muted status. + * @param {string} participantId + * @param {string} mediaType 'audio' or 'video' + */ + updateMutedForNoTracks(participantId, mediaType) { + const participant = APP.conference.getParticipantById(participantId); + + if (participant + && !participant.getTracksByMediaType(mediaType).length) { + if (mediaType === 'audio') { + APP.UI.setAudioMuted(participantId, true); + } else if (mediaType === 'video') { + APP.UI.setVideoMuted(participantId, true); + } else { + logger.error(`Unsupported media type: ${mediaType}`); + } + } }, /** @@ -441,6 +463,9 @@ var VideoLayout = { this._setRemoteControlProperties(user, remoteVideo); this.addRemoteVideoContainer(id, remoteVideo); + this.updateMutedForNoTracks(id, 'audio'); + this.updateMutedForNoTracks(id, 'video'); + const remoteVideosCount = Object.keys(remoteVideos).length; if (remoteVideosCount === 1) {