Преглед на файлове

Merge pull request #645 from tsareg/master

Added ability to change output audio device through settings
j8
hristoterezov преди 9 години
родител
ревизия
49e60a8b4f
променени са 6 файла, в които са добавени 81 реда и са изтрити 5 реда
  1. 11
    0
      conference.js
  2. 4
    0
      index.html
  3. 1
    0
      lang/main.json
  4. 32
    5
      modules/UI/side_pannels/settings/SettingsMenu.js
  5. 32
    0
      modules/settings/Settings.js
  6. 1
    0
      service/UI/UIEvents.js

+ 11
- 0
conference.js Целия файл

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
         APP.UI.addListener(
1147
         APP.UI.addListener(
1137
             UIEvents.TOGGLE_SCREENSHARING, this.toggleScreenSharing.bind(this)
1148
             UIEvents.TOGGLE_SCREENSHARING, this.toggleScreenSharing.bind(this)
1138
         );
1149
         );

+ 4
- 0
index.html Целия файл

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

+ 1
- 0
lang/main.json Целия файл

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

+ 32
- 5
modules/UI/side_pannels/settings/SettingsMenu.js Целия файл

1
-/* global APP, $ */
1
+/* global APP, $, JitsiMeetJS */
2
 import UIUtil from "../../util/UIUtil";
2
 import UIUtil from "../../util/UIUtil";
3
 import UIEvents from "../../../../service/UI/UIEvents";
3
 import UIEvents from "../../../../service/UI/UIEvents";
4
 import languages from "../../../../service/translation/languages";
4
 import languages from "../../../../service/translation/languages";
124
                 emitter.emit(UIEvents.AUDIO_DEVICE_CHANGED, micDeviceId);
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
      * @param {{ deviceId, label, kind }[]} devices list of available devices
193
      * @param {{ deviceId, label, kind }[]} devices list of available devices
187
      */
194
      */
188
     changeDevicesList (devices) {
195
     changeDevicesList (devices) {
196
+        let $devicesOptions =  $('#devicesOptions');
197
+
189
         if (!devices.length) {
198
         if (!devices.length) {
190
-            $('#devicesOptions').hide();
199
+            $devicesOptions.hide();
191
             return;
200
             return;
192
         }
201
         }
193
 
202
 
203
+        let $selectCamera= $('#selectCamera'),
204
+            $selectMic = $('#selectMic'),
205
+            $selectAudioOutput = $('#selectAudioOutput'),
206
+            $selectAudioOutputParent = $selectAudioOutput.parent();
207
+
194
         let audio = devices.filter(device => device.kind === 'audioinput');
208
         let audio = devices.filter(device => device.kind === 'audioinput');
195
         let video = devices.filter(device => device.kind === 'videoinput');
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
             generateDevicesOptions(video, Settings.getCameraDeviceId())
214
             generateDevicesOptions(video, Settings.getCameraDeviceId())
199
         );
215
         );
200
-        $('#selectMic').html(
216
+        $selectMic.html(
201
             generateDevicesOptions(audio, Settings.getMicDeviceId())
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 Целия файл

1
+/* global JitsiMeetJS */
2
+
1
 import UIUtil from '../UI/util/UIUtil';
3
 import UIUtil from '../UI/util/UIUtil';
2
 
4
 
3
 let email = '';
5
 let email = '';
40
     welcomePageDisabled = JSON.parse(
42
     welcomePageDisabled = JSON.parse(
41
         window.localStorage.welcomePageDisabled || false
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
 } else {
56
 } else {
44
     console.log("local storage is not supported");
57
     console.log("local storage is not supported");
45
 }
58
 }
142
         window.localStorage.micDeviceId = newId;
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
      * Check if welcome page is enabled or not.
178
      * Check if welcome page is enabled or not.
147
      * @returns {boolean}
179
      * @returns {boolean}

+ 1
- 0
service/UI/UIEvents.js Целия файл

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

Loading…
Отказ
Запис