Files
Blink/docs/blink-remote-syncplay-plan.md
T
1xDed cbb750a413
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
update
2026-12-02 08:37:23 +03:00

257 lines
13 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 `<video>` element directly.
4. **Seek was extrapolated as if playing.** After a group seek the server stays
in `Waiting` at the seek position; the client kept adding elapsed time,
making the server chase a moving target. A Seek now freezes the timeline at
the target and pauses locally until the group unpause.
5. **State updates resumed/paused clients immediately.** That bypassed the
server’s scheduled `When`, so each client started at a different instant.
Only Pause/Unpause/Seek commands drive playback now; the state update is
informational.
6. **Local parking echoed Pause/Seek/Buffer requests.** Pausing a client to
park it looked like a user request and flipped the group to `Paused` or
restarted the wait. Parking is guarded, and pause/resume/seek/buffer reports
are suppressed while the group is parking.
7. **Readiness waited for `HAVE_CURRENT_DATA`/`onReady`.** A player parked
before its first frame could stay at metadata only, so it never reported
ready and the group waited 30 s. Readiness now accepts loaded metadata
(`readyState >= 1`), which is enough to start in sync.
8. **Command timeline.** Pause/Unpause/Seek positions are now anchored to the
server’s `When` + `PositionTicks` and reset on every play-queue update,
instead of extrapolating from a stale queue snapshot.
9. **Auto-group start window.** Auto-join polling is 2 s and, when other Blink
devices are online, sharing the queue waits 2.2 s so they join before the
first unpause instead of joining mid-playback.
`pnpm exec tsc --noEmit` and `pnpm build` pass after these changes.
## Audio, transfers and group edge cases (2026-12-02, follow-up)
### Additional fixes
1. **Audio playback was invisible to Jellyfin.** The `<audio>` element played
locally but never sent `reportPlaybackStart/Progress/Stopped`. As a result
`/Sessions` stayed empty, so audio could not be cast, taken over, followed or
synchronised. Audio now reports start, progress (10 s), pause and stop; the
session shows the track and position like a video.
2. **A group was moving unrelated local music.** Group `Seek`/`Pause`/`Unpause`
commands and drift correction were applied to whatever media the client was
playing. Starting music while a group video was running made the server seek
the track to the video position: the song jumped to its end, ended and
restarted every couple of seconds. Commands now only touch the group's
current item; other local media is ignored.
3. **Starting media echoed a Pause into the group.** Pausing the old video when
music starts looked like a user Pause request. A short media-switch guard
suppresses Pause/Seek/Buffer reports while audio and video swap.
4. **A client playing local media held the whole group.** Such a client is now
marked with `IgnoreWait` on the server, and the mark is cleared when it
returns to the group item. The group no longer waits 30 s for a member that
deliberately switched to music; its own playback is unaffected.
5. **Transfers stopped the source before the target had started.** `playOnSession`
now waits until the target session reports the requested item (up to two
attempts), then corrects its position. If the target never starts, the
mutation fails and the source keeps playing instead of stopping everywhere.
6. **Audio transfers always looked unsuccessful.** Because audio was never
reported, the source could not verify the target. With audio reporting the
same confirmation works for music and video.
7. **Follow-me card was hidden by an idle audio player.** It used to hide
whenever the audio bar had an item, even when paused. It now hides only while
audio is actually playing, so “Продолжить здесь” appears over an open but
idle audio player.
8. **Audio/video mixing.** Starting one medium stops the other; the group item
guard prevents cross-media seeks; media-switch guards prevent old-player
events from being sent as group commands.
9. **Two-second loop at the start of a group video.** Late auto-joins each put
the group back into Waiting and re-parked everyone at the first seconds.
Auto-join polls every 1 s, the host waits 3 s before sharing the queue when
other Blink clients are online, and the old “solo force resume” was removed.
Three clients now start together in about 1 s with no loop.
10. **Back from the player.** The group is not left. The player exit no longer
reports a Pause, and after ~3 s without local media the client is marked
`IgnoreWait`, so the group keeps playing while the user browses.
11. **Audio autoplay overrode SyncPlay parking.** The `<audio autoPlay>` element
started even when the group had parked it, so clients played ~3 s and the
server then seeked everyone back to 0. The element no longer autoplays:
playback follows the shared store flag, and parking pauses it before the
element even mounts.
### Follow-up verification
| Scenario | Result |
| --- | --- |
| Audio session visibility | `/Sessions` shows the track, type Audio, live position |
| Audio send, one client to another | Target starts at the transferred position; source stops only after confirmation |
| Follow-me with the audio player open | Card appears over the paused/ended audio player; takeover works for audio and video |
| Music during a group video | Group stays Playing; music advances 31→35 s while video 5→10 s |
| Group pause while one client plays music | State `Paused` in 1 s; video pauses, music keeps playing |
| Music vs. group seek | Group seek to 05:00 does not move the music (33→44 s) |
| Three-client group start | `Playing` in ~1 s, positions identical, no 2 s loop |
| Group audio start | Parks at 0, no 3 s restart; pause 8.6/8.7/8.6 → resume 9.8/9.8/9.8 |
| Group audio seek to 01:00 | All at 60–61 s, then advance together, no end loop |
| Back from the group player | Group remains; other clients continue; Pause reaches `Paused` in 1 s with the browsing client ignored |
| `tsc --noEmit` / `pnpm build` | Pass |