Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.

Commit 68c814c

Browse files
committed
gphoto preview: stop preview earlier to free gphoto
Change-Id: Ifa23bc5eb80d47361a34e04b808a9e3a50807f99
1 parent a09f127 commit 68c814c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/js/core.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ const photoBooth = (function () {
246246
}
247247
};
248248

249-
api.stopVideoAndTakePic = function (data) {
249+
api.stopPreviewVideo = function () {
250250
if (api.stream) {
251251
const dataVideo = {
252252
play: 'false',
@@ -260,7 +260,6 @@ const photoBooth = (function () {
260260
const track = api.stream.getTracks()[0];
261261
track.stop();
262262
$('#video--view').hide();
263-
api.callTakePicApi(data);
264263
})
265264
.fail(function (xhr, status, result) {
266265
console.log('Could not stop webcam', result);
@@ -376,12 +375,7 @@ const photoBooth = (function () {
376375

377376
loader.css('background', config.colors.panel);
378377
loader.css('background-color', config.colors.panel);
379-
380-
if (config.preview_mode === 'gphoto' && api.stream) {
381-
api.stopVideoAndTakePic(data);
382-
} else {
383-
api.callTakePicApi(data);
384-
}
378+
api.callTakePicApi(data);
385379
};
386380

387381
api.callTakePicApi = function (data) {
@@ -672,6 +666,7 @@ const photoBooth = (function () {
672666
api.startCountdown = function (start, element, cb) {
673667
let count = 0;
674668
let current = start;
669+
let stop = start > 3 ? start - 2 : start;
675670

676671
function timerFunction() {
677672
element.text(current);
@@ -686,6 +681,9 @@ const photoBooth = (function () {
686681
cb();
687682
}
688683
count++;
684+
if (config.preview_mode === 'gphoto' && count === stop) {
685+
api.stopPreviewVideo();
686+
}
689687
}
690688
timerFunction();
691689
};

0 commit comments

Comments
 (0)