diff --git a/server/player/index.html b/server/player/index.html
index f1a25ed..de236ff 100644
--- a/server/player/index.html
+++ b/server/player/index.html
@@ -1880,69 +1880,168 @@
}
// ==================== Screenshots ====================
- function captureAndSend() {
- if (!socket?.connected) return;
+ // Draw a media element into a destination rect honouring its object-fit, so the capture
+ // matches what's on screen instead of stretching the source to a fixed size (the old
+ // bug). 'cover' crops the source; 'contain' letterboxes; 'fill' stretches.
+ function drawMediaFit(ctx, el, ew, eh, dx, dy, dw, dh, fit) {
+ if (!ew || !eh) { ctx.drawImage(el, dx, dy, dw, dh); return; }
+ if (fit === 'fill') { ctx.drawImage(el, dx, dy, dw, dh); return; }
+ const er = ew / eh, dr = dw / dh;
+ if (fit === 'contain') {
+ let w = dw, h = dh;
+ if (er > dr) h = dw / er; else w = dh * er;
+ ctx.drawImage(el, dx + (dw - w) / 2, dy + (dh - h) / 2, w, h);
+ } else { // 'cover' (zone default) and anything unexpected -> crop to fill, no distortion
+ let sw = ew, sh = eh, sx = 0, sy = 0;
+ if (er > dr) { sw = eh * dr; sx = (ew - sw) / 2; }
+ else { sh = ew / dr; sy = (eh - sh) / 2; }
+ ctx.drawImage(el, sx, sy, sw, sh, dx, dy, dw, dh);
+ }
+ }
+
+ // A cross-origin
/