fix(toolbox) hide volume meter when audio levels are disabled
This commit is contained in:
parent
26a6c336e3
commit
8d8cc9c8bd
|
@ -121,9 +121,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.audio-preview-entry-text {
|
&--nometer {
|
||||||
max-width: 178px;
|
.audio-preview-entry-text {
|
||||||
|
max-width: 238px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&--withmeter {
|
||||||
|
.audio-preview-entry-text {
|
||||||
|
max-width: 178px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&-icon {
|
&-icon {
|
||||||
|
|
|
@ -68,3 +68,14 @@ export function isToolbarButtonEnabled(buttonName: string, state: Object | Array
|
||||||
|
|
||||||
return buttons.includes(buttonName);
|
return buttons.includes(buttonName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether audio level measurement is enabled or not.
|
||||||
|
*
|
||||||
|
* @param {Object} state - The state of the app.
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export function areAudioLevelsEnabled(state: Object): boolean {
|
||||||
|
// Default to false for React Native as audio levels are of no interest to the mobile app.
|
||||||
|
return navigator.product !== 'ReactNative' && !state['features/base/config'].disableAudioLevels;
|
||||||
|
}
|
||||||
|
|
|
@ -40,6 +40,11 @@ export type Props = {
|
||||||
*/
|
*/
|
||||||
currentOutputDeviceId: string,
|
currentOutputDeviceId: string,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to decide whether to measure audio levels for microphone devices.
|
||||||
|
*/
|
||||||
|
measureAudioLevels: boolean,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to set a new microphone as the current one.
|
* Used to set a new microphone as the current one.
|
||||||
*/
|
*/
|
||||||
|
@ -179,6 +184,7 @@ class AudioSettingsContent extends Component<Props, State> {
|
||||||
key = { `me-${index}` }
|
key = { `me-${index}` }
|
||||||
length = { length }
|
length = { length }
|
||||||
listHeaderId = { this.microphoneHeaderId }
|
listHeaderId = { this.microphoneHeaderId }
|
||||||
|
measureAudioLevels = { this.props.measureAudioLevels }
|
||||||
onClick = { this._onMicrophoneEntryClick }>
|
onClick = { this._onMicrophoneEntryClick }>
|
||||||
{label}
|
{label}
|
||||||
</MicrophoneEntry>
|
</MicrophoneEntry>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import InlineDialog from '@atlaskit/inline-dialog';
|
import InlineDialog from '@atlaskit/inline-dialog';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { areAudioLevelsEnabled } from '../../../../base/config/functions';
|
||||||
import {
|
import {
|
||||||
getAudioInputDeviceData,
|
getAudioInputDeviceData,
|
||||||
getAudioOutputDeviceData,
|
getAudioOutputDeviceData,
|
||||||
|
@ -59,7 +60,8 @@ function AudioSettingsPopup({
|
||||||
setAudioOutputDevice,
|
setAudioOutputDevice,
|
||||||
onClose,
|
onClose,
|
||||||
outputDevices,
|
outputDevices,
|
||||||
popupPlacement
|
popupPlacement,
|
||||||
|
measureAudioLevels
|
||||||
}: Props) {
|
}: Props) {
|
||||||
return (
|
return (
|
||||||
<div className = 'audio-preview'>
|
<div className = 'audio-preview'>
|
||||||
|
@ -67,6 +69,7 @@ function AudioSettingsPopup({
|
||||||
content = { <AudioSettingsContent
|
content = { <AudioSettingsContent
|
||||||
currentMicDeviceId = { currentMicDeviceId }
|
currentMicDeviceId = { currentMicDeviceId }
|
||||||
currentOutputDeviceId = { currentOutputDeviceId }
|
currentOutputDeviceId = { currentOutputDeviceId }
|
||||||
|
measureAudioLevels = { measureAudioLevels }
|
||||||
microphoneDevices = { microphoneDevices }
|
microphoneDevices = { microphoneDevices }
|
||||||
outputDevices = { outputDevices }
|
outputDevices = { outputDevices }
|
||||||
setAudioInputDevice = { setAudioInputDevice }
|
setAudioInputDevice = { setAudioInputDevice }
|
||||||
|
@ -95,7 +98,8 @@ function mapStateToProps(state) {
|
||||||
currentOutputDeviceId: getCurrentOutputDeviceId(state),
|
currentOutputDeviceId: getCurrentOutputDeviceId(state),
|
||||||
isOpen: getAudioSettingsVisibility(state),
|
isOpen: getAudioSettingsVisibility(state),
|
||||||
microphoneDevices: getAudioInputDeviceData(state),
|
microphoneDevices: getAudioInputDeviceData(state),
|
||||||
outputDevices: getAudioOutputDeviceData(state)
|
outputDevices: getAudioOutputDeviceData(state),
|
||||||
|
measureAudioLevels: areAudioLevelsEnabled(state)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,12 @@ type Props = AudioSettingsEntryProps & {
|
||||||
* Click handler for component.
|
* Click handler for component.
|
||||||
*/
|
*/
|
||||||
onClick: Function,
|
onClick: Function,
|
||||||
listHeaderId: string
|
listHeaderId: string,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to decide whether to listen to audio level changes.
|
||||||
|
*/
|
||||||
|
measureAudioLevels: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
@ -129,9 +134,9 @@ export default class MicrophoneEntry extends Component<Props, State> {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
_startListening() {
|
_startListening() {
|
||||||
const { jitsiTrack } = this.props;
|
const { jitsiTrack, measureAudioLevels } = this.props;
|
||||||
|
|
||||||
jitsiTrack && jitsiTrack.on(
|
jitsiTrack && measureAudioLevels && jitsiTrack.on(
|
||||||
JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
|
JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
|
||||||
this._updateLevel);
|
this._updateLevel);
|
||||||
}
|
}
|
||||||
|
@ -185,20 +190,32 @@ export default class MicrophoneEntry extends Component<Props, State> {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
render() {
|
render() {
|
||||||
|
const {
|
||||||
const { deviceId, children, hasError, index, isSelected, length, jitsiTrack, listHeaderId } = this.props;
|
deviceId,
|
||||||
|
children,
|
||||||
|
hasError,
|
||||||
|
index,
|
||||||
|
isSelected,
|
||||||
|
length,
|
||||||
|
jitsiTrack,
|
||||||
|
listHeaderId,
|
||||||
|
measureAudioLevels
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
const deviceTextId: string = `choose_microphone${deviceId}`;
|
const deviceTextId: string = `choose_microphone${deviceId}`;
|
||||||
|
|
||||||
const labelledby: string = `${listHeaderId} ${deviceTextId} `;
|
const labelledby: string = `${listHeaderId} ${deviceTextId} `;
|
||||||
|
|
||||||
|
const className = `audio-preview-microphone ${measureAudioLevels
|
||||||
|
? 'audio-preview-microphone--withmeter' : 'audio-preview-microphone--nometer'}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
aria-checked = { isSelected }
|
aria-checked = { isSelected }
|
||||||
aria-labelledby = { labelledby }
|
aria-labelledby = { labelledby }
|
||||||
aria-posinset = { index }
|
aria-posinset = { index }
|
||||||
aria-setsize = { length }
|
aria-setsize = { length }
|
||||||
className = 'audio-preview-microphone'
|
className = { className }
|
||||||
onClick = { this._onClick }
|
onClick = { this._onClick }
|
||||||
onKeyPress = { this._onKeyPress }
|
onKeyPress = { this._onKeyPress }
|
||||||
role = 'radio'
|
role = 'radio'
|
||||||
|
@ -209,7 +226,7 @@ export default class MicrophoneEntry extends Component<Props, State> {
|
||||||
labelId = { deviceTextId }>
|
labelId = { deviceTextId }>
|
||||||
{children}
|
{children}
|
||||||
</AudioSettingsEntry>
|
</AudioSettingsEntry>
|
||||||
{ Boolean(jitsiTrack) && <Meter
|
{ Boolean(jitsiTrack) && measureAudioLevels && <Meter
|
||||||
className = 'audio-preview-meter-mic'
|
className = 'audio-preview-meter-mic'
|
||||||
isDisabled = { hasError }
|
isDisabled = { hasError }
|
||||||
level = { this.state.level } />
|
level = { this.state.level } />
|
||||||
|
|
Loading…
Reference in New Issue