diff --git a/.gitignore b/.gitignore index f1a46a7..0340c62 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ generateBanner # TypeScript incremental build cache *.tsbuildinfo + +# local multi-client test profiles +.clients/ diff --git a/docs/blink-remote-syncplay-plan.md b/docs/blink-remote-syncplay-plan.md new file mode 100644 index 0000000..b9e655d --- /dev/null +++ b/docs/blink-remote-syncplay-plan.md @@ -0,0 +1,256 @@ +# Blink Remote Control + SyncPlay Plan + +## Goal + +логин root пароль 12345 +сервер https://jel.midns.ru + +Make remote control and SyncPlay predictable for Blink clients only: + +- Remote control lists only `Client = Blink` sessions, with readable device names. +- Quick transfer of the current media to any selected Blink device. +- Media takeover cards for taking playback from another Blink device. +- SyncPlay groups are Blink groups; add an auto-group for all running Blink clients. +- Keep group playback as close to frame-accurate as the Jellyfin SyncPlay protocol allows. +- Redesign all remote/session cards with a glass surface, clear hierarchy and motion. + +## Constraints + +- Do not expose non-Blink Jellyfin sessions in remote control or SyncPlay UI. +- Do not rely on `GroupInfoDto.Participants` for device names: the server stores + distinct user names there, not device names or sessions. +- Device identity must be stable per installation and readable by humans. +- Multi-client testing should use the same Jellyfin user, like a household setup. + +## Workstreams + +### 1. Blink identity and shared session utilities + +- Add a device identity helper: stable id, readable name + (`Blink · Windows · 4F2A`), optional local override. +- Set `deviceInfo.name` from that helper so Jellyfin reports a useful + `DeviceName` for every Blink client. +- Add a local "device name" field in Settings → Preferences. +- Add shared helpers: + - `isBlinkSession` + - `getBlinkSessions(sessions, { userId, selfDeviceId })` + - `getBlinkDeviceName` + - `getBlinkDeviceKind` + - Blink group marker/prefix and predicate. + +### 2. Remote control: Blink only + quick transfer + +- Shared `useBlinkSessions` hook: realtime WebSocket snapshot first, API poll as + fallback. Filters by `Client=Blink`, same user, excludes the local device. +- Use the shared filter in: + - titlebar cast dialog + - remote page + - audio player device menu / remote bar + - FollowMe takeover prompt + - legacy playback sync +- `CastButton` without explicit media uses the current local media + (video/audio item, queue, position, paused state). +- Redesign the cast dialog: + - "Сейчас играет" media preview. + - Blink device cards. + - One-click "Отправить сюда". + - "Забрать сюда" when the target is playing. + - "Открыть пульт" for full control. + +### 3. Remote page: full control + +- Blink-only device list with proper names. +- Glass session cards: device, status, now playing, progress. +- Add actions missing today: + - take remote playback here + - send current local media to the selected device + - stop remote playback + - audio track selection (alongside subtitles) + - volume/mute, seek, play/pause, next/prev, fullscreen + - open SyncPlay group controls from the remote page +- Motion: card lift, progress animation, active-device glow. + +### 4. SyncPlay: Blink groups + auto-group + +- Group name prefix `Blink ·`; only prefixed groups are listed and joinable. +- Create groups with the prefix hidden from the visible name. +- Auto-group: + - name `Blink · Автогруппа` + - host can create/join with one click + - other Blink clients auto-join when the setting is enabled (default on) + - host can optionally share the current queue at the same time +- SyncPlay dialog shows online Blink devices by name and uses Blink-only + groups. +- `GroupInfoDto.Participants` is shown as users, never as devices. +- Avoid the old "participants <= 1 => force resume" shortcut when other Blink + devices are online; let the server's group-wait complete. + +### 5. Maximum SyncPlay synchronization + +- Measure real ping (EMA of SyncPlay ping round-trip) instead of a fixed 50 ms. +- Only report `Ready` once local playback is actually ready (video ready and not + buffering; audio element has enough data). +- Reduce drift tolerance to the server's practical sync window (~500 ms) and + keep seek throttling. +- Keep assistant controllers: pings every 3 s, ready retry only while waiting. +- Do not auto-resume a group before other online Blink clients are ready. + +### 6. Glass takeover cards + animations + +- Shared `SessionCard` component for remote dialog, remote page and device + lists. +- Glass surface: translucent gradient, 1 px highlight border, blur, depth + shadow, poster-driven accent. +- States: selected, playing, paused, idle, unsupported. +- Motion: entrance stagger, hover lift, press scale, progress transition, + active pulse. +- FollowMe takeover prompt uses the same glass language. + +### 7. Testing with 2-3 clients + +- Launch the current dev build as 2 extra WebView2 profiles, each with its own + localStorage device id; share the same Jellyfin user/token. +- Verify: + 1. all three appear as `Client=Blink` with distinct readable names + 2. remote dialog lists only Blink devices + 3. screenshot/internal API check of the glass cards + 4. send current media from client 1 to client 2; verify client 2 starts at + the same position and client 1 stops + 5. take media back to client 1; verify client 2 stops + 6. create auto-group from client 1; clients 2/3 join automatically + 7. share queue; all three play the same item; compare positions/drift + 8. pause/resume/seek from client 1; verify clients 2/3 follow + 9. verify non-Blink sessions/groups are not shown +- Record results in the final report. + +## Definition of done + +- `tsc --noEmit` and `pnpm build` pass. +- No non-Blink session or group appears in remote/SyncPlay UI. +- Three-device test passes for transfer, takeover, auto-group and + pause/resume/seek synchronization. +- Final short report with issue count and serious fixes. + +## Verification results (2026-12-02) + +Stand: three Blink clients on one Windows machine (`2346`, `5A33`, `1959`), +one Jellyfin user, dev build, server `https://jel.midns.ru`. + +| Scenario | Result | +| --- | --- | +| Blink-only filters and names | Jellyfin Web / other sessions never shown; devices appear as `Blink · Windows · XXXX` | +| Send current media to another client | Target starts at the same position with the shared queue; source stops | +| Take playback back | Target stops, initiator resumes at the transferred position | +| Auto-group with all three clients | Clients join in 1–3 s; no 30 s `Waiting` timeout | +| Group queue start | `Playing` within ~1 s, positions 0.00/0.00/0.00 (spread ≤ 0.02 s) | +| Pause | `Paused` within ~1 s, all at the same position (spread 0.00 s) | +| Resume | Server schedules the unpause by ping (≈2 s in this setup), spread 0.01 s | +| Seek to 05:00 | `Waiting → Playing`, final spread 0.02–0.03 s at 306.3 s | +| Non-Blink groups | Not listed, not joinable | + +### Serious fixes found by the three-client test + +1. **Buffer end was reported as another Buffer request.** The Jellyfin server + treats any Buffer request as “this session is buffering”, so every client + that finished buffering was marked buffering again. Buffer end now sends + `Ready`, as jellyfin-web does. +2. **Parking tolerance was 30 ms instead of 400 ms.** While waiting for a new + queue, clients seeked every second against a 30 ms threshold and never sent + `Ready`; the group only started via the server’s 30 s timeout. The threshold + is now 400 ms, below the server’s 500 ms acceptance window. +3. **Paused position was read from a stale store value.** `playerState.currentTime` + only updates on `timeupdate`, which can stand still while paused, so seeks + looked unapplied. Position now comes from the `