Skip to content

Commit 7b08b1b

Browse files
authored
Merge pull request #1076 from dpalou/MOBILE-839
Mobile 839
2 parents b10af08 + d49025a commit 7b08b1b

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed
-9.78 KB
Loading
-10.5 KB
Loading

www/core/components/emulator/services/mediacapture.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,19 @@ angular.module('mm.core.emulator')
5050
function captureMedia(type, successCallback, errorCallback, options) {
5151
options = options || {};
5252

53+
var loadingModal;
54+
5355
try {
5456
var scope = $rootScope.$new(),
55-
loadingModal = $mmUtil.showModalLoading(),
5657
facingMode = 'environment',
5758
mimetype,
5859
extension,
5960
quality = 0.92, // Image only.
6061
returnData = false, // Image only.
6162
isCaptureImage = false; // To identify if it's capturing an image using media capture plugin (instead of camera).
6263

64+
loadingModal = $mmUtil.showModalLoading();
65+
6366
if (type == 'captureimage') {
6467
isCaptureImage = true;
6568
type = 'image';
@@ -117,7 +120,7 @@ angular.module('mm.core.emulator')
117120
audio: !scope.isImage
118121
};
119122

120-
navigator.mediaDevices.getUserMedia(constraints).then(function(localMediaStream) {
123+
return navigator.mediaDevices.getUserMedia(constraints).then(function(localMediaStream) {
121124
var streamVideo,
122125
previewMedia,
123126
canvas,
@@ -159,17 +162,37 @@ angular.module('mm.core.emulator')
159162
}
160163

161164
if (scope.isImage || scope.isVideo) {
165+
var hasLoaded = false,
166+
waitTimeout;
167+
162168
// Set the stream as the source of the video.
163169
streamVideo = modal.modalEl.querySelector('video.mm-webcam-stream');
164170
streamVideo.src = $window.URL.createObjectURL(localMediaStream);
165171

166172
// Stream ready, show modal.
167173
streamVideo.onloadedmetadata = function() {
174+
if (hasLoaded) {
175+
// Already loaded or timeout triggered, stop.
176+
return;
177+
}
178+
179+
hasLoaded = true;
180+
$timeout.cancel(waitTimeout);
168181
loadingModal.dismiss();
169182
modal.show();
170183
scope.readyToCapture = true;
171184
streamVideo.onloadedmetadata = null;
172185
};
186+
187+
// If stream isn't ready in a while, show error.
188+
waitTimeout = $timeout(function() {
189+
if (!hasLoaded) {
190+
// Show error.
191+
hasLoaded = true;
192+
loadingModal.dismiss();
193+
errorCallback && errorCallback({code: -1, message: 'Cannot connect to webcam.'});
194+
}
195+
}, 10000);
173196
} else {
174197
// No need to wait to show the modal.
175198
loadingModal.dismiss();
@@ -304,10 +327,14 @@ angular.module('mm.core.emulator')
304327
scope.$on('$destroy', function() {
305328
scope.modal.remove();
306329
});
307-
}).catch(errorCallback);
308-
}, errorCallback);
330+
});
331+
}).catch(function(err) {
332+
loadingModal && loadingModal.dismiss();
333+
errorCallback && errorCallback(err);
334+
});
309335
} catch(ex) {
310-
errorCallback(ex.toString());
336+
loadingModal && loadingModal.dismiss();
337+
errorCallback && errorCallback(ex.toString());
311338
}
312339
}
313340

www/core/components/login/main.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,8 @@ angular.module('mm.core.login', [])
376376
url = url.replace(ssoScheme, '');
377377

378378
// Some platforms like Windows add a slash at the end. Remove it.
379-
if (url.slice(-1) == '/') {
380-
url = url.substring(0, url.length - 1);
381-
}
382-
383379
// Some sites add a # at the end of the URL. If it's there, remove it.
384-
if (url.slice(-1) == '#') {
385-
url = url.substring(0, url.length - 1);
386-
}
380+
url = url.replace(/\/?#?\/?$/, '');
387381

388382
// Decode from base64.
389383
try {

www/core/lib/util.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ angular.module('mm.core')
296296
// It's a desktop app, send an event so the file is opened. It has to be done with an event
297297
// because opening the file from here (renderer process) doesn't focus the opened app.
298298
require('electron').ipcRenderer.send('openItem', path);
299+
deferred.resolve();
299300
} else if (window.plugins) {
300301
var extension = $mmFS.getFileExtension(path),
301302
mimetype = $mmFS.getMimeType(extension);

www/core/scss/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,3 +1655,7 @@ h2.invert {
16551655
border-color: transparent;
16561656
background: none;
16571657
}
1658+
1659+
::-webkit-calendar-picker-indicator, ::-webkit-inner-spin-button, ::-webkit-clear-button {
1660+
display: none;
1661+
}

0 commit comments

Comments
 (0)