浏览代码

style(JitsiLocalTrack):Rename method & add comment

dev1
Hristo Terezov 6 年前
父节点
当前提交
1bfc96a287
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6
    3
      modules/RTC/JitsiLocalTrack.js

+ 6
- 3
modules/RTC/JitsiLocalTrack.js 查看文件

@@ -147,7 +147,7 @@ export default class JitsiLocalTrack extends JitsiTrack {
147 147
          */
148 148
         this._noDataFromSourceTimeout = null;
149 149
 
150
-        this._onDeviceListChanged = devices => {
150
+        this._onDeviceListWillChange = devices => {
151 151
             this._setRealDeviceIdFromDeviceList(devices);
152 152
 
153 153
             // Mark track as ended for those browsers that do not support
@@ -171,7 +171,7 @@ export default class JitsiLocalTrack extends JitsiTrack {
171 171
                 this._onAudioOutputDeviceChanged);
172 172
         }
173 173
 
174
-        RTCUtils.addListener(RTCEvents.DEVICE_LIST_WILL_CHANGE, this._onDeviceListChanged);
174
+        RTCUtils.addListener(RTCEvents.DEVICE_LIST_WILL_CHANGE, this._onDeviceListWillChange);
175 175
 
176 176
         this._initNoDataFromSourceHandlers();
177 177
     }
@@ -269,6 +269,9 @@ export default class JitsiLocalTrack extends JitsiTrack {
269 269
         let device = devices.find(d => d.kind === kind && d.label === track.label);
270 270
 
271 271
         if (!device && this._realDeviceId === 'default') { // the default device has been changed.
272
+            // If the default device was 'A' and the default device is changed to 'B' the label for the track will
273
+            // remain 'Default - A' but the label for the device in the device list will be updated to 'A'. That's
274
+            // why in order to match it we need to remove the 'Default - ' part.
272 275
             const label = (track.label || '').replace('Default - ', '');
273 276
 
274 277
             device = devices.find(d => d.kind === kind && d.label === label);
@@ -525,7 +528,7 @@ export default class JitsiLocalTrack extends JitsiTrack {
525 528
             this.detach();
526 529
         }
527 530
 
528
-        RTCUtils.removeListener(RTCEvents.DEVICE_LIST_WILL_CHANGE, this._onDeviceListChanged);
531
+        RTCUtils.removeListener(RTCEvents.DEVICE_LIST_WILL_CHANGE, this._onDeviceListWillChange);
529 532
 
530 533
         if (this._onAudioOutputDeviceChanged) {
531 534
             RTCUtils.removeListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,

正在加载...
取消
保存