Browse Source

fix(toolbox) hide volume meter when audio levels are disabled

master
Akshay Raje 3 years ago
parent
commit
8d8cc9c8bd
No account linked to committer's email address

+ 11
- 2
css/_audio-preview.scss View File

121
             }
121
             }
122
         }
122
         }
123
 
123
 
124
-        .audio-preview-entry-text {
125
-            max-width: 178px;
124
+        &--nometer {
125
+            .audio-preview-entry-text {
126
+                max-width: 238px;
127
+            }
126
         }
128
         }
129
+
130
+        &--withmeter {
131
+            .audio-preview-entry-text {
132
+                max-width: 178px;
133
+            }
134
+        }
135
+
127
     }
136
     }
128
 
137
 
129
     &-icon {
138
     &-icon {

+ 11
- 0
react/features/base/config/functions.web.js View File

68
 
68
 
69
     return buttons.includes(buttonName);
69
     return buttons.includes(buttonName);
70
 }
70
 }
71
+
72
+/**
73
+ * Returns whether audio level measurement is enabled or not.
74
+ *
75
+ * @param {Object} state - The state of the app.
76
+ * @returns {boolean}
77
+ */
78
+export function areAudioLevelsEnabled(state: Object): boolean {
79
+    // Default to false for React Native as audio levels are of no interest to the mobile app.
80
+    return navigator.product !== 'ReactNative' && !state['features/base/config'].disableAudioLevels;
81
+}

+ 6
- 0
react/features/settings/components/web/audio/AudioSettingsContent.js View File

40
     */
40
     */
41
     currentOutputDeviceId: string,
41
     currentOutputDeviceId: string,
42
 
42
 
43
+    /**
44
+    * Used to decide whether to measure audio levels for microphone devices.
45
+    */
46
+    measureAudioLevels: boolean,
47
+
43
    /**
48
    /**
44
     * Used to set a new microphone as the current one.
49
     * Used to set a new microphone as the current one.
45
     */
50
     */
179
                 key = { `me-${index}` }
184
                 key = { `me-${index}` }
180
                 length = { length }
185
                 length = { length }
181
                 listHeaderId = { this.microphoneHeaderId }
186
                 listHeaderId = { this.microphoneHeaderId }
187
+                measureAudioLevels = { this.props.measureAudioLevels }
182
                 onClick = { this._onMicrophoneEntryClick }>
188
                 onClick = { this._onMicrophoneEntryClick }>
183
                 {label}
189
                 {label}
184
             </MicrophoneEntry>
190
             </MicrophoneEntry>

+ 6
- 2
react/features/settings/components/web/audio/AudioSettingsPopup.js View File

3
 import InlineDialog from '@atlaskit/inline-dialog';
3
 import InlineDialog from '@atlaskit/inline-dialog';
4
 import React from 'react';
4
 import React from 'react';
5
 
5
 
6
+import { areAudioLevelsEnabled } from '../../../../base/config/functions';
6
 import {
7
 import {
7
     getAudioInputDeviceData,
8
     getAudioInputDeviceData,
8
     getAudioOutputDeviceData,
9
     getAudioOutputDeviceData,
59
     setAudioOutputDevice,
60
     setAudioOutputDevice,
60
     onClose,
61
     onClose,
61
     outputDevices,
62
     outputDevices,
62
-    popupPlacement
63
+    popupPlacement,
64
+    measureAudioLevels
63
 }: Props) {
65
 }: Props) {
64
     return (
66
     return (
65
         <div className = 'audio-preview'>
67
         <div className = 'audio-preview'>
67
                 content = { <AudioSettingsContent
69
                 content = { <AudioSettingsContent
68
                     currentMicDeviceId = { currentMicDeviceId }
70
                     currentMicDeviceId = { currentMicDeviceId }
69
                     currentOutputDeviceId = { currentOutputDeviceId }
71
                     currentOutputDeviceId = { currentOutputDeviceId }
72
+                    measureAudioLevels = { measureAudioLevels }
70
                     microphoneDevices = { microphoneDevices }
73
                     microphoneDevices = { microphoneDevices }
71
                     outputDevices = { outputDevices }
74
                     outputDevices = { outputDevices }
72
                     setAudioInputDevice = { setAudioInputDevice }
75
                     setAudioInputDevice = { setAudioInputDevice }
95
         currentOutputDeviceId: getCurrentOutputDeviceId(state),
98
         currentOutputDeviceId: getCurrentOutputDeviceId(state),
96
         isOpen: getAudioSettingsVisibility(state),
99
         isOpen: getAudioSettingsVisibility(state),
97
         microphoneDevices: getAudioInputDeviceData(state),
100
         microphoneDevices: getAudioInputDeviceData(state),
98
-        outputDevices: getAudioOutputDeviceData(state)
101
+        outputDevices: getAudioOutputDeviceData(state),
102
+        measureAudioLevels: areAudioLevelsEnabled(state)
99
     };
103
     };
100
 }
104
 }
101
 
105
 

+ 24
- 7
react/features/settings/components/web/audio/MicrophoneEntry.js View File

41
      * Click handler for component.
41
      * Click handler for component.
42
      */
42
      */
43
     onClick: Function,
43
     onClick: Function,
44
-    listHeaderId: string
44
+    listHeaderId: string,
45
+
46
+    /**
47
+    * Used to decide whether to listen to audio level changes.
48
+    */
49
+    measureAudioLevels: boolean,
45
 }
50
 }
46
 
51
 
47
 type State = {
52
 type State = {
129
      * @returns {void}
134
      * @returns {void}
130
      */
135
      */
131
     _startListening() {
136
     _startListening() {
132
-        const { jitsiTrack } = this.props;
137
+        const { jitsiTrack, measureAudioLevels } = this.props;
133
 
138
 
134
-        jitsiTrack && jitsiTrack.on(
139
+        jitsiTrack && measureAudioLevels && jitsiTrack.on(
135
             JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
140
             JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
136
             this._updateLevel);
141
             this._updateLevel);
137
     }
142
     }
185
      * @inheritdoc
190
      * @inheritdoc
186
      */
191
      */
187
     render() {
192
     render() {
188
-
189
-        const { deviceId, children, hasError, index, isSelected, length, jitsiTrack, listHeaderId } = this.props;
193
+        const {
194
+            deviceId,
195
+            children,
196
+            hasError,
197
+            index,
198
+            isSelected,
199
+            length,
200
+            jitsiTrack,
201
+            listHeaderId,
202
+            measureAudioLevels
203
+        } = this.props;
190
 
204
 
191
         const deviceTextId: string = `choose_microphone${deviceId}`;
205
         const deviceTextId: string = `choose_microphone${deviceId}`;
192
 
206
 
193
         const labelledby: string = `${listHeaderId} ${deviceTextId} `;
207
         const labelledby: string = `${listHeaderId} ${deviceTextId} `;
194
 
208
 
209
+        const className = `audio-preview-microphone ${measureAudioLevels
210
+            ? 'audio-preview-microphone--withmeter' : 'audio-preview-microphone--nometer'}`;
211
+
195
         return (
212
         return (
196
             <li
213
             <li
197
                 aria-checked = { isSelected }
214
                 aria-checked = { isSelected }
198
                 aria-labelledby = { labelledby }
215
                 aria-labelledby = { labelledby }
199
                 aria-posinset = { index }
216
                 aria-posinset = { index }
200
                 aria-setsize = { length }
217
                 aria-setsize = { length }
201
-                className = 'audio-preview-microphone'
218
+                className = { className }
202
                 onClick = { this._onClick }
219
                 onClick = { this._onClick }
203
                 onKeyPress = { this._onKeyPress }
220
                 onKeyPress = { this._onKeyPress }
204
                 role = 'radio'
221
                 role = 'radio'
209
                     labelId = { deviceTextId }>
226
                     labelId = { deviceTextId }>
210
                     {children}
227
                     {children}
211
                 </AudioSettingsEntry>
228
                 </AudioSettingsEntry>
212
-                { Boolean(jitsiTrack) && <Meter
229
+                { Boolean(jitsiTrack) && measureAudioLevels && <Meter
213
                     className = 'audio-preview-meter-mic'
230
                     className = 'audio-preview-meter-mic'
214
                     isDisabled = { hasError }
231
                     isDisabled = { hasError }
215
                     level = { this.state.level } />
232
                     level = { this.state.level } />

Loading…
Cancel
Save