From ed9fb6d23a91243dff99476023f9c12df6fa41ea Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 29 Mar 2024 20:39:03 +0100 Subject: [PATCH] Flip user-facing camera stream --- showbits-thermal-printer/static/photo.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/showbits-thermal-printer/static/photo.html b/showbits-thermal-printer/static/photo.html index 6d4f1ad..afcae97 100644 --- a/showbits-thermal-printer/static/photo.html +++ b/showbits-thermal-printer/static/photo.html @@ -19,6 +19,10 @@ height: 100%; } + video.mirrored { + scale: -1 1; + } + #button { position: absolute; bottom: 20px; @@ -106,8 +110,13 @@ }); video.srcObject = stream; - // Enable or disable flip button + // Flip video horizontally if it's facing the user const facing = getStreamFacingMode(stream); + if (facing !== "environment") { + video.classList.add("mirrored"); + } + + // Enable or disable flip button const canFlip = facing !== undefined; const facingOpposite = facing === "user" ? "environment" : "user"; flip.hidden = !canFlip;