Переглянути джерело

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

master
Akshay Raje 3 роки тому
джерело
коміт
8d8cc9c8bd
Аккаунт користувача з таким Email не знайдено

+ 11
- 2
css/_audio-preview.scss Переглянути файл

@@ -121,9 +121,18 @@
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 138
     &-icon {

+ 11
- 0
react/features/base/config/functions.web.js Переглянути файл

@@ -68,3 +68,14 @@ export function isToolbarButtonEnabled(buttonName: string, state: Object | Array
68 68
 
69 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 Переглянути файл

@@ -40,6 +40,11 @@ export type Props = {
40 40
     */
41 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 49
     * Used to set a new microphone as the current one.
45 50
     */
@@ -179,6 +184,7 @@ class AudioSettingsContent extends Component<Props, State> {
179 184
                 key = { `me-${index}` }
180 185
                 length = { length }
181 186
                 listHeaderId = { this.microphoneHeaderId }
187
+                measureAudioLevels = { this.props.measureAudioLevels }
182 188
                 onClick = { this._onMicrophoneEntryClick }>
183 189
                 {label}
184 190
             </MicrophoneEntry>

+ 6
- 2
react/features/settings/components/web/audio/AudioSettingsPopup.js Переглянути файл

@@ -3,6 +3,7 @@
3 3
 import InlineDialog from '@atlaskit/inline-dialog';
4 4
 import React from 'react';
5 5
 
6
+import { areAudioLevelsEnabled } from '../../../../base/config/functions';
6 7
 import {
7 8
     getAudioInputDeviceData,
8 9
     getAudioOutputDeviceData,
@@ -59,7 +60,8 @@ function AudioSettingsPopup({
59 60
     setAudioOutputDevice,
60 61
     onClose,
61 62
     outputDevices,
62
-    popupPlacement
63
+    popupPlacement,
64
+    measureAudioLevels
63 65
 }: Props) {
64 66
     return (
65 67
         <div className = 'audio-preview'>
@@ -67,6 +69,7 @@ function AudioSettingsPopup({
67 69
                 content = { <AudioSettingsContent
68 70
                     currentMicDeviceId = { currentMicDeviceId }
69 71
                     currentOutputDeviceId = { currentOutputDeviceId }
72
+                    measureAudioLevels = { measureAudioLevels }
70 73
                     microphoneDevices = { microphoneDevices }
71 74
                     outputDevices = { outputDevices }
72 75
                     setAudioInputDevice = { setAudioInputDevice }
@@ -95,7 +98,8 @@ function mapStateToProps(state) {
95 98
         currentOutputDeviceId: getCurrentOutputDeviceId(state),
96 99
         isOpen: getAudioSettingsVisibility(state),
97 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 Переглянути файл

@@ -41,7 +41,12 @@ type Props = AudioSettingsEntryProps & {
41 41
      * Click handler for component.
42 42
      */
43 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 52
 type State = {
@@ -129,9 +134,9 @@ export default class MicrophoneEntry extends Component<Props, State> {
129 134
      * @returns {void}
130 135
      */
131 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 140
             JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
136 141
             this._updateLevel);
137 142
     }
@@ -185,20 +190,32 @@ export default class MicrophoneEntry extends Component<Props, State> {
185 190
      * @inheritdoc
186 191
      */
187 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 205
         const deviceTextId: string = `choose_microphone${deviceId}`;
192 206
 
193 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 212
         return (
196 213
             <li
197 214
                 aria-checked = { isSelected }
198 215
                 aria-labelledby = { labelledby }
199 216
                 aria-posinset = { index }
200 217
                 aria-setsize = { length }
201
-                className = 'audio-preview-microphone'
218
+                className = { className }
202 219
                 onClick = { this._onClick }
203 220
                 onKeyPress = { this._onKeyPress }
204 221
                 role = 'radio'
@@ -209,7 +226,7 @@ export default class MicrophoneEntry extends Component<Props, State> {
209 226
                     labelId = { deviceTextId }>
210 227
                     {children}
211 228
                 </AudioSettingsEntry>
212
-                { Boolean(jitsiTrack) && <Meter
229
+                { Boolean(jitsiTrack) && measureAudioLevels && <Meter
213 230
                     className = 'audio-preview-meter-mic'
214 231
                     isDisabled = { hasError }
215 232
                     level = { this.state.level } />

Завантаження…
Відмінити
Зберегти