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,9 +233,11 @@ export default class Transport {
233 233
 
234 234
         return new Promise((resolve, reject) => {
235 235
             this._responseHandlers.set(id, ({ error, result }) => {
236
-                if (result) {
236
+                if (typeof result !== 'undefined') {
237 237
                     resolve(result);
238
-                } else if (error) {
238
+
239
+                // eslint-disable-next-line no-negated-condition
240
+                } else if (typeof error !== 'undefined') {
239 241
                     reject(error);
240 242
                 } else { // no response
241 243
                     reject(new Error('Unexpected response format!'));

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

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

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

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

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

@@ -66,14 +66,16 @@ class DeviceSelectionDialog extends Component {
66 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 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,14 +71,16 @@ class DeviceSelectionDialogBase extends Component {
71 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 86
          * If true, the audio meter will not display. Necessary for browsers or
@@ -381,7 +383,7 @@ class DeviceSelectionDialogBase extends Component {
381 383
         const configurations = [
382 384
             {
383 385
                 devices: availableDevices.videoInput,
384
-                hasPermission: this.props.hasVideoPermission,
386
+                hasPermission: this.props.hasVideoPermission(),
385 387
                 icon: 'icon-camera',
386 388
                 isDisabled: this.props.disableDeviceChange,
387 389
                 key: 'videoInput',
@@ -391,7 +393,7 @@ class DeviceSelectionDialogBase extends Component {
391 393
             },
392 394
             {
393 395
                 devices: availableDevices.audioInput,
394
-                hasPermission: this.props.hasAudioPermission,
396
+                hasPermission: this.props.hasAudioPermission(),
395 397
                 icon: 'icon-microphone',
396 398
                 isDisabled: this.props.disableAudioInputChange
397 399
                     || this.props.disableDeviceChange,
@@ -405,8 +407,8 @@ class DeviceSelectionDialogBase extends Component {
405 407
         if (!this.props.hideAudioOutputSelect) {
406 408
             configurations.push({
407 409
                 devices: availableDevices.audioOutput,
408
-                hasPermission: this.props.hasAudioPermission
409
-                    || this.props.hasVideoPermission,
410
+                hasPermission: this.props.hasAudioPermission()
411
+                    || this.props.hasVideoPermission(),
410 412
                 icon: 'icon-volume',
411 413
                 isDisabled: this.props.disableDeviceChange,
412 414
                 key: 'audioOutput',

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

@@ -3,10 +3,14 @@ import 'aui-experimental-css';
3 3
 
4 4
 import DeviceSelectionPopup from './DeviceSelectionPopup';
5 5
 
6
+declare var JitsiMeetJS: Object;
7
+
6 8
 let deviceSelectionPopup;
7 9
 
8 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 16
 window.addEventListener('beforeunload', () =>

+ 2
- 2
static/deviceSelectionPopup.html View File

@@ -8,9 +8,9 @@
8 8
     <script><!--#include virtual="/interface_config.js" --></script>
9 9
     <script>
10 10
         window.config = {};
11
-        window.JitsiMeetJS = window.opener.window.JitsiMeetJS;
12 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 14
     <link rel="stylesheet" href="css/all.css">
15 15
   </head>
16 16
   <body>

Loading…
Cancel
Save