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

197 lines
5.8 KiB
React
Raw Normal View History

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';
2017-03-28 22:02:23 +08:00
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',
},
2017-09-29 21:38:10 +08:00
enterSessionLabel: {
id: 'app.audio.enterSessionLabel',
description: 'enter session 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;
2017-09-29 21:38:10 +08:00
this.handleJoin = props.handleJoin;
this.joinEchoTest = props.joinEchoTest;
this.exitAudio = props.exitAudio;
2017-09-30 04:42:34 +08:00
this.changeInputDevice = props.changeInputDevice;
2017-10-04 04:42:10 +08:00
console.log('inputDeviceId', props.inputDeviceId);
this.state = {
2017-10-04 04:42:10 +08:00
inputDeviceId: props.inputDeviceId,
outputDeviceId: undefined,
};
}
2017-09-29 21:38:10 +08:00
componentDidMount() {
2017-09-30 04:42:34 +08:00
// this.joinEchoTest();
2017-09-29 21:38:10 +08:00
}
componentWillUnmount() {
const {
isEchoTest,
} = this.props;
if (isEchoTest) {
this.exitAudio();
}
}
chooseAudio() {
this.props.changeMenu(this.props.JOIN_AUDIO);
}
2017-09-30 04:42:34 +08:00
handleInputChange(deviceId, device) {
console.log(`INPUT DEVICE CHANGED: ${deviceId}`);
2017-09-30 04:42:34 +08:00
console.log(device);
this.changeInputDevice(deviceId);
this.setState({
inputDeviceId: deviceId,
});
}
2017-09-29 21:38:10 +08:00
handleOutputChange(deviceId, device) {
console.log(`OUTPUT DEVICE CHANGED: ${deviceId}`);
2017-09-30 04:42:34 +08:00
console.log(device);
this.setState({
outputDeviceId: deviceId,
});
}
2017-09-29 21:38:10 +08:00
// handleClose() {
// this.setState({ isOpen: false });
// this.props.mountModal(null);
// }
render() {
const {
2017-09-29 21:38:10 +08:00
isConnecting,
intl,
} = this.props;
2017-09-29 21:38:10 +08:00
// 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)}
2017-07-06 23:54:18 +08:00
<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)}
2017-07-06 23:54:18 +08:00
<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)}
2017-07-06 23:54:18 +08:00
<AudioStreamVolume
deviceId={this.state.inputDeviceId}
className={styles.audioMeter}
/>
</label>
</div>
</div>
<div className={styles.col}>
<label className={styles.label}> </label>
2017-06-03 03:25:02 +08:00
<AudioTestContainer />
</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'}
onClick={this.handleJoin}
disabled={isConnecting}
>
2017-09-29 21:42:08 +08:00
<span className={isConnecting ? styles.calling : null}>
2017-09-29 21:38:10 +08:00
{ isConnecting ? 'Calling echo test' : intl.formatMessage(intlMessages.enterSessionLabel)}
</span>
</Button>
</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
}
export default withModalMounter(injectIntl(AudioSettings));