screentinker/tizen/css/style.css
screentinker 965920cd17
PiP overlay MVP: push image/web overlays to a device or group (#109) (#127)
* PiP overlay MVP: push image/web overlays to a device or group (#109)

Implements the #109 MVP from docs proposal: a floating overlay PUSHED to a device or
group in real time, rendered above the playlist without disturbing it. Scope is the
MVP only — video/RTSP, MQTT, offline-queue, and the priority/stacking system are
deferred to follow-up PRs as the proposal specifies.

Protocol (/device socket, player-agnostic):
- device:pip-show { pip_id, type:image|web, uri, position, width, height, duration,
  title?, title_color?, background_color?, opacity?, border_radius?, close_button? }
- device:pip-clear { pip_id? }
The player fetches uri itself (same trust model as remote_url content; server never
proxies). type:web is full-trust by design, hence the 'full' token scope.

Server (server/routes/pip.js, new; mounted in config/api-surface.js PUBLIC_ROUTERS):
- POST /api/pip and POST /api/pip/clear + DELETE /api/pip, all requireScope('full').
- Resolves device_id to a device OR a group, expands a group to members, and emits
  per-device — reusing the group command route's room-size online check and
  {device_id, name, status: sent|offline} result shape. Generates pip_id.
- Validates type/position allowlists, uri http(s), numeric bounds on
  width/height/duration/opacity/border_radius, colors via the existing VALID_COLOR
  (#RRGGBB; transparency is the separate opacity field).
- Workspace-isolated: every target query is scoped to req.workspaceId, so a token
  bound to workspace A can't address workspace B (404). Offline devices are reported,
  never queued (PiP is ephemeral).

Player overlay layer (Tizen; tizen/js/pip-overlay.js, new):
- A #pip sibling ABOVE #stage that PlaylistPlayer/ZoneRenderer never touch.
- applyOrientation now applies the SAME transform to #pip as #stage, so corner
  positions track the visible CONTENT in all four orientations.
- image -> <img>, web -> <iframe> (muted by default: empty allow= denies autoplay),
  sized/positioned/styled per payload, optional title bar.
- Single overlay slot, last-show-wins; duration timer (0 = until cleared); pip-clear
  (id-aware) or timer tears down; teardown wrapped so a malformed payload can't wedge
  the layer. Reports show/clear over device:log (tag 'pip').

Dashboard: a minimal "Send overlay" / "Clear overlay" tester on the device-detail
controls (device/group via the open device, type, uri, position, duration), calling
POST /api/pip through the api helper.

Tests (server suite green, 161/161):
- api.test.js: PiP tier — authz (read/write 403, full passes), workspace isolation
  (wsA token -> wsB device 404), payload validation, device + group targeting, clear;
  plus the PUBLIC_ROUTERS snapshot-firewall updated for /api/pip.
- pip-overlay.test.js: loads the real player.js + pip-overlay.js in a vm with a DOM
  shim; proves the overlay shows, auto-dismisses on the duration timer, and never
  changes the playlist signature / touches #stage; web->iframe, last-show-wins,
  id-aware clear, malformed-payload safety.

Not in this PR (intentional):
- Android player overlay — fast-follow. Protocol + server are player-agnostic; the
  Android layer (an overlay View above the player, orientation-matched to MainActivity's
  rootView rotation) is the same shape and lands next.
- OpenAPI docs for POST /api/pip — the contract test's scope heuristic only treats
  'command' paths as full-scope, so documenting a full-scope non-command route there
  needs that heuristic extended first; deferred with the docs item (proposal §8.6).
- video/rtsp types, MQTT, offline queue-on-reconnect, priority/stacking, arbitrary
  (x,y)/selector positioning (proposal §6).

Refs #109

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* PiP overlay: add Android + web players (#109)

Extends the #109 PiP MVP to the other two players so the protocol (device:pip-show /
device:pip-clear) is honored fleet-wide, not just on Tizen. No server/protocol changes —
the route and socket messages are player-agnostic; these are the two missing surfaces.

Web player (server/player/index.html):
- New #pipContainer layer above #playerContainer, pointer-transparent, that the playlist
  render never touches. The same orientation transform is applied to it as to
  #playerContainer (extended to also reset width/height on landscape so a
  portrait->landscape switch realigns), so corner positions track the visible content.
- Inline PiP logic mirroring tizen/js/pip-overlay.js: image -> <img>, web -> <iframe>
  (muted by default via empty allow=), position/size/bg/opacity/radius/title, single slot
  last-show-wins, duration timer (0 = until cleared), id-aware clear, wrapped teardown.
- device:pip-show/clear handlers; reports show/clear over device:log (tag "pip").

Android player:
- activity_main.xml: a pipLayout FrameLayout as the LAST child of rootLayout — it draws
  above the content AND inherits rootView's orientation rotation/translation, so corner
  positioning is orientation-matched for free.
- PipOverlay.kt (new): builds the overlay box into pipLayout. image -> ImageView (decoded
  off-thread via ImageLoader, dropped if torn down mid-decode); web -> WebView with
  mediaPlaybackRequiresUserGesture=true (mute-by-default). Gravity-based corner/center
  placement with a 4% inset, GradientDrawable bg + corner radius, alpha=opacity, optional
  title bar. Single slot last-show-wins; duration timer; id-aware clear; teardown wrapped
  and also run on activity destroy (WebView cleanup).
- WebSocketService: onPipShow/onPipClear callbacks + safeOn handlers posted to the main
  thread (they build Views) + a sendLog(tag, level, message) emitter for device:log.
- MainActivity: instantiate PipOverlay (log -> wsService.sendLog("pip", ...)), wire the
  callbacks, tear down on destroy.

Verified: Android assembleDebug builds clean; web player inline JS parses; server suite
still 161/161 (no server changes this commit). Not yet validated on real hardware —
four-orientation corner positioning mirrors the player container/rootView transform but
should be eyeballed on a panel.

Refs #109

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 14:54:44 -05:00

90 lines
3.2 KiB
CSS

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
width: 100%; height: 100%;
background: #000; color: #f1f5f9;
font-family: "Samsung One", "Tizen Sans", Arial, sans-serif;
overflow: hidden;
cursor: none;
}
.screen {
position: absolute; top: 0; left: 0;
width: 100%; height: 100%;
display: flex; align-items: center; justify-content: center;
}
.hidden { display: none !important; }
/* Setup / pairing card */
.card {
background: #111827;
border: 1px solid #1f2937;
border-radius: 18px;
padding: 48px 64px;
text-align: center;
max-width: 760px;
}
.card h1 { color: #3b82f6; font-size: 44px; margin-bottom: 6px; }
.sub { color: #94a3b8; font-size: 22px; margin-bottom: 36px; }
.card label { display: block; text-align: left; color: #94a3b8; font-size: 18px; margin-bottom: 8px; }
#serverUrl {
width: 100%; font-size: 26px; padding: 16px 20px;
border-radius: 10px; border: 2px solid #334155;
background: #0b1220; color: #f1f5f9; margin-bottom: 24px;
}
#serverUrl:focus { outline: none; border-color: #3b82f6; }
button {
font-size: 24px; font-weight: bold; color: #fff;
background: #3b82f6; border: none; border-radius: 10px;
padding: 16px 40px; cursor: pointer;
}
button:focus { outline: 3px solid #93c5fd; }
button.ghost { background: transparent; color: #64748b; font-size: 18px; margin-top: 24px; padding: 8px; }
.status { color: #64748b; font-size: 18px; margin-top: 20px; min-height: 24px; }
.status.error { color: #ef4444; }
/* Pairing code */
.code {
font-size: 96px; font-weight: bold; letter-spacing: 16px;
color: #22c55e; margin: 24px 0; font-family: monospace;
}
.hint { color: #94a3b8; font-size: 20px; line-height: 1.5; }
/* Playback stage */
.stage { background: #000; }
.stage img, .stage video, .stage iframe {
position: absolute; top: 0; left: 0;
width: 100%; height: 100%; border: 0;
}
.stage img.contain, .stage video.contain { object-fit: contain; }
.stage img.cover, .stage video.cover { object-fit: cover; }
.stage img.fill, .stage video.fill { object-fit: fill; }
/* Video wall mode: the stage is positioned (in vw/vh) as this screen's slice of the
wall's player rect; media stretches to fill (object-fit:fill) so a given source row
lands on the same physical line across every screen that shares a viewport height. */
.stage.wall-mode img, .stage.wall-mode video, .stage.wall-mode iframe { object-fit: fill; }
/* #109: PiP overlay layer. Sits above #stage and fills the same viewport box so a
child positioned to a corner lands in the corner of the visible content. app.js
applies the SAME orientation transform here as on #stage (portrait/flipped). It is
pointer-transparent and empty (invisible) until PipOverlay renders into it. */
#pip {
position: fixed; top: 0; left: 0;
width: 100vw; height: 100vh;
pointer-events: none;
z-index: 50;
}
#pip > div { box-shadow: 0 6px 28px rgba(0,0,0,0.55); }
/* Toast */
.toast {
position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
background: rgba(17,24,39,0.92); color: #f1f5f9;
padding: 12px 24px; border-radius: 10px; font-size: 18px;
border: 1px solid #334155;
}