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

Commit

Permalink
gphoto preview: stop preview earlier to free gphoto
Browse files Browse the repository at this point in the history
Change-Id: Ifa23bc5eb80d47361a34e04b808a9e3a50807f99
  • Loading branch information
andi34 committed Nov 15, 2020
1 parent a09f127 commit 9a08f9a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const photoBooth = (function () {
}
};

api.stopVideoAndTakePic = function (data) {
api.stopPreviewVideo = function () {
if (api.stream) {
const dataVideo = {
play: 'false',
Expand All @@ -260,7 +260,6 @@ const photoBooth = (function () {
const track = api.stream.getTracks()[0];
track.stop();
$('#video--view').hide();
api.callTakePicApi(data);
})
.fail(function (xhr, status, result) {
console.log('Could not stop webcam', result);
Expand Down Expand Up @@ -376,12 +375,7 @@ const photoBooth = (function () {

loader.css('background', config.colors.panel);
loader.css('background-color', config.colors.panel);

if (config.preview_mode === 'gphoto' && api.stream) {
api.stopVideoAndTakePic(data);
} else {
api.callTakePicApi(data);
}
api.callTakePicApi(data);
};

api.callTakePicApi = function (data) {
Expand Down Expand Up @@ -672,6 +666,7 @@ const photoBooth = (function () {
api.startCountdown = function (start, element, cb) {
let count = 0;
let current = start;
const stop = start > 3 ? start - 2 : start;

function timerFunction() {
element.text(current);
Expand All @@ -686,6 +681,9 @@ const photoBooth = (function () {
cb();
}
count++;
if (config.preview_mode === 'gphoto' && count === stop) {
api.stopPreviewVideo();
}
}
timerFunction();
};
Expand Down

0 comments on commit 9a08f9a

Please sign in to comment.