diff --git a/config/config.inc.php b/config/config.inc.php index 6b9577d93..b40af776d 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -28,6 +28,8 @@ // control time in seconds until Photobooth reloads automatically $config['picture']['time_to_live'] = '90'; $config['picture']['preview_before_processing'] = false; +$config['picture']['retry_on_error'] = '0'; +$config['picture']['retry_timeout'] = '2'; $config['delete']['no_request'] = false; $config['database']['enabled'] = true; $config['database']['file'] = 'db'; diff --git a/lib/configsetup.inc.php b/lib/configsetup.inc.php index a55380cd8..f80a9caa7 100644 --- a/lib/configsetup.inc.php +++ b/lib/configsetup.inc.php @@ -227,6 +227,28 @@ 'name' => 'picture[preview_before_processing]', 'value' => $config['picture']['preview_before_processing'], ], + 'picture_retry_on_error' => [ + 'view' => 'expert', + 'type' => 'range', + 'placeholder' => $defaultConfig['picture']['retry_on_error'], + 'name' => 'picture[retry_on_error]', + 'value' => $config['picture']['retry_on_error'], + 'range_min' => 0, + 'range_max' => 10, + 'range_step' => 1, + 'unit' => 'multiplied', + ], + 'picture_retry_timeout' => [ + 'view' => 'expert', + 'type' => 'range', + 'placeholder' => $defaultConfig['picture']['retry_timeout'], + 'name' => 'picture[retry_timeout]', + 'value' => $config['picture']['retry_timeout'], + 'range_min' => 0, + 'range_max' => 10, + 'range_step' => 1, + 'unit' => 'seconds', + ], 'delete_no_request' => [ 'view' => 'expert', 'type' => 'checkbox', diff --git a/resources/lang/en.json b/resources/lang/en.json index f40b8bdde..325b41ac2 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -145,6 +145,8 @@ "general:download_enabled": "Allow downloads", "general:download_thumbs": "Use thumbnails for download", "general:picture_preview_before_processing": "Preload and show image during filter processing", + "general:picture_retry_on_error": "Retry taking a picture", + "general:picture_retry_timeout": "Retry timeout", "general:picture_thumb_size": "Thumbnail size", "general:picture_time_to_live": "Show image after capture:", "general:start_screen_subtitle": "Start screen (subtitle)", @@ -301,6 +303,8 @@ "manual:general:download_enabled": "If enabled, a download button is visible on each picture inside the gallery.", "manual:general:download_thumbs": "If enabled, thumbnails will be used at download (if exist) instead the full sized image.", "manual:general:picture_preview_before_processing": "If enabled, images are preloaded and shown during filter processing.", + "manual:general:picture_retry_on_error": "Set how often the system will try to take a picture in the event of an error. 0 = disabled.", + "manual:general:picture_retry_timeout": "Set a time after which the photo recording will be tried again. \"Retry taking a picture\" needs to be set to a value > 0.", "manual:general:picture_thumb_size": "Choose thumbnail size: XS = max 360px, S = max 540px, M = max 900px, L = max 1080px, XL = max 1260px", "manual:general:picture_time_to_live": "Choose a time between 1 and 90 seconds. Your picture is visible for that time on the result screen after taking it.", "manual:general:start_screen_subtitle": "Enter the subtitle visible on startpage.", @@ -449,6 +453,7 @@ "manual:version:check_version": "This will check online against the Github repository for the latest Photobooth version.", "manual:version:updater_button": "This will check if Photobooth can be updated and perform the update. Only works on Linux if Photobooth was installed via git.", "milliseconds": "ms", + "multiplied": "x", "myconfig": "My Config", "newCollage": "New Collage", "newPhoto": "New Picture", @@ -564,6 +569,7 @@ "reset:reset_remove_images": "Delete images", "reset:reset_remove_mailtxt": "Delete e-mail addresses database", "retakePhoto": "Retake", + "retry_message": "Taking picture failed. Retrying. Retry:", "save": "Save", "saveerror": "Error!", "saving": "Saving ...", diff --git a/src/js/core.js b/src/js/core.js index 194c56250..68c08cdba 100644 --- a/src/js/core.js +++ b/src/js/core.js @@ -401,6 +401,7 @@ const photoBooth = (function () { }; api.callTakePicApi = function (data, retry = 0) { + const retrymsg = photoboothTools.getTranslation('retry_message'); startTime = new Date().getTime(); jQuery .post('api/takePic.php', data) @@ -421,7 +422,41 @@ const photoBooth = (function () { $('#' + imgFilter).addClass('activeSidenavBtn'); if (result.error) { - api.errorPic(result); + if (config.picture.retry_on_error > 0 && retry < config.picture.retry_on_error) { + photoboothTools.console.logDev('Taking picture failed. Retrying. Retry: ' + retry); + retry += 1; + loading.append( + $('

').text( + retrymsg + ' ' + retry + '/' + config.picture.retry_on_error + ) + ); + api.startCountdown(config.picture.retry_timeout, counter, () => { + loading.empty(); + counter.empty(); + cheese.empty(); + + if (config.picture.no_cheese) { + photoboothTools.console.log('Cheese is disabled.'); + api.callTakePicApi(data, retry); + } else { + if (data.style === 'photo' || data.style === 'chroma') { + const cheesemsg = photoboothTools.getTranslation('cheese'); + cheese.text(cheesemsg); + } else { + const cheesemsg = photoboothTools.getTranslation('cheeseCollage'); + cheese.text(cheesemsg); + $('

') + .text(`${nextCollageNumber + 1} / ${config.collage.limit}`) + .appendTo('.cheese'); + } + setTimeout(() => { + api.callTakePicApi(data, retry); + }, config.picture.cheese_time); + } + }); + } else { + api.errorPic(result); + } } else if (result.success === 'collage') { currentCollageFile = result.file; nextCollageNumber = result.current + 1;