Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #257 from daserge/multiple-focus-2
Browse files Browse the repository at this point in the history
Added missing CHECK_PLAYING_TIMEOUT
  • Loading branch information
Vladimir Kotikov committed Jun 14, 2016
2 parents e65272a + eb31d2e commit 45ec98f
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/windows/BarcodeScannerProxy.js
Expand Up @@ -12,6 +12,8 @@ var urlutil = require('cordova/urlutil');

var CAMERA_STREAM_STATE_CHECK_RETRY_TIMEOUT = 200; // milliseconds
var OPERATION_IS_IN_PROGRESS = -2147024567;
var INITIAL_FOCUS_DELAY = 200; // milliseconds
var CHECK_PLAYING_TIMEOUT = 100; // milliseconds

/**
* List of supported barcode formats from ZXing library. Used to return format
Expand Down Expand Up @@ -322,16 +324,20 @@ module.exports = {
return result;
}

try {
return controller.focusControl.focusAsync();
} catch (e) {
// This happens on mutliple taps
if (e.number !== OPERATION_IS_IN_PROGRESS) {
console.error('focusAsync failed: ' + e);
return WinJS.Promise.wrapError(e);
// The delay prevents focus hang on slow devices
return WinJS.Promise.timeout(INITIAL_FOCUS_DELAY)
.then(function () {
try {
return controller.focusControl.focusAsync();
} catch (e) {
// This happens on mutliple taps
if (e.number !== OPERATION_IS_IN_PROGRESS) {
console.error('focusAsync failed: ' + e);
return WinJS.Promise.wrapError(e);
}
return result;
}
return result;
}
});
}

function setupFocus(focusControl) {
Expand Down

0 comments on commit 45ec98f

Please sign in to comment.