2016-11-16 05:00:28 +08:00
|
|
|
import React from 'react';
|
2017-10-11 02:03:29 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2020-05-26 04:00:13 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2022-02-15 04:20:50 +08:00
|
|
|
import Button from '/imports/ui/components/common/button/component';
|
2017-05-03 01:18:01 +08:00
|
|
|
import { withModalMounter } from '/imports/ui/components/modal/service';
|
2017-03-23 21:19:44 +08:00
|
|
|
import AudioTestContainer from '/imports/ui/components/audio/audio-test/container';
|
2021-11-09 22:33:40 +08:00
|
|
|
import Styled from './styles';
|
2017-09-26 04:28:36 +08:00
|
|
|
|
2017-10-11 02:03:29 +08:00
|
|
|
const propTypes = {
|
2021-08-09 22:24:02 +08:00
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2017-10-11 02:03:29 +08:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2017-09-26 04:28:36 +08:00
|
|
|
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
|
|
|
},
|
2017-09-26 04:28:36 +08:00
|
|
|
});
|
2016-12-01 11:37:52 +08:00
|
|
|
|
2017-02-17 04:57:57 +08:00
|
|
|
class AudioSettings extends React.Component {
|
2016-11-16 05:00:28 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2017-10-11 02:03:29 +08:00
|
|
|
const {
|
2017-10-27 21:19:24 +08:00
|
|
|
inputDeviceId,
|
|
|
|
outputDeviceId,
|
2017-10-11 02:03:29 +08:00
|
|
|
} = props;
|
|
|
|
|
2016-12-09 02:17:08 +08:00
|
|
|
this.handleInputChange = this.handleInputChange.bind(this);
|
|
|
|
this.handleOutputChange = this.handleOutputChange.bind(this);
|
2017-10-04 04:42:10 +08:00
|
|
|
|
2016-12-09 02:17:08 +08:00
|
|
|
this.state = {
|
2017-10-27 21:19:24 +08:00
|
|
|
inputDeviceId,
|
|
|
|
outputDeviceId,
|
2017-03-23 04:10:49 +08:00
|
|
|
};
|
2016-11-22 05:06:19 +08:00
|
|
|
}
|
|
|
|
|
2017-10-23 20:41:09 +08:00
|
|
|
handleInputChange(deviceId) {
|
2017-10-27 21:19:24 +08:00
|
|
|
const {
|
|
|
|
changeInputDevice,
|
|
|
|
} = this.props;
|
|
|
|
|
2017-11-01 01:34:06 +08:00
|
|
|
changeInputDevice(deviceId);
|
2016-12-09 02:17:08 +08:00
|
|
|
this.setState({
|
2017-03-23 04:10:49 +08:00
|
|
|
inputDeviceId: deviceId,
|
2016-12-09 02:17:08 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-23 20:41:09 +08:00
|
|
|
handleOutputChange(deviceId) {
|
2017-10-27 21:19:24 +08:00
|
|
|
const {
|
|
|
|
changeOutputDevice,
|
|
|
|
} = this.props;
|
|
|
|
|
2017-11-01 01:34:06 +08:00
|
|
|
changeOutputDevice(deviceId);
|
2017-09-26 04:28:36 +08:00
|
|
|
this.setState({
|
|
|
|
outputDeviceId: deviceId,
|
|
|
|
});
|
2016-12-09 02:17:08 +08:00
|
|
|
}
|
|
|
|
|
2016-11-16 05:00:28 +08:00
|
|
|
render() {
|
2017-02-17 04:57:57 +08:00
|
|
|
const {
|
2017-09-29 21:38:10 +08:00
|
|
|
isConnecting,
|
2017-02-17 04:57:57 +08:00
|
|
|
intl,
|
2017-10-27 21:19:24 +08:00
|
|
|
handleBack,
|
|
|
|
handleRetry,
|
2017-02-17 04:57:57 +08:00
|
|
|
} = this.props;
|
|
|
|
|
2021-08-09 22:24:02 +08:00
|
|
|
const { inputDeviceId, outputDeviceId } = this.state;
|
|
|
|
|
2016-11-16 05:00:28 +08:00
|
|
|
return (
|
2021-11-09 22:33:40 +08:00
|
|
|
<Styled.FormWrapper>
|
|
|
|
<Styled.Form>
|
|
|
|
<Styled.Row>
|
|
|
|
<Styled.AudioNote>
|
2017-04-07 20:44:05 +08:00
|
|
|
{intl.formatMessage(intlMessages.descriptionLabel)}
|
2021-11-09 22:33:40 +08:00
|
|
|
</Styled.AudioNote>
|
|
|
|
</Styled.Row>
|
|
|
|
|
|
|
|
<Styled.Row>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.FormElement>
|
|
|
|
<Styled.LabelSmall htmlFor="inputDeviceSelector">
|
2017-04-07 20:44:05 +08:00
|
|
|
{intl.formatMessage(intlMessages.micSourceLabel)}
|
2021-11-09 22:33:40 +08:00
|
|
|
<Styled.DeviceSelectorSelect
|
2017-10-11 02:03:29 +08:00
|
|
|
id="inputDeviceSelector"
|
2021-08-09 22:24:02 +08:00
|
|
|
value={inputDeviceId}
|
2017-07-06 23:54:18 +08:00
|
|
|
kind="audioinput"
|
|
|
|
onChange={this.handleInputChange}
|
|
|
|
/>
|
2021-11-09 22:33:40 +08:00
|
|
|
</Styled.LabelSmall>
|
|
|
|
</Styled.FormElement>
|
|
|
|
</Styled.Col>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.FormElement>
|
|
|
|
<Styled.LabelSmall htmlFor="outputDeviceSelector">
|
2017-04-07 20:44:05 +08:00
|
|
|
{intl.formatMessage(intlMessages.speakerSourceLabel)}
|
2021-11-09 22:33:40 +08:00
|
|
|
<Styled.DeviceSelectorSelect
|
2017-10-11 02:03:29 +08:00
|
|
|
id="outputDeviceSelector"
|
2021-08-09 22:24:02 +08:00
|
|
|
value={outputDeviceId}
|
2017-07-06 23:54:18 +08:00
|
|
|
kind="audiooutput"
|
|
|
|
onChange={this.handleOutputChange}
|
|
|
|
/>
|
2021-11-09 22:33:40 +08:00
|
|
|
</Styled.LabelSmall>
|
|
|
|
</Styled.FormElement>
|
|
|
|
</Styled.Col>
|
|
|
|
</Styled.Row>
|
2017-03-23 04:10:49 +08:00
|
|
|
|
2021-11-09 22:33:40 +08:00
|
|
|
<Styled.Row>
|
|
|
|
<Styled.SpacedLeftCol>
|
2021-08-09 22:24:02 +08:00
|
|
|
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
|
2021-11-09 22:33:40 +08:00
|
|
|
<Styled.LabelSmall htmlFor="audioTest">
|
2017-10-10 04:48:10 +08:00
|
|
|
Test your speaker volume
|
2017-10-11 02:03:29 +08:00
|
|
|
<AudioTestContainer id="audioTest" />
|
2021-11-09 22:33:40 +08:00
|
|
|
</Styled.LabelSmall>
|
|
|
|
</Styled.SpacedLeftCol>
|
|
|
|
</Styled.Row>
|
|
|
|
</Styled.Form>
|
2017-03-23 04:10:49 +08:00
|
|
|
|
2021-11-09 22:33:40 +08:00
|
|
|
<Styled.EnterAudio>
|
|
|
|
<Styled.BackButton
|
2017-09-26 04:28:36 +08:00
|
|
|
label={intl.formatMessage(intlMessages.backLabel)}
|
2019-03-12 12:14:31 +08:00
|
|
|
size="md"
|
|
|
|
color="primary"
|
2017-10-27 21:19:24 +08:00
|
|
|
onClick={handleBack}
|
2017-09-29 21:38:10 +08:00
|
|
|
disabled={isConnecting}
|
|
|
|
ghost
|
2017-09-26 04:28:36 +08:00
|
|
|
/>
|
2017-09-29 21:38:10 +08:00
|
|
|
<Button
|
2019-03-12 12:14:31 +08:00
|
|
|
size="md"
|
|
|
|
color="primary"
|
2017-10-05 04:49:11 +08:00
|
|
|
label={intl.formatMessage(intlMessages.retryLabel)}
|
2017-10-27 21:19:24 +08:00
|
|
|
onClick={handleRetry}
|
2017-10-05 04:49:11 +08:00
|
|
|
/>
|
2021-11-09 22:33:40 +08:00
|
|
|
</Styled.EnterAudio>
|
|
|
|
</Styled.FormWrapper>
|
2017-09-29 21:42:08 +08:00
|
|
|
);
|
2016-11-16 05:00:28 +08:00
|
|
|
}
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|
2017-02-17 04:57:57 +08:00
|
|
|
|
2017-10-11 02:03:29 +08:00
|
|
|
AudioSettings.propTypes = propTypes;
|
|
|
|
|
2017-05-03 01:18:01 +08:00
|
|
|
export default withModalMounter(injectIntl(AudioSettings));
|