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

181 lines
5.5 KiB
JavaScript

import React from 'react';
import { defineMessages, injectIntl } 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 AudioStreamVolume from '/imports/ui/components/audio/audio-stream-volume/component';
import EnterAudioContainer from '/imports/ui/components/audio/enter-audio/container';
import AudioTestContainer from '/imports/ui/components/audio/audio-test/container';
import cx from 'classnames';
import styles from './styles';
const intlMessages = defineMessages({
backLabel: {
id: 'app.audio.backLabel',
description: 'audio settings back button label',
},
titleLabel: {
id: 'app.audio.audioSettings.titleLabel',
description: 'audio setting title 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',
},
retryLabel: {
id: 'app.audio.audioSettings.retryLabel',
description: 'Retry button label',
},
});
class AudioSettings extends React.Component {
constructor(props) {
super(props);
this.chooseAudio = this.chooseAudio.bind(this);
this.handleInputChange = this.handleInputChange.bind(this);
this.handleOutputChange = this.handleOutputChange.bind(this);
this.handleBack = props.handleBack;
this.handleRetry = props.handleRetry;
this.exitAudio = props.exitAudio;
this.changeInputDevice = props.changeInputDevice;
this.changeOutputDevice = props.changeOutputDevice;
console.log('inputDeviceId', props.inputDeviceId);
this.state = {
inputDeviceId: props.inputDeviceId,
outputDeviceId: undefined,
};
}
chooseAudio() {
this.props.changeMenu(this.props.JOIN_AUDIO);
}
handleInputChange(deviceId, device) {
console.log(`INPUT DEVICE CHANGED: ${deviceId}`);
console.log(device);
this.changeInputDevice(deviceId);
this.setState({
inputDeviceId: deviceId,
});
}
handleOutputChange(deviceId, device) {
console.log(`OUTPUT DEVICE CHANGED: ${deviceId}`);
console.log(device);
this.changeOutputDevice(deviceId);
this.setState({
outputDeviceId: deviceId,
});
}
// handleClose() {
// this.setState({ isOpen: false });
// this.props.mountModal(null);
// }
render() {
const {
isConnecting,
intl,
} = this.props;
// return this.renderCalling();
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 className={cx(styles.label, styles.labelSmall)}>
{intl.formatMessage(intlMessages.micSourceLabel)}
<DeviceSelector
value={this.state.inputDeviceId}
className={styles.select}
kind="audioinput"
onChange={this.handleInputChange}
/>
</label>
</div>
</div>
<div className={styles.col}>
<div className={styles.formElement}>
<label className={cx(styles.label, styles.labelSmall)}>
{intl.formatMessage(intlMessages.speakerSourceLabel)}
<DeviceSelector
value={this.state.outputDeviceId}
className={styles.select}
kind="audiooutput"
onChange={this.handleOutputChange}
/>
</label>
</div>
</div>
</div>
<div className={styles.row}>
<div className={styles.col}>
<div className={styles.formElement}>
<label className={cx(styles.label, styles.labelSmall)}>
{intl.formatMessage(intlMessages.streamVolumeLabel)}
<AudioStreamVolume
deviceId={this.state.inputDeviceId}
className={styles.audioMeter}
/>
</label>
</div>
</div>
<div className={styles.col}>
<label className={styles.labelSmall}>
Test your speaker volume
<AudioTestContainer />
</label>
</div>
</div>
</div>
<div className={styles.enterAudio}>
<Button
className={styles.backBtn}
label={intl.formatMessage(intlMessages.backLabel)}
size={'md'}
color={'primary'}
onClick={this.handleBack}
disabled={isConnecting}
ghost
/>
<Button
size={'md'}
color={'primary'}
label={intl.formatMessage(intlMessages.retryLabel)}
onClick={this.handleRetry}
/>
</div>
</div>
);
}
}
export default withModalMounter(injectIntl(AudioSettings));