Pārlūkot izejas kodu

Merge pull request #645 from tsareg/master

Added ability to change output audio device through settings
j8
hristoterezov 9 gadus atpakaļ
vecāks
revīzija
49e60a8b4f

+ 11
- 0
conference.js Parādīt failu

@@ -1133,6 +1133,17 @@ export default {
1133 1133
             }
1134 1134
         );
1135 1135
 
1136
+        APP.UI.addListener(
1137
+            UIEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
1138
+            (audioOutputDeviceId) => {
1139
+                APP.settings.setAudioOutputDeviceId(audioOutputDeviceId)
1140
+                    .then(() => console.log('changed audio output device'))
1141
+                    .catch((err) => {
1142
+                        console.error('failed to set audio output device', err);
1143
+                    });
1144
+            }
1145
+        );
1146
+
1136 1147
         APP.UI.addListener(
1137 1148
             UIEvents.TOGGLE_SCREENSHARING, this.toggleScreenSharing.bind(this)
1138 1149
         );

+ 4
- 0
index.html Parādīt failu

@@ -258,6 +258,10 @@
258 258
                     <span data-i18n="settings.selectMic"></span>
259 259
                     <select id="selectMic"></select>
260 260
                 </label>
261
+                <label className="devicesOptionsLabel">
262
+                    <span data-i18n="settings.selectAudioOutput"></span>
263
+                    <select id="selectAudioOutput"></select>
264
+                </label>
261 265
             </div>
262 266
             <div id="followMeOptions">
263 267
                 <label class = "followMeLabel">

+ 1
- 0
lang/main.json Parādīt failu

@@ -89,6 +89,7 @@
89 89
         "startVideoMuted": "Start without video",
90 90
         "selectCamera": "Select camera",
91 91
         "selectMic": "Select microphone",
92
+        "selectAudioOutput": "Select audio output",
92 93
         "followMe": "Enable follow me"
93 94
     },
94 95
     "videothumbnail":

+ 32
- 5
modules/UI/side_pannels/settings/SettingsMenu.js Parādīt failu

@@ -1,4 +1,4 @@
1
-/* global APP, $ */
1
+/* global APP, $, JitsiMeetJS */
2 2
 import UIUtil from "../../util/UIUtil";
3 3
 import UIEvents from "../../../../service/UI/UIEvents";
4 4
 import languages from "../../../../service/translation/languages";
@@ -124,6 +124,13 @@ export default {
124 124
                 emitter.emit(UIEvents.AUDIO_DEVICE_CHANGED, micDeviceId);
125 125
             }
126 126
         });
127
+        $('#selectAudioOutput').change(function () {
128
+            let audioOutputDeviceId = $(this).val();
129
+            if (audioOutputDeviceId !== Settings.getAudioOutputDeviceId()) {
130
+                emitter.emit(UIEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
131
+                    audioOutputDeviceId);
132
+            }
133
+        });
127 134
     },
128 135
 
129 136
     /**
@@ -186,21 +193,41 @@ export default {
186 193
      * @param {{ deviceId, label, kind }[]} devices list of available devices
187 194
      */
188 195
     changeDevicesList (devices) {
196
+        let $devicesOptions =  $('#devicesOptions');
197
+
189 198
         if (!devices.length) {
190
-            $('#devicesOptions').hide();
199
+            $devicesOptions.hide();
191 200
             return;
192 201
         }
193 202
 
203
+        let $selectCamera= $('#selectCamera'),
204
+            $selectMic = $('#selectMic'),
205
+            $selectAudioOutput = $('#selectAudioOutput'),
206
+            $selectAudioOutputParent = $selectAudioOutput.parent();
207
+
194 208
         let audio = devices.filter(device => device.kind === 'audioinput');
195 209
         let video = devices.filter(device => device.kind === 'videoinput');
210
+        let audioOutput = devices
211
+            .filter(device => device.kind === 'audiooutput');
196 212
 
197
-        $('#selectCamera').html(
213
+        $selectCamera.html(
198 214
             generateDevicesOptions(video, Settings.getCameraDeviceId())
199 215
         );
200
-        $('#selectMic').html(
216
+        $selectMic.html(
201 217
             generateDevicesOptions(audio, Settings.getMicDeviceId())
202 218
         );
203 219
 
204
-        $('#devicesOptions').show();
220
+        if (audioOutput.length &&
221
+            JitsiMeetJS.isDeviceChangeAvailable('output')) {
222
+            $selectAudioOutput.html(
223
+                generateDevicesOptions(audioOutput,
224
+                    Settings.getAudioOutputDeviceId()));
225
+
226
+            $selectAudioOutputParent.show();
227
+        } else {
228
+            $selectAudioOutputParent.hide();
229
+        }
230
+
231
+        $devicesOptions.show();
205 232
     }
206 233
 };

+ 32
- 0
modules/settings/Settings.js Parādīt failu

@@ -1,3 +1,5 @@
1
+/* global JitsiMeetJS */
2
+
1 3
 import UIUtil from '../UI/util/UIUtil';
2 4
 
3 5
 let email = '';
@@ -40,6 +42,17 @@ if (supportsLocalStorage()) {
40 42
     welcomePageDisabled = JSON.parse(
41 43
         window.localStorage.welcomePageDisabled || false
42 44
     );
45
+
46
+    var audioOutputDeviceId = window.localStorage.audioOutputDeviceId;
47
+
48
+    if (typeof audioOutputDeviceId !== 'undefined' &&
49
+        audioOutputDeviceId !== JitsiMeetJS.getAudioOutputDevice()) {
50
+        JitsiMeetJS.setAudioOutputDevice(
51
+            window.localStorage.audioOutputDeviceId).catch((ex) => {
52
+                console.error('failed to set audio output device from local ' +
53
+                    'storage', ex);
54
+            });
55
+    }
43 56
 } else {
44 57
     console.log("local storage is not supported");
45 58
 }
@@ -142,6 +155,25 @@ export default {
142 155
         window.localStorage.micDeviceId = newId;
143 156
     },
144 157
 
158
+    /**
159
+     * Get device id of the audio output device which is currently in use.
160
+     * Empty string stands for default device.
161
+     * @returns {String}
162
+     */
163
+    getAudioOutputDeviceId: function () {
164
+        return JitsiMeetJS.getAudioOutputDevice();
165
+    },
166
+    /**
167
+     * Set device id of the audio output device which is currently in use.
168
+     * Empty string stands for default device.
169
+     * @param {string} newId new audio output device id
170
+     * @returns {Promise}
171
+     */
172
+    setAudioOutputDeviceId: function (newId = '') {
173
+        return JitsiMeetJS.setAudioOutputDevice(newId)
174
+            .then(() => window.localStorage.audioOutputDeviceId = newId);
175
+    },
176
+
145 177
     /**
146 178
      * Check if welcome page is enabled or not.
147 179
      * @returns {boolean}

+ 1
- 0
service/UI/UIEvents.js Parādīt failu

@@ -67,6 +67,7 @@ export default {
67 67
     SUBJECT_CHANGED: "UI.subject_changed",
68 68
     VIDEO_DEVICE_CHANGED: "UI.video_device_changed",
69 69
     AUDIO_DEVICE_CHANGED: "UI.audio_device_changed",
70
+    AUDIO_OUTPUT_DEVICE_CHANGED: "UI.audio_output_device_changed",
70 71
     /**
71 72
      * Notifies interested listeners that the follow-me feature is enabled or
72 73
      * disabled.

Notiek ielāde…
Atcelt
Saglabāt