diff --git a/src/CallMediaHandler.js b/src/CallMediaHandler.js index 45ca5dc30d..780df60846 100644 --- a/src/CallMediaHandler.js +++ b/src/CallMediaHandler.js @@ -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); }, diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index b8567fc180..99b02b59f9 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -952,24 +952,21 @@ module.exports = React.createClass({ let webcamDropdown =

{_t('No Webcams detected')}

; 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 =
-

Microphone

+

{_t('Microphone')}

{this._mapWebRtcDevicesToSpans(audioInputs)} @@ -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 =
-

Cameras

+

{_t('Camera')}

{this._mapWebRtcDevicesToSpans(videoInputs)} diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 3a8752fd5d..b9ac79d362 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -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",