Browse Source

fix(device_selection_popup): On Firefox

j8
hristoterezov 7 years ago
parent
commit
9d953f18c2

+ 4
- 2
modules/transport/Transport.js View File

233
 
233
 
234
         return new Promise((resolve, reject) => {
234
         return new Promise((resolve, reject) => {
235
             this._responseHandlers.set(id, ({ error, result }) => {
235
             this._responseHandlers.set(id, ({ error, result }) => {
236
-                if (result) {
236
+                if (typeof result !== 'undefined') {
237
                     resolve(result);
237
                     resolve(result);
238
-                } else if (error) {
238
+
239
+                // eslint-disable-next-line no-negated-condition
240
+                } else if (typeof error !== 'undefined') {
239
                     reject(error);
241
                     reject(error);
240
                 } else { // no response
242
                 } else { // no response
241
                     reject(new Error('Unexpected response format!'));
243
                     reject(new Error('Unexpected response format!'));

+ 9
- 4
react/features/device-selection/DeviceSelectionPopup.js View File

61
             disableAudioInputChange: true,
61
             disableAudioInputChange: true,
62
             disableDeviceChange: true,
62
             disableDeviceChange: true,
63
             hasAudioPermission: JitsiMeetJS.mediaDevices
63
             hasAudioPermission: JitsiMeetJS.mediaDevices
64
-                .isDevicePermissionGranted('audio'),
64
+                .isDevicePermissionGranted.bind(null, 'audio'),
65
             hasVideoPermission: JitsiMeetJS.mediaDevices
65
             hasVideoPermission: JitsiMeetJS.mediaDevices
66
-                .isDevicePermissionGranted('video'),
66
+                .isDevicePermissionGranted.bind(null, 'video'),
67
             hideAudioInputPreview: !JitsiMeetJS.isCollectingLocalStats(),
67
             hideAudioInputPreview: !JitsiMeetJS.isCollectingLocalStats(),
68
             hideAudioOutputSelect: true
68
             hideAudioOutputSelect: true
69
         };
69
         };
139
             this._getAvailableDevices(),
139
             this._getAvailableDevices(),
140
             this._isDeviceListAvailable(),
140
             this._isDeviceListAvailable(),
141
             this._isDeviceChangeAvailable(),
141
             this._isDeviceChangeAvailable(),
142
+            this._isDeviceChangeAvailable('output'),
142
             this._getCurrentDevices(),
143
             this._getCurrentDevices(),
143
             this._isMultipleAudioInputSupported()
144
             this._isMultipleAudioInputSupported()
144
         ]).then(([
145
         ]).then(([
145
             availableDevices,
146
             availableDevices,
146
             listAvailable,
147
             listAvailable,
147
             changeAvailable,
148
             changeAvailable,
149
+            changeOutputAvailable,
148
             currentDevices,
150
             currentDevices,
149
             multiAudioInputSupported
151
             multiAudioInputSupported
150
         ]) => {
152
         ]) => {
155
                 currentVideoInputId: currentDevices.videoInput,
157
                 currentVideoInputId: currentDevices.videoInput,
156
                 disableAudioInputChange: !multiAudioInputSupported,
158
                 disableAudioInputChange: !multiAudioInputSupported,
157
                 disableDeviceChange: !listAvailable || !changeAvailable,
159
                 disableDeviceChange: !listAvailable || !changeAvailable,
158
-                hideAudioOutputSelect: !changeAvailable
160
+                hideAudioOutputSelect: !changeOutputAvailable
159
             });
161
             });
160
         });
162
         });
161
     }
163
     }
164
      * Returns Promise that resolves with true if the device change is available
166
      * Returns Promise that resolves with true if the device change is available
165
      * and with false if not.
167
      * and with false if not.
166
      *
168
      *
169
+     * @param {string} [deviceType] - Values - 'output', 'input' or undefined.
170
+     * Default - 'input'.
167
      * @returns {Promise}
171
      * @returns {Promise}
168
      */
172
      */
169
-    _isDeviceChangeAvailable() {
173
+    _isDeviceChangeAvailable(deviceType) {
170
         return this._transport.sendRequest({
174
         return this._transport.sendRequest({
175
+            deviceType,
171
             type: 'devices',
176
             type: 'devices',
172
             name: 'isDeviceChangeAvailable'
177
             name: 'isDeviceChangeAvailable'
173
         }).catch(e => {
178
         }).catch(e => {

+ 4
- 3
react/features/device-selection/actions.js View File

51
                     disableDeviceChange: !isDeviceListAvailable
51
                     disableDeviceChange: !isDeviceListAvailable
52
                         || !JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(),
52
                         || !JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(),
53
                     hasAudioPermission: JitsiMeetJS.mediaDevices
53
                     hasAudioPermission: JitsiMeetJS.mediaDevices
54
-                        .isDevicePermissionGranted('audio'),
54
+                        .isDevicePermissionGranted.bind(null, 'audio'),
55
                     hasVideoPermission: JitsiMeetJS.mediaDevices
55
                     hasVideoPermission: JitsiMeetJS.mediaDevices
56
-                        .isDevicePermissionGranted('video'),
56
+                        .isDevicePermissionGranted.bind(null, 'video'),
57
                     hideAudioInputPreview:
57
                     hideAudioInputPreview:
58
                         !JitsiMeetJS.isCollectingLocalStats(),
58
                         !JitsiMeetJS.isCollectingLocalStats(),
59
                     hideAudioOutputSelect: !JitsiMeetJS.mediaDevices
59
                     hideAudioOutputSelect: !JitsiMeetJS.mediaDevices
144
             break;
144
             break;
145
         case 'isDeviceChangeAvailable':
145
         case 'isDeviceChangeAvailable':
146
             responseCallback(
146
             responseCallback(
147
-                JitsiMeetJS.mediaDevices.isDeviceChangeAvailable());
147
+                JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(
148
+                    request.deviceType));
148
             break;
149
             break;
149
         case 'isMultipleAudioInputSupported':
150
         case 'isMultipleAudioInputSupported':
150
             responseCallback(JitsiMeetJS.isMultipleAudioInputSupported());
151
             responseCallback(JitsiMeetJS.isMultipleAudioInputSupported());

+ 6
- 4
react/features/device-selection/components/DeviceSelectionDialog.js View File

66
         dispatch: React.PropTypes.func,
66
         dispatch: React.PropTypes.func,
67
 
67
 
68
         /**
68
         /**
69
-         * Whether or not a new audio input source can be selected.
69
+         * Function that checks whether or not a new audio input source can be
70
+         * selected.
70
          */
71
          */
71
-        hasAudioPermission: React.PropTypes.bool,
72
+        hasAudioPermission: React.PropTypes.func,
72
 
73
 
73
         /**
74
         /**
74
-         * Whether or not a new video input sources can be selected.
75
+         * Function that checks whether or not a new video input sources can be
76
+         * selected.
75
          */
77
          */
76
-        hasVideoPermission: React.PropTypes.bool,
78
+        hasVideoPermission: React.PropTypes.func,
77
 
79
 
78
         /**
80
         /**
79
          * If true, the audio meter will not display. Necessary for browsers or
81
          * If true, the audio meter will not display. Necessary for browsers or

+ 10
- 8
react/features/device-selection/components/DeviceSelectionDialogBase.js View File

71
         disableDeviceChange: React.PropTypes.bool,
71
         disableDeviceChange: React.PropTypes.bool,
72
 
72
 
73
         /**
73
         /**
74
-         * Whether or not a new audio input source can be selected.
74
+         * Function that checks whether or not a new audio input source can be
75
+         * selected.
75
          */
76
          */
76
-        hasAudioPermission: React.PropTypes.bool,
77
+        hasAudioPermission: React.PropTypes.func,
77
 
78
 
78
         /**
79
         /**
79
-         * Whether or not a new video input sources can be selected.
80
+         * Function that checks whether or not a new video input sources can be
81
+         * selected.
80
          */
82
          */
81
-        hasVideoPermission: React.PropTypes.bool,
83
+        hasVideoPermission: React.PropTypes.func,
82
 
84
 
83
         /**
85
         /**
84
          * If true, the audio meter will not display. Necessary for browsers or
86
          * If true, the audio meter will not display. Necessary for browsers or
381
         const configurations = [
383
         const configurations = [
382
             {
384
             {
383
                 devices: availableDevices.videoInput,
385
                 devices: availableDevices.videoInput,
384
-                hasPermission: this.props.hasVideoPermission,
386
+                hasPermission: this.props.hasVideoPermission(),
385
                 icon: 'icon-camera',
387
                 icon: 'icon-camera',
386
                 isDisabled: this.props.disableDeviceChange,
388
                 isDisabled: this.props.disableDeviceChange,
387
                 key: 'videoInput',
389
                 key: 'videoInput',
391
             },
393
             },
392
             {
394
             {
393
                 devices: availableDevices.audioInput,
395
                 devices: availableDevices.audioInput,
394
-                hasPermission: this.props.hasAudioPermission,
396
+                hasPermission: this.props.hasAudioPermission(),
395
                 icon: 'icon-microphone',
397
                 icon: 'icon-microphone',
396
                 isDisabled: this.props.disableAudioInputChange
398
                 isDisabled: this.props.disableAudioInputChange
397
                     || this.props.disableDeviceChange,
399
                     || this.props.disableDeviceChange,
405
         if (!this.props.hideAudioOutputSelect) {
407
         if (!this.props.hideAudioOutputSelect) {
406
             configurations.push({
408
             configurations.push({
407
                 devices: availableDevices.audioOutput,
409
                 devices: availableDevices.audioOutput,
408
-                hasPermission: this.props.hasAudioPermission
409
-                    || this.props.hasVideoPermission,
410
+                hasPermission: this.props.hasAudioPermission()
411
+                    || this.props.hasVideoPermission(),
410
                 icon: 'icon-volume',
412
                 icon: 'icon-volume',
411
                 isDisabled: this.props.disableDeviceChange,
413
                 isDisabled: this.props.disableDeviceChange,
412
                 key: 'audioOutput',
414
                 key: 'audioOutput',

+ 5
- 1
react/features/device-selection/popup.js View File

3
 
3
 
4
 import DeviceSelectionPopup from './DeviceSelectionPopup';
4
 import DeviceSelectionPopup from './DeviceSelectionPopup';
5
 
5
 
6
+declare var JitsiMeetJS: Object;
7
+
6
 let deviceSelectionPopup;
8
 let deviceSelectionPopup;
7
 
9
 
8
 window.init = function(i18next) {
10
 window.init = function(i18next) {
9
-    deviceSelectionPopup = new DeviceSelectionPopup(i18next);
11
+    JitsiMeetJS.init({}).then(() => {
12
+        deviceSelectionPopup = new DeviceSelectionPopup(i18next);
13
+    });
10
 };
14
 };
11
 
15
 
12
 window.addEventListener('beforeunload', () =>
16
 window.addEventListener('beforeunload', () =>

+ 2
- 2
static/deviceSelectionPopup.html View File

8
     <script><!--#include virtual="/interface_config.js" --></script>
8
     <script><!--#include virtual="/interface_config.js" --></script>
9
     <script>
9
     <script>
10
         window.config = {};
10
         window.config = {};
11
-        window.JitsiMeetJS = window.opener.window.JitsiMeetJS;
12
     </script>
11
     </script>
13
-    <script src="libs/device_selection_popup_bundle.min.js"></script>
12
+    <script src="libs/lib-jitsi-meet.min.js?v=139"></script>
13
+    <script src="libs/device_selection_popup_bundle.min.js?v=1"></script>
14
     <link rel="stylesheet" href="css/all.css">
14
     <link rel="stylesheet" href="css/all.css">
15
   </head>
15
   </head>
16
   <body>
16
   <body>

Loading…
Cancel
Save