Skip to content

Commit 06dc29b

Browse files
committed
Revert "Ensure live preview is not cached"
This reverts commit 80faa47.
1 parent 82bc1d5 commit 06dc29b

File tree

8 files changed

+16
-27
lines changed

8 files changed

+16
-27
lines changed

admin/captureconfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
$config['picture']['cheese_time'] = '0';
3535

3636
$config['preview']['mode'] = 'url';
37-
$config['preview']['url'] = 'http://' . Environment::getIp() . ':1984/api/stream.mjpeg?src=photobooth';
37+
$config['preview']['url'] = 'url("http://' . Environment::getIp() . ':1984/api/stream.mjpeg?src=photobooth")';
3838
$config['preview']['camTakesPic'] = false;
3939

4040
try {

admin/wgetcaptureconfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
$config['picture']['cheese_time'] = '0';
3535

3636
$config['preview']['mode'] = 'url';
37-
$config['preview']['url'] = 'http://' . Environment::getIp() . ':1984/api/stream.mjpeg?src=photobooth';
37+
$config['preview']['url'] = 'url("http://' . Environment::getIp() . ':1984/api/stream.mjpeg?src=photobooth")';
3838
$config['preview']['camTakesPic'] = false;
3939

4040
try {

assets/js/preview.js

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
/* eslint n/no-unsupported-features/node-builtins: "off" */
22
/* globals photoBooth photoboothTools */
3-
4-
function addCacheBustingParam(url) {
5-
const timestamp = new Date().getTime();
6-
7-
if (url.includes('?')) {
8-
return `${url}&t=${timestamp}`;
9-
}
10-
11-
return `${url}?t=${timestamp}`;
12-
}
13-
14-
function getRootProperty(property) {
15-
const root = document.documentElement;
16-
const style = getComputedStyle(root);
17-
return style.getPropertyValue(property).trim();
18-
}
19-
203
const photoboothPreview = (function () {
214
// vars
225
const CameraDisplayMode = {
@@ -196,8 +179,8 @@ const photoboothPreview = (function () {
196179
} else if (config.preview.mode === PreviewMode.URL.valueOf()) {
197180
photoboothTools.console.logDev('Preview: Preview at countdown from URL.');
198181
setTimeout(function () {
199-
url.attr('src', addCacheBustingParam(getRootProperty('--background-preview')));
200182
url.show();
183+
url.addClass('streaming');
201184
}, config.preview.url_delay);
202185
}
203186
break;
@@ -208,8 +191,8 @@ const photoboothPreview = (function () {
208191
} else if (config.preview.mode === PreviewMode.URL.valueOf()) {
209192
photoboothTools.console.logDev('Preview: Preview from URL.');
210193
setTimeout(function () {
211-
url.attr('src', addCacheBustingParam(getRootProperty('--background-preview')));
212194
url.show();
195+
url.addClass('streaming');
213196
}, config.preview.url_delay);
214197
}
215198
break;
@@ -235,8 +218,8 @@ const photoboothPreview = (function () {
235218
tracks.forEach((track) => track.stop());
236219
api.stream = null;
237220
}
221+
url.removeClass('streaming');
238222
url.hide();
239-
url.attr('src', '');
240223
video.hide();
241224
pictureFrame.hide();
242225
collageFrame.hide();

assets/js/test-preview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const photoboothPreviewTest = (function () {
9696
if (config.preview.mode === PreviewMode.DEVICE.valueOf()) {
9797
photoboothPreview.stopVideo();
9898
} else if (config.preview.mode === PreviewMode.URL.valueOf()) {
99-
previewIpcam.attr('src', '');
99+
previewIpcam.removeClass('streaming');
100100
previewIpcam.hide();
101101
}
102102

assets/sass/components/_preview.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,9 @@
9292
scale: 1 -1;
9393
}
9494
}
95+
96+
#preview--ipcam {
97+
&.streaming {
98+
background-image: var(--background-preview);
99+
}
100+
}

docs/faq/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ If you like to have the same preview independent of the device you access Photob
476476
Make sure to have a stream available you can use (e.g. from your Webcam, Smartphone Camera or Raspberry Pi Camera)
477477

478478
- Admin panel config _"Preview mode"_: `from URL`
479-
- Admin panel config _"Preview-URL"_ example (add needed IP address instead): `http://192.168.0.2:8081`
479+
- Admin panel config _"Preview-URL"_ example (add needed IP address instead): `url(http://192.168.0.2:8081)`
480480

481481
**Note**
482482

@@ -488,7 +488,7 @@ Make sure to have a stream available you can use (e.g. from your Webcam, Smartph
488488
489489
If you want to use a stream from your DSLR or Pi Camera, install go2rtc and setup needed service to use.
490490
491-
go2rtc can be accessed at `http://localhost:1984`. Use `http://localhost:1984/api/stream.mjpeg?src=photobooth` as _"Preview-URL"_ (replace `localhost` with Photobooths IP for remote access).
491+
go2rtc can be accessed at `http://localhost:1984`. Use `url("http://localhost:1984/api/stream.mjpeg?src=photobooth")` as _"Preview-URL"_ (replace `localhost` with Photobooths IP for remote access).
492492
To be able to also capture images you need to adjust the capture command.
493493
_"Commands"_: _"Take picture command"_: `capture %s`
494494

lib/configsetup.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@
15131513
'preview_url' => [
15141514
'type' => 'input',
15151515
'name' => 'preview[url]',
1516-
'placeholder' => 'http://localhost:8081',
1516+
'placeholder' => 'url(http://localhost:8081)',
15171517
'value' => htmlentities($config['preview']['url'] ?? ''),
15181518
],
15191519
'preview_url_delay' => [

template/components/preview.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
echo '<div id="preview-container" style="aspect-ratio: ' . $comp . '">';
4646
echo '<div id="preview-wrapper" style="aspect-ratio:' . $comp . '">';
4747
echo '<video id="preview--video" style="' . $composed_style . '" class="' . $previewFlipClass . ' ' . $previewStyleClass . '" autoplay playsinline></video>';
48-
echo '<img id="preview--ipcam" style="' . $composed_style . '" class="' . $previewFlipClass . ' ' . $previewStyleClass . '"></img>';
48+
echo '<div id="preview--ipcam" style="' . $composed_style . '" class="' . $previewFlipClass . ' ' . $previewStyleClass . '"></div>';
4949
echo '<div id="preview--none">' . $languageService->translate('no_preview') . '</div>';
5050
echo '</div></div>';
5151

0 commit comments

Comments
 (0)