special case default - CallMediaHandler can figure it out
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
3eb519b227
commit
46a9326607
3 changed files with 31 additions and 11 deletions
|
@ -53,12 +53,36 @@ export default {
|
|||
// });
|
||||
},
|
||||
|
||||
_findDefault: function(devices) {
|
||||
return devices.some((device) => device.deviceId === 'default') ? 'default' : undefined;
|
||||
},
|
||||
|
||||
setAudioInputDefault: async function() {
|
||||
const devices = await this.getDevices();
|
||||
const audioDefault = this._findDefault(devices.audioinput);
|
||||
this._setAudioInput(audioDefault);
|
||||
},
|
||||
|
||||
setAudioInput: function(deviceId) {
|
||||
this[deviceId === 'default' ? 'setAudioInputDefault' : '_setAudioInput'](deviceId);
|
||||
},
|
||||
|
||||
_setAudioInput: function(deviceId) {
|
||||
UserSettingsStore.setLocalSetting('webrtc_audioinput', deviceId);
|
||||
Matrix.setMatrixCallAudioInput(deviceId);
|
||||
},
|
||||
|
||||
setVideoInputDefault: async function() {
|
||||
const devices = await this.getDevices();
|
||||
const videoDefault = this._findDefault(devices.videoinput);
|
||||
this._setVideoInput(videoDefault);
|
||||
},
|
||||
|
||||
setVideoInput: function(deviceId) {
|
||||
this[deviceId === 'default' ? 'setVideoInputDefault' : '_setVideoInput']();
|
||||
},
|
||||
|
||||
_setVideoInput: function(deviceId) {
|
||||
UserSettingsStore.setLocalSetting('webrtc_videoinput', deviceId);
|
||||
Matrix.setMatrixCallVideoInput(deviceId);
|
||||
},
|
||||
|
|
|
@ -952,24 +952,21 @@ module.exports = React.createClass({
|
|||
let webcamDropdown = <p>{_t('No Webcams detected')}</p>;
|
||||
|
||||
const defaultOption = {
|
||||
deviceId: undefined,
|
||||
deviceId: 'default',
|
||||
label: _t('Default Device'),
|
||||
};
|
||||
|
||||
const audioInputs = this.state.mediaDevices.audioinput.slice(0);
|
||||
if (audioInputs.length > 0) {
|
||||
let defaultInput;
|
||||
if (!audioInputs.some((input) => input.deviceId === 'default')) {
|
||||
audioInputs.unshift(defaultOption);
|
||||
} else {
|
||||
defaultInput = 'default';
|
||||
}
|
||||
|
||||
microphoneDropdown = <div>
|
||||
<h4>Microphone</h4>
|
||||
<h4>{_t('Microphone')}</h4>
|
||||
<Dropdown
|
||||
className="mx_UserSettings_webRtcDevices_dropdown"
|
||||
value={this.state.activeAudioInput || defaultInput}
|
||||
value={this.state.activeAudioInput || 'default'}
|
||||
onOptionChange={this._setAudioInput}>
|
||||
{this._mapWebRtcDevicesToSpans(audioInputs)}
|
||||
</Dropdown>
|
||||
|
@ -978,18 +975,15 @@ module.exports = React.createClass({
|
|||
|
||||
const videoInputs = this.state.mediaDevices.videoinput.slice(0);
|
||||
if (videoInputs.length > 0) {
|
||||
let defaultInput;
|
||||
if (!videoInputs.some((input) => input.deviceId === 'default')) {
|
||||
videoInputs.unshift(defaultOption);
|
||||
} else {
|
||||
defaultInput = 'default';
|
||||
}
|
||||
|
||||
webcamDropdown = <div>
|
||||
<h4>Cameras</h4>
|
||||
<h4>{_t('Camera')}</h4>
|
||||
<Dropdown
|
||||
className="mx_UserSettings_webRtcDevices_dropdown"
|
||||
value={this.state.activeVideoInput || defaultInput}
|
||||
value={this.state.activeVideoInput || 'default'}
|
||||
onOptionChange={this._setVideoInput}>
|
||||
{this._mapWebRtcDevicesToSpans(videoInputs)}
|
||||
</Dropdown>
|
||||
|
|
|
@ -136,6 +136,8 @@
|
|||
"No media permissions": "No media permissions",
|
||||
"You may need to manually permit Riot to access your microphone/webcam": "You may need to manually permit Riot to access your microphone/webcam",
|
||||
"Default Device": "Default Device",
|
||||
"Microphone": "Microphone",
|
||||
"Cameras": "Cameras",
|
||||
"Advanced": "Advanced",
|
||||
"Algorithm": "Algorithm",
|
||||
"Always show message timestamps": "Always show message timestamps",
|
||||
|
|
Loading…
Reference in a new issue