bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/audio-settings/component.jsx

182 lines
5.3 KiB
React
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl, intlShape } from 'react-intl';
import Button from '/imports/ui/components/button/component';
import { withModalMounter } from '/imports/ui/components/modal/service';
import DeviceSelector from '/imports/ui/components/audio/device-selector/component';
import AudioTestContainer from '/imports/ui/components/audio/audio-test/container';
import cx from 'classnames';
import styles from './styles';
const propTypes = {
intl: intlShape.isRequired,
exitAudio: PropTypes.func.isRequired,
changeInputDevice: PropTypes.func.isRequired,
changeOutputDevice: PropTypes.func.isRequired,
handleBack: PropTypes.func.isRequired,
handleRetry: PropTypes.func.isRequired,
isConnecting: PropTypes.bool.isRequired,
inputDeviceId: PropTypes.string.isRequired,
outputDeviceId: PropTypes.string.isRequired,
};
const intlMessages = defineMessages({
backLabel: {
id: 'app.audio.backLabel',
description: 'audio settings back button label',
},
descriptionLabel: {
id: 'app.audio.audioSettings.descriptionLabel',
description: 'audio settings description label',
},
micSourceLabel: {
id: 'app.audio.audioSettings.microphoneSourceLabel',
description: 'Label for mic source',
},
speakerSourceLabel: {
id: 'app.audio.audioSettings.speakerSourceLabel',
description: 'Label for speaker source',
},
streamVolumeLabel: {
id: 'app.audio.audioSettings.microphoneStreamLabel',
description: 'Label for stream volume',
},
2017-10-05 04:49:11 +08:00
retryLabel: {
id: 'app.audio.audioSettings.retryLabel',
description: 'Retry button label',
2017-09-29 21:38:10 +08:00
},
});
class AudioSettings extends React.Component {
constructor(props) {
super(props);
const {
handleBack,
handleRetry,
exitAudio,
changeInputDevice,
changeOutputDevice,
} = props;
this.handleInputChange = this.handleInputChange.bind(this);
this.handleOutputChange = this.handleOutputChange.bind(this);
this.handleBack = handleBack;
this.handleRetry = handleRetry;
this.exitAudio = exitAudio;
this.changeInputDevice = changeInputDevice;
this.changeOutputDevice = changeOutputDevice;
2017-10-04 04:42:10 +08:00
this.state = {
2017-10-04 04:42:10 +08:00
inputDeviceId: props.inputDeviceId,
outputDeviceId: props.outputDeviceId,
};
}
2017-10-23 20:41:09 +08:00
handleInputChange(deviceId) {
2017-09-30 04:42:34 +08:00
this.changeInputDevice(deviceId);
this.setState({
inputDeviceId: deviceId,
});
}
2017-10-23 20:41:09 +08:00
handleOutputChange(deviceId) {
this.changeOutputDevice(deviceId);
this.setState({
outputDeviceId: deviceId,
});
}
render() {
const {
2017-09-29 21:38:10 +08:00
isConnecting,
intl,
} = this.props;
return (
<div>
<div className={styles.form}>
<div className={styles.row}>
<div className={styles.audioNote}>
{intl.formatMessage(intlMessages.descriptionLabel)}
</div>
</div>
<div className={styles.row}>
<div className={styles.col}>
<div className={styles.formElement}>
<label
htmlFor="inputDeviceSelector"
className={cx(styles.label, styles.labelSmall)}
>
{intl.formatMessage(intlMessages.micSourceLabel)}
2017-07-06 23:54:18 +08:00
<DeviceSelector
id="inputDeviceSelector"
2017-07-06 23:54:18 +08:00
value={this.state.inputDeviceId}
className={styles.select}
kind="audioinput"
onChange={this.handleInputChange}
/>
</label>
</div>
</div>
<div className={styles.col}>
<div className={styles.formElement}>
<label
htmlFor="outputDeviceSelector"
className={cx(styles.label, styles.labelSmall)}
>
{intl.formatMessage(intlMessages.speakerSourceLabel)}
2017-07-06 23:54:18 +08:00
<DeviceSelector
id="outputDeviceSelector"
2017-07-06 23:54:18 +08:00
value={this.state.outputDeviceId}
className={styles.select}
kind="audiooutput"
onChange={this.handleOutputChange}
/>
</label>
</div>
</div>
</div>
<div className={styles.row}>
<div className={cx(styles.col, styles.spacedLeft)}>
<label
htmlFor="audioTest"
className={styles.labelSmall}
>
Test your speaker volume
<AudioTestContainer id="audioTest" />
</label>
</div>
</div>
</div>
<div className={styles.enterAudio}>
<Button
className={styles.backBtn}
label={intl.formatMessage(intlMessages.backLabel)}
size={'md'}
color={'primary'}
onClick={this.handleBack}
2017-09-29 21:38:10 +08:00
disabled={isConnecting}
ghost
/>
2017-09-29 21:38:10 +08:00
<Button
size={'md'}
color={'primary'}
2017-10-05 04:49:11 +08:00
label={intl.formatMessage(intlMessages.retryLabel)}
onClick={this.handleRetry}
/>
</div>
</div>
2017-09-29 21:42:08 +08:00
);
}
2017-09-29 21:38:10 +08:00
2017-06-03 03:25:02 +08:00
}
AudioSettings.propTypes = propTypes;
export default withModalMounter(injectIntl(AudioSettings));