Browse Source

fix(gum): handle NotAllowedError (#646)

This is a two part fix:
- In the new gum flow, this.getUserMedia supports promises
  and rejections were not getting caught. So change
  _newGetUserMediaWithConstraints to be promise based instead
  of callback.
- The error name returned from blocked device permissions is
  NotAllowedError, as adapter shims PermissionDeniedError
  to be NotAllowedError.
dev1
virtuacoplenny 7 years ago
parent
commit
fb286a51a1
2 changed files with 5 additions and 5 deletions
  1. 1
    0
      JitsiTrackError.js
  2. 4
    5
      modules/RTC/RTCUtils.js

+ 1
- 0
JitsiTrackError.js View File

74
         };
74
         };
75
 
75
 
76
         switch (error.name) {
76
         switch (error.name) {
77
+        case 'NotAllowedError':
77
         case 'PermissionDeniedError':
78
         case 'PermissionDeniedError':
78
         case 'SecurityError':
79
         case 'SecurityError':
79
             this.name = JitsiTrackErrors.PERMISSION_DENIED;
80
             this.name = JitsiTrackErrors.PERMISSION_DENIED;

+ 4
- 5
modules/RTC/RTCUtils.js View File

1190
     _newGetUserMediaWithConstraints(umDevices, constraints = {}) {
1190
     _newGetUserMediaWithConstraints(umDevices, constraints = {}) {
1191
         return new Promise((resolve, reject) => {
1191
         return new Promise((resolve, reject) => {
1192
             try {
1192
             try {
1193
-                this.getUserMedia(
1194
-                    constraints,
1195
-                    stream => {
1193
+                this.getUserMedia(constraints)
1194
+                    .then(stream => {
1196
                         logger.log('onUserMediaSuccess');
1195
                         logger.log('onUserMediaSuccess');
1197
 
1196
 
1198
                         // TODO(brian): Is this call needed? Why is this
1197
                         // TODO(brian): Is this call needed? Why is this
1201
                         setAvailableDevices(umDevices, stream);
1200
                         setAvailableDevices(umDevices, stream);
1202
 
1201
 
1203
                         resolve(stream);
1202
                         resolve(stream);
1204
-                    },
1205
-                    error => {
1203
+                    })
1204
+                    .catch(error => {
1206
                         logger.warn('Failed to get access to local media. '
1205
                         logger.warn('Failed to get access to local media. '
1207
                             + ` ${error} ${constraints} `);
1206
                             + ` ${error} ${constraints} `);
1208
 
1207
 

Loading…
Cancel
Save