update
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
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
This commit is contained in:
1 parent
7fb3d6cfa4
commit
cbb750a413
67 files changed
+4485
-2499
No files matched your search
@@ -45,3 +45,6 @@ generateBanner
|
||||
|
||||
# TypeScript incremental build cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# local multi-client test profiles
|
||||
.clients/
|
||||
@@ -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 `<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 |
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"clipboard-manager":{"default_permission":{"identifier":"default","description":"No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n","permissions":[]},"permissions":{"allow-clear":{"identifier":"allow-clear","description":"Enables the clear command without any pre-configured scope.","commands":{"allow":["clear"],"deny":[]}},"allow-read-image":{"identifier":"allow-read-image","description":"Enables the read_image command without any pre-configured scope.","commands":{"allow":["read_image"],"deny":[]}},"allow-read-text":{"identifier":"allow-read-text","description":"Enables the read_text command without any pre-configured scope.","commands":{"allow":["read_text"],"deny":[]}},"allow-write-html":{"identifier":"allow-write-html","description":"Enables the write_html command without any pre-configured scope.","commands":{"allow":["write_html"],"deny":[]}},"allow-write-image":{"identifier":"allow-write-image","description":"Enables the write_image command without any pre-configured scope.","commands":{"allow":["write_image"],"deny":[]}},"allow-write-secret":{"identifier":"allow-write-secret","description":"Enables the write_secret command without any pre-configured scope.","commands":{"allow":["write_secret"],"deny":[]}},"allow-write-text":{"identifier":"allow-write-text","description":"Enables the write_text command without any pre-configured scope.","commands":{"allow":["write_text"],"deny":[]}},"deny-clear":{"identifier":"deny-clear","description":"Denies the clear command without any pre-configured scope.","commands":{"allow":[],"deny":["clear"]}},"deny-read-image":{"identifier":"deny-read-image","description":"Denies the read_image command without any pre-configured scope.","commands":{"allow":[],"deny":["read_image"]}},"deny-read-text":{"identifier":"deny-read-text","description":"Denies the read_text command without any pre-configured scope.","commands":{"allow":[],"deny":["read_text"]}},"deny-write-html":{"identifier":"deny-write-html","description":"Denies the write_html command without any pre-configured scope.","commands":{"allow":[],"deny":["write_html"]}},"deny-write-image":{"identifier":"deny-write-image","description":"Denies the write_image command without any pre-configured scope.","commands":{"allow":[],"deny":["write_image"]}},"deny-write-secret":{"identifier":"deny-write-secret","description":"Denies the write_secret command without any pre-configured scope.","commands":{"allow":[],"deny":["write_secret"]}},"deny-write-text":{"identifier":"deny-write-text","description":"Denies the write_text command without any pre-configured scope.","commands":{"allow":[],"deny":["write_text"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener","allow-supports-multiple-windows"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-exit":{"identifier":"allow-exit","description":"Enables the exit command without any pre-configured scope.","commands":{"allow":["exit"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","coLine truncated
|
||||
{"clipboard-manager":{"default_permission":{"identifier":"default","description":"No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n","permissions":[]},"permissions":{"allow-clear":{"identifier":"allow-clear","description":"Enables the clear command without any pre-configured scope.","commands":{"allow":["clear"],"deny":[]}},"allow-read-image":{"identifier":"allow-read-image","description":"Enables the read_image command without any pre-configured scope.","commands":{"allow":["read_image"],"deny":[]}},"allow-read-text":{"identifier":"allow-read-text","description":"Enables the read_text command without any pre-configured scope.","commands":{"allow":["read_text"],"deny":[]}},"allow-write-html":{"identifier":"allow-write-html","description":"Enables the write_html command without any pre-configured scope.","commands":{"allow":["write_html"],"deny":[]}},"allow-write-image":{"identifier":"allow-write-image","description":"Enables the write_image command without any pre-configured scope.","commands":{"allow":["write_image"],"deny":[]}},"allow-write-secret":{"identifier":"allow-write-secret","description":"Enables the write_secret command without any pre-configured scope.","commands":{"allow":["write_secret"],"deny":[]}},"allow-write-text":{"identifier":"allow-write-text","description":"Enables the write_text command without any pre-configured scope.","commands":{"allow":["write_text"],"deny":[]}},"deny-clear":{"identifier":"deny-clear","description":"Denies the clear command without any pre-configured scope.","commands":{"allow":[],"deny":["clear"]}},"deny-read-image":{"identifier":"deny-read-image","description":"Denies the read_image command without any pre-configured scope.","commands":{"allow":[],"deny":["read_image"]}},"deny-read-text":{"identifier":"deny-read-text","description":"Denies the read_text command without any pre-configured scope.","commands":{"allow":[],"deny":["read_text"]}},"deny-write-html":{"identifier":"deny-write-html","description":"Denies the write_html command without any pre-configured scope.","commands":{"allow":[],"deny":["write_html"]}},"deny-write-image":{"identifier":"deny-write-image","description":"Denies the write_image command without any pre-configured scope.","commands":{"allow":[],"deny":["write_image"]}},"deny-write-secret":{"identifier":"deny-write-secret","description":"Denies the write_secret command without any pre-configured scope.","commands":{"allow":[],"deny":["write_secret"]}},"deny-write-text":{"identifier":"deny-write-text","description":"Denies the write_text command without any pre-configured scope.","commands":{"allow":[],"deny":["write_text"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener","allow-supports-multiple-windows"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-exit":{"identifier":"allow-exit","description":"Enables the exit command without any pre-configured scope.","commands":{"allow":["exit"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","coLine truncated
|
||||
@@ -1,356 +0,0 @@
|
||||
|
||||
.appBar {
|
||||
// Custom titlebar: the app header itself sits at the very top of the window,
|
||||
// under the native overlay titlebar (no native glass strip, no blur panels).
|
||||
transition: background-color $transition-time-fast;
|
||||
// Same vertical rhythm as the home page header so every page's controls
|
||||
// sit on one consistent level.
|
||||
padding: 1.3rem ($page-margin - 1.7em);
|
||||
z-index: 999 !important;
|
||||
top: 0 !important;
|
||||
|
||||
// Keep the left controls clear of the macOS traffic lights and put the
|
||||
// header row on the same level as them.
|
||||
html.is-macos & {
|
||||
padding-top: 0.6rem;
|
||||
padding-left: calc(#{$page-margin} - 1.7em + 72px);
|
||||
}
|
||||
|
||||
.flex {
|
||||
// Avoid animating padding; it causes layout reflow on each frame.
|
||||
transition: background-color $transition-time-fast;
|
||||
border-radius: 1000px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
// Solid, part-of-the-screen titlebar background once the page scrolls.
|
||||
&.elevated {
|
||||
background-color: $clr-background-default !important;
|
||||
border-bottom: 1px solid rgb(255 255 255 / 0.06);
|
||||
box-shadow: none !important;
|
||||
background-image: none !important;
|
||||
backdrop-filter: none !important;
|
||||
}
|
||||
|
||||
&-title {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
max-width: min(38vw, 520px);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: rgb(255 255 255 / 0.72);
|
||||
font-size: 0.9rem !important;
|
||||
font-weight: 500 !important;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&-avatar {
|
||||
background: rgb(255 255 255 / 0.1) !important;
|
||||
&-icon {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
&-text {
|
||||
opacity: 0.7;
|
||||
transition: opacity $transition-time-fast;
|
||||
position: relative;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
&::after {
|
||||
content: "";
|
||||
width: 100%;
|
||||
height: 1.2px;
|
||||
background: white;
|
||||
opacity: 0.7;
|
||||
position: absolute;
|
||||
bottom: 4.6px;
|
||||
left: 0;
|
||||
transform: scaleX(0);
|
||||
transition: transform $transition-time-fast,
|
||||
background $transition-time-fast,
|
||||
opacity $transition-time-fast;
|
||||
}
|
||||
&:hover {
|
||||
opacity: 0.8;
|
||||
&::after {
|
||||
transform: scaleX(0.25);
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
&.active {
|
||||
opacity: 1;
|
||||
color: $clr-accent-default;
|
||||
&::after {
|
||||
transform: scaleX(0.5);
|
||||
opacity: 1;
|
||||
background: $clr-accent-default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.library-drawer {
|
||||
// Ensure the drawer paper itself gets the styling
|
||||
&.MuiDrawer-paper {
|
||||
width: 280px;
|
||||
margin: 16px;
|
||||
height: calc(100% - 32px) !important; // float in the middle
|
||||
border-radius: 24px;
|
||||
background: rgba(20, 20, 25, 0.75); // Darker, substantial base
|
||||
backdrop-filter: blur(24px) saturate(180%);
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
box-shadow:
|
||||
0 24px 48px rgba(0, 0, 0, 0.4),
|
||||
0 4px 8px rgba(0, 0, 0, 0.2);
|
||||
overflow: hidden; // Contain scrollbars
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
// The drawer itself scrolls, so settings/about/libraries stay reachable
|
||||
// when the window is shorter than the full menu.
|
||||
&-scroll {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
padding-bottom: 12px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.18);
|
||||
border-radius: 999px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Keep the close action visible while the rest of the menu scrolls.
|
||||
&-top {
|
||||
position: sticky !important;
|
||||
top: 0 !important;
|
||||
z-index: 3;
|
||||
background: rgba(18, 18, 24, 0.92);
|
||||
backdrop-filter: blur(18px) saturate(160%);
|
||||
}
|
||||
|
||||
.MuiList-root {
|
||||
padding: 8px; // Reduced from 16px
|
||||
gap: 2px; // Reduced gap
|
||||
}
|
||||
|
||||
.MuiDivider-root {
|
||||
border-color: rgba(255, 255, 255, 0.1);
|
||||
margin: 4px 12px; // Reduced margins
|
||||
}
|
||||
|
||||
// Navigation Items
|
||||
.MuiListItemButton-root {
|
||||
border-radius: 12px !important; // Slightly smaller radius
|
||||
padding: 8px 12px; // Reduced padding (was 12px 16px)
|
||||
margin-bottom: 2px;
|
||||
transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
color: #fff;
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
margin-right: 12px; // Reduced spacing
|
||||
font-size: 22px; // Slightly smaller icons usually look better with less padding
|
||||
transition: all 0.2s ease;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.MuiListItemText-primary {
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem; // Slightly smaller text
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
}
|
||||
|
||||
// Active State
|
||||
.library-drawer-item.active {
|
||||
.MuiListItemButton-root {
|
||||
background: linear-gradient(90deg, rgba($clr-accent-default, 0.2), rgba($clr-accent-default, 0.05));
|
||||
color: $clr-accent-default;
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-variation-settings: 'FILL' 1;
|
||||
color: $clr-accent-default;
|
||||
}
|
||||
|
||||
// Active Indicator Bar
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
height: 24px;
|
||||
width: 4px;
|
||||
background: $clr-accent-default;
|
||||
border-radius: 0 4px 4px 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Custom Scrollbar for the drawer content
|
||||
&::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 4px;
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.appLoading {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.appBar {
|
||||
padding: calc(0.55rem + var(--safe-top)) 0.6rem 0.55rem !important;
|
||||
|
||||
html.is-macos & {
|
||||
padding-left: 76px !important;
|
||||
}
|
||||
|
||||
.appBar-groups,
|
||||
.appBar-cast,
|
||||
.appBar-favorite,
|
||||
.appBar-downloads,
|
||||
[aria-label="Главная"] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
&-title {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.library-drawer.MuiDrawer-paper {
|
||||
width: min(84vw, 320px);
|
||||
margin: calc(8px + var(--safe-top)) 8px calc(8px + var(--safe-bottom));
|
||||
height: calc(100% - 16px - var(--safe-top) - var(--safe-bottom)) !important;
|
||||
border-radius: 20px;
|
||||
background: rgb(18 18 24 / 0.98) !important;
|
||||
backdrop-filter: blur(24px) saturate(160%);
|
||||
}
|
||||
}
|
||||
|
||||
/* Short windows: keep every menu item reachable by scrolling and make the
|
||||
rows denser so less scrolling is needed in the first place. */
|
||||
@media (max-height: 720px) {
|
||||
.library-drawer {
|
||||
&.MuiDrawer-paper {
|
||||
margin: 8px;
|
||||
height: calc(100% - 16px) !important;
|
||||
}
|
||||
|
||||
.MuiListItemButton-root {
|
||||
min-height: 36px !important;
|
||||
padding: 6px 10px !important;
|
||||
}
|
||||
|
||||
.MuiListItemText-primary {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.MuiTypography-overline {
|
||||
padding-top: 0.7em !important;
|
||||
padding-bottom: 0.1em;
|
||||
}
|
||||
|
||||
.MuiDivider-root {
|
||||
margin: 2px 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-height: 560px) {
|
||||
.library-drawer {
|
||||
.MuiListItemButton-root {
|
||||
min-height: 32px !important;
|
||||
padding: 4px 8px !important;
|
||||
}
|
||||
|
||||
.MuiListItemText-primary {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.back-only-bar {
|
||||
padding-top: var(--safe-top);
|
||||
|
||||
html.is-macos & {
|
||||
padding-left: 76px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.qc-label-short {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.qc-label-full {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.qc-label-short {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.back-only-bar .MuiButton-root {
|
||||
height: 38px;
|
||||
min-height: 38px;
|
||||
padding: 0 0.85rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.72rem;
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.appBar-title {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
import MuiAppBar from "@mui/material/AppBar";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import React, { useCallback, useState } from "react";
|
||||
|
||||
import "./appBar.scss";
|
||||
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
||||
import useHeaderStore from "@/utils/store/header";
|
||||
import useSearchStore from "@/utils/store/search";
|
||||
import BackButton from "../buttons/backButton";
|
||||
import CastButton from "../buttons/castButton";
|
||||
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||
import { NavigationDrawer } from "./navigationDrawer";
|
||||
import WindowControls from "../windowControls";
|
||||
|
||||
const MemoizeBackButton = React.memo(BackButton);
|
||||
|
||||
const HIDDEN_PATHS = [
|
||||
"/login",
|
||||
"/setup",
|
||||
"/server",
|
||||
"/player",
|
||||
"/error",
|
||||
"/settings",
|
||||
"/library",
|
||||
"/search",
|
||||
"/remote",
|
||||
// The home page draws its own header inside the hero frame.
|
||||
"/home",
|
||||
];
|
||||
|
||||
/** Whether the global app header is drawn for this route. */
|
||||
export const shouldShowAppBar = (pathname: string) =>
|
||||
!HIDDEN_PATHS.some(
|
||||
(path) => pathname.startsWith(path) || pathname === "/",
|
||||
);
|
||||
|
||||
const AppBarContent = () => {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
const toggleSearchDialog = useSearchStore(
|
||||
useShallow((s) => s.toggleSearchDialog),
|
||||
);
|
||||
|
||||
// This hook subscribes to page scroll; keep it out of hidden routes.
|
||||
const trigger = useScrollTrigger({
|
||||
disableHysteresis: true,
|
||||
threshold: 20,
|
||||
});
|
||||
|
||||
const [showDrawer, setShowDrawer] = useState(false);
|
||||
|
||||
const handleDrawerClose = useCallback(() => {
|
||||
setShowDrawer(false);
|
||||
}, []);
|
||||
|
||||
const handleDrawerOpen = useCallback(() => {
|
||||
setShowDrawer(true);
|
||||
}, []);
|
||||
|
||||
const handleNavigateToHome = useCallback(() => navigate({ to: "/home" }), []);
|
||||
const handleNavigateToFavorite = useCallback(() => {
|
||||
navigate({ to: "/favorite" });
|
||||
}, []);
|
||||
|
||||
const { pageTitle } = useHeaderStore(
|
||||
useShallow((s) => ({ pageTitle: s.pageTitle })),
|
||||
);
|
||||
|
||||
const fallbackTitle = (() => {
|
||||
const path = location.pathname;
|
||||
if (path === "/favorite") return "Избранное";
|
||||
if (path === "/downloads") return "Загрузки";
|
||||
if (path.startsWith("/music/")) return "Музыка";
|
||||
if (path.startsWith("/player/audio")) return "Сейчас играет";
|
||||
return "";
|
||||
})();
|
||||
const title = pageTitle || fallbackTitle;
|
||||
|
||||
return (
|
||||
<>
|
||||
<MuiAppBar
|
||||
data-tauri-drag-region
|
||||
className={
|
||||
trigger
|
||||
? "appBar flex flex-row flex-justify-spaced-between elevated"
|
||||
: "appBar flex flex-row flex-justify-spaced-between"
|
||||
}
|
||||
elevation={0}
|
||||
color="transparent"
|
||||
>
|
||||
<div
|
||||
className="flex flex-row"
|
||||
data-tauri-drag-region
|
||||
style={{ gap: "0.6em" }}
|
||||
>
|
||||
<Tooltip title="Открыть меню">
|
||||
<IconButton onClick={handleDrawerOpen} aria-label="Открыть меню">
|
||||
<span className="material-symbols-rounded">menu</span>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<MemoizeBackButton />
|
||||
<Tooltip title="Главная">
|
||||
<IconButton onClick={handleNavigateToHome} aria-label="Главная">
|
||||
<span
|
||||
className={
|
||||
location.pathname === "/home"
|
||||
? "material-symbols-rounded fill"
|
||||
: "material-symbols-rounded"
|
||||
}
|
||||
>
|
||||
home
|
||||
</span>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
{title && (
|
||||
<Typography className="appBar-title" noWrap>
|
||||
{title}
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
<div
|
||||
className="flex flex-row"
|
||||
data-tauri-drag-region
|
||||
style={{ gap: "0.6em" }}
|
||||
>
|
||||
<Tooltip title="Смотреть вместе">
|
||||
<IconButton
|
||||
className="appBar-groups"
|
||||
onClick={openSyncPlayDialog}
|
||||
aria-label="Смотреть вместе"
|
||||
>
|
||||
<span className="material-symbols-rounded">groups</span>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<span className="appBar-cast">
|
||||
<CastButton />
|
||||
</span>
|
||||
<Tooltip title="Поиск">
|
||||
<IconButton onClick={toggleSearchDialog} aria-label="Поиск">
|
||||
<span className="material-symbols-rounded">search</span>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Tooltip title="Загрузки">
|
||||
<IconButton
|
||||
className="appBar-downloads"
|
||||
onClick={() => navigate({ to: "/downloads" })}
|
||||
aria-label="Загрузки"
|
||||
>
|
||||
<span className="material-symbols-rounded">download</span>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Tooltip title="Пульт">
|
||||
<IconButton
|
||||
onClick={() => navigate({ to: "/remote" })}
|
||||
aria-label="Пульт"
|
||||
>
|
||||
<span className="material-symbols-rounded">settings_remote</span>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Tooltip title="Избранное">
|
||||
<IconButton
|
||||
className="appBar-favorite"
|
||||
onClick={handleNavigateToFavorite}
|
||||
aria-label="Избранное"
|
||||
>
|
||||
<span className="material-symbols-rounded">favorite</span>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<UserAvatarMenu />
|
||||
<WindowControls />
|
||||
</div>
|
||||
</MuiAppBar>
|
||||
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export const AppBar = () => {
|
||||
const location = useLocation();
|
||||
if (!shouldShowAppBar(location.pathname)) return null;
|
||||
return <AppBarContent />;
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
.back-only-bar {
|
||||
padding-top: var(--safe-top);
|
||||
|
||||
html.is-macos & {
|
||||
padding-left: 76px;
|
||||
}
|
||||
}
|
||||
|
||||
.qc-label-short {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.qc-label-full {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.qc-label-short {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.back-only-bar .MuiButton-root {
|
||||
height: 38px;
|
||||
min-height: 38px;
|
||||
padding: 0 0.85rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.72rem;
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import { useLocation, useRouter } from "@tanstack/react-router";
|
||||
import React from "react";
|
||||
import QuickConnectButton from "../buttons/quickConnectButton";
|
||||
|
||||
import "./backOnly.scss";
|
||||
|
||||
export default function AppBarBackOnly() {
|
||||
const { history } = useRouter();
|
||||
const location = useLocation();
|
||||
@@ -26,7 +28,7 @@ export default function AppBarBackOnly() {
|
||||
<IconButton
|
||||
size="large"
|
||||
edge="start"
|
||||
//@ts-ignore
|
||||
//@ts-expect-error
|
||||
color="white"
|
||||
aria-label="Назад"
|
||||
disabled={history.length <= 1}
|
||||
@@ -48,4 +50,4 @@ export default function AppBarBackOnly() {
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
import { getUserViewApi } from "@jellyfin/sdk/lib/utils/api/user-view-api";
|
||||
import {
|
||||
Divider,
|
||||
Drawer,
|
||||
List,
|
||||
ListItem,
|
||||
ListItemButton,
|
||||
ListItemText,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import React, { useEffect, useMemo } from "react";
|
||||
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import ListItemLink from "../listItemLink";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
interface NavigationDrawerProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
|
||||
const libraries = useQuery({
|
||||
queryKey: ["libraries"],
|
||||
queryFn: async () => {
|
||||
if (!user?.Id || !api?.accessToken) {
|
||||
return;
|
||||
}
|
||||
const libs = await getUserViewApi(api).getUserViews({
|
||||
userId: user.Id,
|
||||
});
|
||||
return libs.data;
|
||||
},
|
||||
enabled: !!user?.Id && !!api?.accessToken,
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
// Libraries can be added on the server while the app is running; refresh
|
||||
// the view list every time the drawer opens so they show up without restart.
|
||||
const refetchLibraries = libraries.refetch;
|
||||
useEffect(() => {
|
||||
if (open) refetchLibraries();
|
||||
}, [open, refetchLibraries]);
|
||||
|
||||
const drawerPaperProps = useMemo(() => {
|
||||
return {
|
||||
className: "glass library-drawer",
|
||||
elevation: 6,
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
open={open}
|
||||
slotProps={{ paper: drawerPaperProps }}
|
||||
className="library-drawer"
|
||||
onClose={onClose}
|
||||
>
|
||||
<div className="library-drawer-scroll">
|
||||
<List className="library-drawer-top">
|
||||
<ListItem>
|
||||
<ListItemButton onClick={onClose}>
|
||||
<span className="material-symbols-rounded">menu_open</span>
|
||||
<div style={{ marginLeft: "8px" }}>Закрыть</div>
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Divider variant="middle" />
|
||||
<Typography
|
||||
variant="overline"
|
||||
sx={{ display: "block", px: 2, pt: 1.5, opacity: 0.55 }}
|
||||
>
|
||||
Обзор
|
||||
</Typography>
|
||||
<List>
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
to="/home"
|
||||
icon="home"
|
||||
primary="Главная"
|
||||
onClick={onClose}
|
||||
/>
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
to="/search"
|
||||
search={{ query: "" }}
|
||||
icon="search"
|
||||
primary="Поиск"
|
||||
onClick={onClose}
|
||||
/>
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
to="/remote"
|
||||
icon="settings_remote"
|
||||
primary="Пульт"
|
||||
onClick={onClose}
|
||||
/>
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
to="/downloads"
|
||||
icon="download"
|
||||
primary="Загрузки"
|
||||
onClick={onClose}
|
||||
/>
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
to="/favorite"
|
||||
icon="favorite"
|
||||
primary="Избранное"
|
||||
onClick={onClose}
|
||||
/>
|
||||
<ListItem className="library-drawer-item">
|
||||
<ListItemButton
|
||||
onClick={() => {
|
||||
onClose();
|
||||
openSyncPlayDialog();
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">groups</span>
|
||||
<ListItemText primary="Смотреть вместе" />
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
{libraries.isSuccess &&
|
||||
libraries.data?.Items?.map((library) => (
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
key={library.Id}
|
||||
to="/library/$id"
|
||||
params={{ id: library.Id ?? "" }}
|
||||
icon={
|
||||
library.CollectionType && getTypeIcon(library.CollectionType)
|
||||
}
|
||||
primary={library.Name ?? "Библиотека"}
|
||||
onClick={onClose}
|
||||
/>
|
||||
))}
|
||||
</List>
|
||||
<Divider variant="middle" />
|
||||
<Typography
|
||||
variant="overline"
|
||||
sx={{ display: "block", px: 2, pt: 1.5, opacity: 0.55 }}
|
||||
>
|
||||
Настройки
|
||||
</Typography>
|
||||
<List>
|
||||
<ListItemLink
|
||||
to="/settings/preferences"
|
||||
icon="settings"
|
||||
primary="Настройки"
|
||||
className="library-drawer-item"
|
||||
onClick={onClose}
|
||||
/>
|
||||
<ListItemLink
|
||||
to="/settings/changeServer"
|
||||
icon="dns"
|
||||
primary="Сменить сервер"
|
||||
className="library-drawer-item"
|
||||
onClick={onClose}
|
||||
/>
|
||||
<ListItemLink
|
||||
to="/settings/about"
|
||||
icon="info"
|
||||
primary="О приложении"
|
||||
className="library-drawer-item"
|
||||
onClick={onClose}
|
||||
/>
|
||||
</List>
|
||||
</div>
|
||||
</Drawer>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,330 @@
|
||||
:root {
|
||||
--app-titlebar-height: 64px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
:root {
|
||||
--app-titlebar-height: calc(96px + var(--safe-top));
|
||||
}
|
||||
}
|
||||
|
||||
html:not(.has-app-titlebar) {
|
||||
--app-titlebar-height: 0px;
|
||||
}
|
||||
|
||||
/* One titlebar for the whole app: brand and sections on the left, utilities
|
||||
and window buttons on the right. It floats above the page; page content
|
||||
insets itself by `--app-titlebar-height`, so route roots all start at y=0
|
||||
and transitions never shift the page vertically. */
|
||||
.app-titlebar {
|
||||
position: fixed;
|
||||
inset: 0 0 auto;
|
||||
z-index: 1000;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
||||
grid-template-areas: "start nav actions";
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
height: var(--app-titlebar-height);
|
||||
padding: 0 clamp(1.1rem, 2.4vw, 2.4rem);
|
||||
box-sizing: border-box;
|
||||
color: #fff;
|
||||
background: transparent;
|
||||
isolation: isolate;
|
||||
|
||||
/* Two layers that cross-fade: the glass surface and the soft gradient used
|
||||
while the titlebar floats over the home hero. No hard border between the
|
||||
bar and the page. */
|
||||
&::before,
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: -1;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&::before {
|
||||
inset: 0 0 -14px;
|
||||
background: rgb(12 13 18 / 0.74);
|
||||
backdrop-filter: blur(24px) saturate(170%);
|
||||
mask-image: linear-gradient(
|
||||
to bottom,
|
||||
#000 calc(100% - 14px),
|
||||
transparent 100%
|
||||
);
|
||||
-webkit-mask-image: linear-gradient(
|
||||
to bottom,
|
||||
#000 calc(100% - 14px),
|
||||
transparent 100%
|
||||
);
|
||||
opacity: 1;
|
||||
transition: opacity 360ms cubic-bezier(0.33, 1, 0.68, 1);
|
||||
will-change: opacity;
|
||||
}
|
||||
|
||||
&::after {
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgb(0 0 0 / 0.58) 0%,
|
||||
rgb(0 0 0 / 0.24) 62%,
|
||||
transparent 100%
|
||||
);
|
||||
opacity: 0;
|
||||
transition: opacity 360ms cubic-bezier(0.33, 1, 0.68, 1);
|
||||
will-change: opacity;
|
||||
}
|
||||
|
||||
html.is-macos & {
|
||||
padding-left: calc(clamp(1.1rem, 2.4vw, 2.4rem) + 72px);
|
||||
}
|
||||
|
||||
/* Home: transparent over the hero until the page starts scrolling. */
|
||||
&--overlay {
|
||||
&::before {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
&::after {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.MuiIconButton-root {
|
||||
width: 2.35rem;
|
||||
height: 2.35rem;
|
||||
color: rgb(255 255 255 / 0.76);
|
||||
transition:
|
||||
color 150ms ease,
|
||||
background-color 150ms ease;
|
||||
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.MuiIconButton-root.Mui-disabled {
|
||||
color: rgb(255 255 255 / 0.25);
|
||||
}
|
||||
|
||||
.window-controls {
|
||||
margin-left: 0.4rem;
|
||||
background: rgb(255 255 255 / 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
.app-titlebar-top {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.app-titlebar-start {
|
||||
grid-area: start;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.app-titlebar-brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
min-width: 0;
|
||||
padding: 0.2rem 0.35rem 0.2rem 0.15rem;
|
||||
border-radius: 10px;
|
||||
color: #fff;
|
||||
font-family: "Medeo Sans", system-ui, sans-serif;
|
||||
font-size: 1.45rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
line-height: 1;
|
||||
text-decoration: none;
|
||||
user-select: none;
|
||||
|
||||
&-mark {
|
||||
width: 2rem;
|
||||
height: 1.6rem;
|
||||
flex: 0 0 auto;
|
||||
overflow: visible;
|
||||
}
|
||||
}
|
||||
|
||||
.app-titlebar-nav {
|
||||
grid-area: nav;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.1rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.app-titlebar-nav-link {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 2.4rem;
|
||||
padding: 0 0.95rem;
|
||||
border-radius: 999px;
|
||||
color: rgb(255 255 255 / 0.64);
|
||||
font-size: 0.92rem;
|
||||
font-weight: 500;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
transition:
|
||||
color 150ms ease,
|
||||
background-color 150ms ease;
|
||||
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.07);
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.09);
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: 0.28rem;
|
||||
width: 1.35rem;
|
||||
height: 2px;
|
||||
border-radius: 2px;
|
||||
background: $clr-accent-default;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.app-titlebar-actions {
|
||||
grid-area: actions;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 0.1rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.app-titlebar-icon-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 2.35rem;
|
||||
height: 2.35rem;
|
||||
border-radius: 50%;
|
||||
color: rgb(255 255 255 / 0.76);
|
||||
text-decoration: none;
|
||||
transition:
|
||||
color 150ms ease,
|
||||
background-color 150ms ease;
|
||||
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.1);
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.35rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.app-titlebar-cast {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
html.is-android .app-titlebar-downloads {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.app-titlebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 0;
|
||||
padding: calc(var(--safe-top) + 0.3rem) 0.6rem 0.35rem;
|
||||
|
||||
.MuiIconButton-root {
|
||||
width: 2.15rem;
|
||||
height: 2.15rem;
|
||||
}
|
||||
}
|
||||
|
||||
.app-titlebar-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
height: 46px;
|
||||
}
|
||||
|
||||
.app-titlebar-start {
|
||||
min-width: 0;
|
||||
gap: 0.2rem;
|
||||
}
|
||||
|
||||
.app-titlebar-brand {
|
||||
gap: 0.4rem;
|
||||
font-size: 1.18rem;
|
||||
|
||||
&-mark {
|
||||
width: 1.55rem;
|
||||
height: 1.28rem;
|
||||
}
|
||||
}
|
||||
|
||||
.app-titlebar-nav {
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
height: 38px;
|
||||
gap: 0.05rem;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
scrollbar-width: none;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.app-titlebar-nav-link {
|
||||
height: 32px;
|
||||
padding: 0 0.72rem;
|
||||
font-size: 0.84rem;
|
||||
|
||||
&.is-active::after {
|
||||
bottom: 0.18rem;
|
||||
}
|
||||
}
|
||||
|
||||
.app-titlebar-actions {
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.app-titlebar-icon-link {
|
||||
width: 2.15rem;
|
||||
height: 2.15rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.app-titlebar {
|
||||
html.is-macos & {
|
||||
padding-left: 0.6rem;
|
||||
}
|
||||
|
||||
.window-controls {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.app-titlebar-cast,
|
||||
.app-titlebar-downloads {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
import { IconButton, Tooltip, useScrollTrigger } from "@mui/material";
|
||||
import { Link, useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import React, { useEffect, useLayoutEffect, useRef } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import BackButton from "@/components/buttons/backButton";
|
||||
import CastButton from "@/components/buttons/castButton";
|
||||
import { UserAvatarMenu } from "@/components/userAvatarMenu";
|
||||
import WindowControls from "@/components/windowControls";
|
||||
import {
|
||||
getLocalMediaTransfer,
|
||||
useCurrentMediaItem,
|
||||
} from "@/utils/methods/localTransfer";
|
||||
import useSearchStore from "@/utils/store/search";
|
||||
import { shouldShowTitlebar } from "./routeVisibility";
|
||||
import { type AppNavItem, useAppNavigation } from "./useAppNavigation";
|
||||
|
||||
import "./appTitlebar.scss";
|
||||
|
||||
const BlinkMark = () => (
|
||||
<svg
|
||||
className="app-titlebar-brand-mark"
|
||||
viewBox="0 0 40 32"
|
||||
fill="none"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<g
|
||||
stroke="currentColor"
|
||||
strokeWidth="2.2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<path d="M8.5 7.6 4.7 4.2" />
|
||||
<path d="M14.2 5.4 13.4 1.4" />
|
||||
<path d="M20.4 5.2 21.1 1.3" />
|
||||
<path d="M5.2 18.4c3.7-5.9 10.5-8.3 16.6-5.7 4.2 1.8 7.6 5 9.8 8.2-4.8 4.7-12.4 6.1-18.2 3.5-3.7-1.7-6.4-3.7-8.2-6Z" />
|
||||
<path
|
||||
d="M18.7 18.5a2.9 2.9 0 1 0 0-5.8 2.9 2.9 0 0 0 0 5.8Z"
|
||||
fill="currentColor"
|
||||
stroke="none"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
|
||||
const isItemActive = (item: AppNavItem, pathname: string) =>
|
||||
item.kind === "home"
|
||||
? pathname === "/home"
|
||||
: pathname === `/library/${item.libraryId}` ||
|
||||
(item.key === "music" && pathname.startsWith("/music/"));
|
||||
|
||||
const NavItem = ({ item, active }: { item: AppNavItem; active: boolean }) => {
|
||||
const className = `app-titlebar-nav-link${active ? " is-active" : ""}`;
|
||||
if (item.kind === "home") {
|
||||
return (
|
||||
<Link
|
||||
to="/home"
|
||||
className={className}
|
||||
aria-current={active ? "page" : undefined}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Link
|
||||
to="/library/$id"
|
||||
params={{ id: item.libraryId }}
|
||||
className={className}
|
||||
aria-current={active ? "page" : undefined}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
|
||||
export const AppTitlebar = () => {
|
||||
const { pathname } = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const visible = shouldShowTitlebar(pathname);
|
||||
const isHome = pathname === "/home";
|
||||
const scrolled = useScrollTrigger({
|
||||
disableHysteresis: true,
|
||||
threshold: 20,
|
||||
});
|
||||
const navigation = useAppNavigation(visible);
|
||||
const navRef = useRef<HTMLElement | null>(null);
|
||||
const currentMedia = useCurrentMediaItem();
|
||||
|
||||
const toggleSearchDialog = useSearchStore(
|
||||
useShallow((s) => s.toggleSearchDialog),
|
||||
);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
document.documentElement.classList.toggle("has-app-titlebar", visible);
|
||||
}, [visible]);
|
||||
|
||||
useEffect(() => {
|
||||
const active = navRef.current?.querySelector<HTMLElement>(
|
||||
".app-titlebar-nav-link.is-active",
|
||||
);
|
||||
active?.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "nearest",
|
||||
inline: "center",
|
||||
});
|
||||
}, [pathname, navigation.length]);
|
||||
|
||||
if (!visible) return null;
|
||||
|
||||
const overlay = isHome && !scrolled;
|
||||
|
||||
return (
|
||||
<>
|
||||
<header
|
||||
className={`app-titlebar${overlay ? " app-titlebar--overlay" : ""}`}
|
||||
data-tauri-drag-region
|
||||
>
|
||||
<div className="app-titlebar-top">
|
||||
<div className="app-titlebar-start" data-tauri-drag-region>
|
||||
<BackButton />
|
||||
<Link
|
||||
to="/home"
|
||||
className="app-titlebar-brand"
|
||||
aria-label="Blink — на главную"
|
||||
>
|
||||
<BlinkMark />
|
||||
<span>Blink</span>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="app-titlebar-actions" data-tauri-drag-region>
|
||||
<span className="app-titlebar-cast">
|
||||
<CastButton
|
||||
item={currentMedia}
|
||||
getTransfer={getLocalMediaTransfer}
|
||||
/>
|
||||
</span>
|
||||
<Tooltip title="Поиск">
|
||||
<IconButton onClick={toggleSearchDialog} aria-label="Поиск">
|
||||
<span className="material-symbols-rounded">search</span>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Tooltip title="Загрузки">
|
||||
<IconButton
|
||||
className="app-titlebar-downloads"
|
||||
onClick={() => navigate({ to: "/downloads" })}
|
||||
aria-label="Загрузки"
|
||||
>
|
||||
<span className="material-symbols-rounded">download</span>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Tooltip title="Настройки">
|
||||
<Link
|
||||
to="/settings/preferences"
|
||||
className="app-titlebar-icon-link"
|
||||
aria-label="Настройки"
|
||||
>
|
||||
<span className="material-symbols-rounded">settings</span>
|
||||
</Link>
|
||||
</Tooltip>
|
||||
<UserAvatarMenu />
|
||||
<WindowControls />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav
|
||||
ref={navRef}
|
||||
className="app-titlebar-nav"
|
||||
aria-label="Основная навигация"
|
||||
>
|
||||
{navigation.map((item) => (
|
||||
<NavItem
|
||||
key={item.key}
|
||||
item={item}
|
||||
active={isItemActive(item, pathname)}
|
||||
/>
|
||||
))}
|
||||
</nav>
|
||||
</header>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
const HIDDEN_PREFIXES = ["/login", "/setup", "/server", "/error", "/player"];
|
||||
|
||||
/** Routes that keep the global titlebar. Auth, setup and players do not. */
|
||||
export const shouldShowTitlebar = (pathname: string) =>
|
||||
pathname !== "/" &&
|
||||
!HIDDEN_PREFIXES.some(
|
||||
(prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`),
|
||||
);
|
||||
@@ -0,0 +1,72 @@
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getUserViewApi } from "@jellyfin/sdk/lib/utils/api/user-view-api";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMemo } from "react";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
|
||||
export type AppNavItem =
|
||||
| {
|
||||
kind: "home";
|
||||
key: "home";
|
||||
label: string;
|
||||
}
|
||||
| {
|
||||
kind: "library";
|
||||
key: "movies" | "tvshows" | "music";
|
||||
label: string;
|
||||
libraryId: string;
|
||||
};
|
||||
|
||||
const LIBRARY_NAV = [
|
||||
{ key: "movies", collectionType: "movies", label: "Фильмы" },
|
||||
{ key: "tvshows", collectionType: "tvshows", label: "Сериалы" },
|
||||
{ key: "music", collectionType: "music", label: "Музыка" },
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* The four permanent sections of the app titlebar. Library items are resolved
|
||||
* from the same cached `getUserViews` query the home page already loads.
|
||||
*/
|
||||
export const useAppNavigation = (enabled: boolean) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
|
||||
const libraries = useQuery({
|
||||
queryKey: ["libraries"],
|
||||
queryFn: async () => {
|
||||
if (!api?.accessToken || !user?.Id) return undefined;
|
||||
const response = await getUserViewApi(api).getUserViews({
|
||||
userId: user.Id,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
enabled: enabled && !!api?.accessToken && !!user?.Id,
|
||||
staleTime: 5 * 60 * 1000,
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const items = useMemo<AppNavItem[]>(() => {
|
||||
const list: AppNavItem[] = [
|
||||
{ kind: "home", key: "home", label: "Главная" },
|
||||
];
|
||||
const views: BaseItemDto[] = libraries.data?.Items ?? [];
|
||||
|
||||
for (const entry of LIBRARY_NAV) {
|
||||
const library = views.find(
|
||||
(view) => view.Id && view.CollectionType === entry.collectionType,
|
||||
);
|
||||
if (!library?.Id) continue;
|
||||
list.push({
|
||||
kind: "library",
|
||||
key: entry.key,
|
||||
label: entry.label,
|
||||
libraryId: library.Id,
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
}, [libraries.data]);
|
||||
|
||||
return items;
|
||||
};
|
||||
@@ -8,9 +8,9 @@ import useRemoteControlStore, {
|
||||
|
||||
type CastButtonProps = {
|
||||
item?: BaseItemDto | null;
|
||||
transfer?: Omit<RemoteTransfer, "item">;
|
||||
transfer?: RemoteTransfer;
|
||||
/** Computed on click so playback position/queue are current. */
|
||||
getTransfer?: () => Omit<RemoteTransfer, "item">;
|
||||
getTransfer?: () => RemoteTransfer | null;
|
||||
size?: "small" | "medium" | "large";
|
||||
};
|
||||
|
||||
@@ -22,16 +22,28 @@ const CastButton = ({
|
||||
}: CastButtonProps) => {
|
||||
const openDialog = useRemoteControlStore((s) => s.openDialog);
|
||||
return (
|
||||
<Tooltip title={item ? "Воспроизвести на другом устройстве" : "Удалённое управление"}>
|
||||
<Tooltip
|
||||
title={
|
||||
item
|
||||
? "Передать текущее медиа на устройство"
|
||||
: "Удалённое управление"
|
||||
}
|
||||
>
|
||||
<IconButton
|
||||
size={size}
|
||||
aria-label={item ? "Воспроизвести на другом устройстве" : "Удалённое управление"}
|
||||
onClick={() =>
|
||||
openDialog({
|
||||
...(getTransfer ? getTransfer() : transfer),
|
||||
item: item ?? null,
|
||||
})
|
||||
aria-label={
|
||||
item
|
||||
? "Передать текущее медиа на устройство"
|
||||
: "Удалённое управление"
|
||||
}
|
||||
onClick={() => {
|
||||
const computed = getTransfer ? getTransfer() : transfer;
|
||||
const resolvedItem = item ?? computed?.item ?? null;
|
||||
openDialog({
|
||||
...(computed ?? {}),
|
||||
item: resolvedItem,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">cast</span>
|
||||
</IconButton>
|
||||
|
||||
@@ -207,6 +207,7 @@ const CardContent = ({
|
||||
opacity: 0.9,
|
||||
fontSize: "0.875rem",
|
||||
fontWeight: 500,
|
||||
lineHeight: 1.3,
|
||||
whiteSpace: "nowrap",
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
@@ -218,6 +219,7 @@ const CardContent = ({
|
||||
style={{
|
||||
opacity: 0.6,
|
||||
fontSize: "0.75rem",
|
||||
lineHeight: 1.3,
|
||||
whiteSpace: "nowrap",
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
.follow-me-card {
|
||||
--follow-accent: hsl(266 32% 22%);
|
||||
|
||||
position: fixed;
|
||||
left: 24px;
|
||||
bottom: 24px;
|
||||
z-index: 1300;
|
||||
isolation: isolate;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: 0.85rem;
|
||||
width: min(390px, calc(100vw - 48px));
|
||||
padding: 0.8rem;
|
||||
overflow: hidden;
|
||||
border-radius: 20px;
|
||||
background:
|
||||
linear-gradient(135deg, rgb(255 255 255 / 0.1), rgb(255 255 255 / 0.025)),
|
||||
rgb(17 15 32 / 0.8);
|
||||
border: 1px solid rgb(255 255 255 / 0.12);
|
||||
box-shadow:
|
||||
0 24px 60px rgb(0 0 0 / 0.5),
|
||||
inset 0 1px 0 rgb(255 255 255 / 0.1);
|
||||
backdrop-filter: blur(26px) saturate(165%);
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: -40%;
|
||||
z-index: -1;
|
||||
pointer-events: none;
|
||||
background: radial-gradient(
|
||||
circle at 12% 20%,
|
||||
var(--follow-accent),
|
||||
transparent 60%
|
||||
);
|
||||
opacity: 0.38;
|
||||
filter: blur(26px);
|
||||
}
|
||||
|
||||
> img {
|
||||
width: 58px;
|
||||
height: 86px;
|
||||
flex: 0 0 auto;
|
||||
object-fit: cover;
|
||||
border-radius: 11px;
|
||||
box-shadow: 0 10px 24px rgb(0 0 0 / 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.follow-me-card {
|
||||
left: 12px;
|
||||
right: 12px;
|
||||
bottom: calc(88px + var(--safe-bottom));
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
@@ -3,26 +3,24 @@ import {
|
||||
BaseItemKind,
|
||||
type SessionInfoDto,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
IconButton,
|
||||
Paper,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { Box, Button, IconButton, Tooltip, Typography } from "@mui/material";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { motion } from "motion/react";
|
||||
import { useSnackbar } from "notistack";
|
||||
import React, { useCallback, useMemo, useState } from "react";
|
||||
import {
|
||||
getBlinkDeviceName,
|
||||
useBlinkSessions,
|
||||
} from "@/utils/methods/blinkSessions";
|
||||
import { getCoverPalette } from "@/utils/methods/coverColor";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { transferSessionToLocal } from "@/utils/methods/transferPlayback";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
import useRealtimeStore from "@/utils/store/realtime";
|
||||
|
||||
import "./followMe.scss";
|
||||
|
||||
const DISMISS_STORAGE_KEY = "blink:follow-me-dismissed";
|
||||
const DISMISS_TTL_MS = 30 * 60 * 1000;
|
||||
@@ -53,8 +51,7 @@ const formatTime = (ticks: number) => {
|
||||
: `${minutes}:${String(seconds).padStart(2, "0")}`;
|
||||
};
|
||||
|
||||
const deviceLabel = (session: SessionInfoDto) =>
|
||||
session.DeviceName || session.Client || "другое устройство";
|
||||
const deviceLabel = (session: SessionInfoDto) => getBlinkDeviceName(session);
|
||||
|
||||
const posterId = (item: BaseItemDto) =>
|
||||
item.ImageTags?.Primary ? item.Id : (item.SeriesId ?? item.Id);
|
||||
@@ -74,32 +71,18 @@ const FollowMe = () => {
|
||||
Boolean(state.playbackStream && state.metadata.item?.Id),
|
||||
);
|
||||
const localAudioActive = useAudioPlayback((state) =>
|
||||
Boolean(state.display && state.item?.Id),
|
||||
Boolean(state.display && state.item?.Id && state.player.playing),
|
||||
);
|
||||
const localActive = localVideoActive || localAudioActive;
|
||||
|
||||
const realtimeSessions = useRealtimeStore((state) => state.sessions);
|
||||
const sessionsQuery = useQuery({
|
||||
queryKey: ["remoteSessions"],
|
||||
queryFn: async () => {
|
||||
if (!api || !user?.Id) return [];
|
||||
return (await getSessionApi(api).getSessions()).data;
|
||||
},
|
||||
enabled: Boolean(api && user?.Id) && !localActive,
|
||||
refetchInterval: localActive ? false : 15_000,
|
||||
networkMode: "always",
|
||||
});
|
||||
const blink = useBlinkSessions(!localActive);
|
||||
|
||||
const [dismissed, setDismissed] = useState<DismissedMap>(readDismissed);
|
||||
const [transferring, setTransferring] = useState(false);
|
||||
|
||||
const candidate = useMemo(() => {
|
||||
if (!api || !user?.Id || localActive) return undefined;
|
||||
const sessions =
|
||||
realtimeSessions.length > 0
|
||||
? realtimeSessions
|
||||
: (sessionsQuery.data ?? []);
|
||||
const options = sessions.filter((session) => {
|
||||
const options = blink.sessions.filter((session) => {
|
||||
const item = session.NowPlayingItem;
|
||||
const lastCheckIn = session.LastPlaybackCheckIn
|
||||
? Date.parse(session.LastPlaybackCheckIn)
|
||||
@@ -109,8 +92,6 @@ const FollowMe = () => {
|
||||
return (
|
||||
Boolean(session.Id && item?.Id) &&
|
||||
!stale &&
|
||||
session.DeviceId !== api.deviceInfo.id &&
|
||||
session.UserId === user.Id &&
|
||||
item?.Type !== BaseItemKind.Photo &&
|
||||
(item?.Type === BaseItemKind.Audio ||
|
||||
item?.Type === BaseItemKind.AudioBook ||
|
||||
@@ -137,14 +118,7 @@ const FollowMe = () => {
|
||||
const key = `${session.Id}:${item.Id}`;
|
||||
if (dismissed[key]) return undefined;
|
||||
return { session, item, position, key };
|
||||
}, [
|
||||
api,
|
||||
user?.Id,
|
||||
localActive,
|
||||
realtimeSessions,
|
||||
sessionsQuery.data,
|
||||
dismissed,
|
||||
]);
|
||||
}, [api, user?.Id, localActive, blink.sessions, dismissed]);
|
||||
|
||||
const dismiss = useCallback((key: string) => {
|
||||
setDismissed((current) => {
|
||||
@@ -191,24 +165,16 @@ const FollowMe = () => {
|
||||
);
|
||||
|
||||
return (
|
||||
<Paper
|
||||
elevation={10}
|
||||
sx={{
|
||||
position: "fixed",
|
||||
left: 24,
|
||||
bottom: 24,
|
||||
zIndex: 1300,
|
||||
display: "flex",
|
||||
gap: 1.5,
|
||||
alignItems: "stretch",
|
||||
width: "min(360px, calc(100vw - 48px))",
|
||||
p: 1.25,
|
||||
borderRadius: "18px",
|
||||
background: "rgba(18, 16, 38, 0.94)",
|
||||
border: "1px solid rgba(255, 255, 255, 0.1)",
|
||||
backdropFilter: "blur(24px)",
|
||||
boxShadow: "0 16px 48px rgba(0, 0, 0, 0.45)",
|
||||
}}
|
||||
<motion.div
|
||||
className="follow-me-card"
|
||||
style={
|
||||
{ "--follow-accent": getCoverPalette(item).base } as React.CSSProperties
|
||||
}
|
||||
initial={{ opacity: 0, y: 18, scale: 0.97 }}
|
||||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||
exit={{ opacity: 0, y: 12, scale: 0.98 }}
|
||||
whileHover={{ y: -2 }}
|
||||
transition={{ type: "spring", stiffness: 380, damping: 32 }}
|
||||
>
|
||||
<Box
|
||||
component="img"
|
||||
@@ -270,7 +236,7 @@ const FollowMe = () => {
|
||||
</span>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</Paper>
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import ShowMoreText from "@/components/showMoreText";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import useHeaderStore from "@/utils/store/header";
|
||||
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||
|
||||
import "./itemDetail.scss";
|
||||
@@ -85,19 +84,13 @@ const ItemDetailLayout = ({
|
||||
item.Type === BaseItemKind.Video ||
|
||||
item.Type === BaseItemKind.Trailer;
|
||||
|
||||
// Show the item's artwork as the ambient page backdrop.
|
||||
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||
const hash = backdropHash ?? getDefaultBackdropHash(item);
|
||||
useEffect(() => {
|
||||
setBackdrop(hash);
|
||||
}, [hash, setBackdrop]);
|
||||
|
||||
// Show a human-readable location in the global app bar.
|
||||
const setPageTitle = useHeaderStore((state) => state.setPageTitle);
|
||||
useEffect(() => {
|
||||
setPageTitle(item.Name ?? null);
|
||||
return () => setPageTitle(null);
|
||||
}, [item.Name, setPageTitle]);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
key={item.Id}
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import {
|
||||
AppBar,
|
||||
Button,
|
||||
Chip,
|
||||
IconButton,
|
||||
@@ -13,36 +12,27 @@ import {
|
||||
TextField,
|
||||
Tooltip,
|
||||
Typography,
|
||||
useScrollTrigger,
|
||||
} from "@mui/material";
|
||||
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { getRouteApi, useNavigate } from "@tanstack/react-router";
|
||||
import { useSnackbar } from "notistack";
|
||||
import type { ChangeEvent } from "react";
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { AVAILABLE_VIEWS, SORT_BY_OPTIONS } from "@/utils/constants/library";
|
||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||
import {
|
||||
generateAudioStreamUrl,
|
||||
playAudio,
|
||||
} from "@/utils/store/audioPlayback";
|
||||
import { setQueue } from "@/utils/store/queue";
|
||||
// import removed: header reads name/count from Zustand slice
|
||||
import { generateAudioStreamUrl, playAudio } from "@/utils/store/audioPlayback";
|
||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||
import useSearchStore from "@/utils/store/search";
|
||||
import { NavigationDrawer } from "../appBar/navigationDrawer";
|
||||
import BackButton from "../buttons/backButton";
|
||||
import CastButton from "../buttons/castButton";
|
||||
import { setQueue } from "@/utils/store/queue";
|
||||
import { FiltersDialogTrigger } from "../filtersDialog";
|
||||
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||
import WindowControls from "../windowControls";
|
||||
import "./libraryHeader.scss";
|
||||
|
||||
const route = getRouteApi("/_api/library/$id");
|
||||
|
||||
const MemoizeBackButton = React.memo(BackButton);
|
||||
|
||||
/**
|
||||
* Page-level toolbar for a library: title, count, view, sorting and filters.
|
||||
* Global navigation and window controls live in the app titlebar.
|
||||
*/
|
||||
export const LibraryHeader = () => {
|
||||
const { id: currentLibraryId } = route.useParams();
|
||||
const { api, user } = route.useRouteContext();
|
||||
@@ -51,7 +41,6 @@ export const LibraryHeader = () => {
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const [shuffling, setShuffling] = useState(false);
|
||||
|
||||
// Zustand library state (selected via shallow comparator)
|
||||
const {
|
||||
currentViewType,
|
||||
storeSortBy,
|
||||
@@ -87,7 +76,6 @@ export const LibraryHeader = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentLibraryId) return;
|
||||
// If the slice isn't initialized, these fields will be undefined
|
||||
if (
|
||||
currentViewType === undefined &&
|
||||
storeSortBy === undefined &&
|
||||
@@ -105,13 +93,10 @@ export const LibraryHeader = () => {
|
||||
storeSortAscending,
|
||||
initLibrary,
|
||||
]);
|
||||
|
||||
const currentLibrary = useSuspenseQuery(
|
||||
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||
);
|
||||
const scrollTrigger = useScrollTrigger({
|
||||
disableHysteresis: true,
|
||||
threshold: 20,
|
||||
});
|
||||
|
||||
const compatibleViews = useMemo(
|
||||
() =>
|
||||
@@ -122,7 +107,7 @@ export const LibraryHeader = () => {
|
||||
),
|
||||
[currentLibrary.data.CollectionType],
|
||||
);
|
||||
// Values from store
|
||||
|
||||
const sortBy = (storeSortBy ?? ItemSortBy.Name) as string;
|
||||
const sortAscending = storeSortAscending ?? true;
|
||||
const effectiveViewType = currentViewType as any;
|
||||
@@ -172,11 +157,6 @@ export const LibraryHeader = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// (Video type multi-select temporarily removed; logic cleaned to reduce overhead.)
|
||||
|
||||
// Prefetch helpers to reduce perceived latency on sort changes
|
||||
// filters, vts, nameStartsWith, genreIds are already selected above
|
||||
// Prefetch handler will be attached on menu items below
|
||||
const prefetchItems = useCallback(
|
||||
async (sortByValue: string, asc: boolean) => {
|
||||
if (!api || !user?.Id || !currentLibraryId || !normalizedViewType) return;
|
||||
@@ -294,99 +274,27 @@ export const LibraryHeader = () => {
|
||||
} finally {
|
||||
setShuffling(false);
|
||||
}
|
||||
}, [
|
||||
api,
|
||||
user?.Id,
|
||||
currentLibraryId,
|
||||
shuffling,
|
||||
enqueueSnackbar,
|
||||
navigate,
|
||||
]);
|
||||
}, [api, user?.Id, currentLibraryId, shuffling, enqueueSnackbar, navigate]);
|
||||
|
||||
const appBarStyling = useMemo(
|
||||
() => ({ backgroundColor: "transparent", paddingRight: "0 !important" }),
|
||||
[],
|
||||
);
|
||||
|
||||
// Read values from Zustand: name set by route, count set by grid
|
||||
const libraryName = libraryNameFromStore ?? currentLibrary.data.Name;
|
||||
const totalCount = itemsTotalCount;
|
||||
|
||||
const toggleSearchDialog = useSearchStore(
|
||||
useShallow((s) => s.toggleSearchDialog),
|
||||
);
|
||||
const handleNavigateToHome = useCallback(
|
||||
() => navigate({ to: "/home" }),
|
||||
[navigate],
|
||||
);
|
||||
const handleNavigateToFavorite = useCallback(
|
||||
() => navigate({ to: "/favorite" }),
|
||||
[navigate],
|
||||
);
|
||||
|
||||
const [showDrawer, setShowDrawer] = useState(false);
|
||||
|
||||
const handleDrawerClose = useCallback(() => {
|
||||
setShowDrawer(false);
|
||||
}, []);
|
||||
|
||||
const handleDrawerOpen = useCallback(() => {
|
||||
setShowDrawer(true);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppBar
|
||||
data-tauri-drag-region
|
||||
className={
|
||||
scrollTrigger
|
||||
? "library-header scrolling flex flex-row"
|
||||
: "library-header flex flex-row"
|
||||
}
|
||||
style={appBarStyling}
|
||||
elevation={0}
|
||||
color="transparent"
|
||||
>
|
||||
<div className="flex flex-row" data-tauri-drag-region style={{ gap: "0.6em" }}>
|
||||
<IconButton
|
||||
onClick={handleDrawerOpen}
|
||||
aria-label="Открыть меню"
|
||||
title="Открыть меню"
|
||||
>
|
||||
<div className="material-symbols-rounded">menu</div>
|
||||
</IconButton>
|
||||
<MemoizeBackButton />
|
||||
<IconButton
|
||||
onClick={handleNavigateToHome}
|
||||
aria-label="Главная"
|
||||
title="Главная"
|
||||
>
|
||||
<div
|
||||
className={
|
||||
location.pathname === "/home"
|
||||
? "material-symbols-rounded fill"
|
||||
: "material-symbols-rounded"
|
||||
}
|
||||
>
|
||||
home
|
||||
</div>
|
||||
</IconButton>
|
||||
</div>
|
||||
<div
|
||||
className="flex flex-row library-header-center"
|
||||
style={{ gap: "0.6em" }}
|
||||
>
|
||||
<div
|
||||
className="library-title-count flex flex-row flex-align-center"
|
||||
title={`${libraryName}${typeof totalCount === "number" ? ` · ${totalCount.toLocaleString()} элементов` : ""}`}
|
||||
>
|
||||
<Typography variant="subtitle1" noWrap align="center">
|
||||
<div className="library-toolbar">
|
||||
<div className="library-toolbar-heading">
|
||||
<Typography variant="h5" noWrap className="library-toolbar-title">
|
||||
{libraryName}
|
||||
</Typography>
|
||||
{typeof totalCount === "number" && (
|
||||
<Chip label={totalCount} sx={{ px: 0.5, ml: 1 }} />
|
||||
<Chip
|
||||
size="small"
|
||||
label={totalCount.toLocaleString()}
|
||||
className="library-toolbar-count"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="library-toolbar-controls">
|
||||
<TextField
|
||||
select
|
||||
size="small"
|
||||
@@ -411,6 +319,7 @@ export const LibraryHeader = () => {
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
|
||||
{isMusicSongs && (
|
||||
<Tooltip title="Перемешать все композиции">
|
||||
<Button
|
||||
@@ -435,19 +344,21 @@ export const LibraryHeader = () => {
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
<IconButton
|
||||
onClick={handleSortAscendingToggle}
|
||||
aria-label="Изменить порядок сортировки"
|
||||
>
|
||||
<div
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
transform: sortAscending ? "rotateX(0deg)" : "rotateX(180deg)",
|
||||
}}
|
||||
>
|
||||
sort
|
||||
</div>
|
||||
</span>
|
||||
</IconButton>
|
||||
|
||||
<TextField
|
||||
select
|
||||
size="small"
|
||||
@@ -494,35 +405,9 @@ export const LibraryHeader = () => {
|
||||
);
|
||||
})}
|
||||
</TextField>
|
||||
|
||||
<FiltersDialogTrigger />
|
||||
</div>
|
||||
<div
|
||||
className="library-header-actions flex flex-row"
|
||||
style={{ gap: "0.6em" }}
|
||||
>
|
||||
<span className="library-header-cast">
|
||||
<CastButton />
|
||||
</span>
|
||||
<IconButton
|
||||
onClick={toggleSearchDialog}
|
||||
aria-label="Поиск"
|
||||
title="Поиск"
|
||||
>
|
||||
<div className="material-symbols-rounded">search</div>
|
||||
</IconButton>
|
||||
<IconButton
|
||||
className="library-header-favorite"
|
||||
onClick={handleNavigateToFavorite}
|
||||
aria-label="Избранное"
|
||||
title="Избранное"
|
||||
>
|
||||
<div className="material-symbols-rounded">favorite</div>
|
||||
</IconButton>
|
||||
<UserAvatarMenu />
|
||||
<WindowControls />
|
||||
</div>
|
||||
</AppBar>
|
||||
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -1,56 +1,39 @@
|
||||
@media (max-width: 980px) {
|
||||
.library-header-cast,
|
||||
.library-header-favorite {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.library-header {
|
||||
.library-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
// Fixed at the very top so the row of controls sits on the same level as
|
||||
// the home page header instead of floating further down the page.
|
||||
inset: 1em 2em auto 2em !important;
|
||||
border-radius: 9999px;
|
||||
margin: 0 auto;
|
||||
position: fixed;
|
||||
width: calc(100vw - 4em) !important;
|
||||
z-index: 10;
|
||||
// Keep the scrolled pill surface behind the controls but above the page.
|
||||
isolation: isolate;
|
||||
padding: 0.25em !important;
|
||||
transition: background-color 0.2s ease-in-out, opacity 0.2s ease-in-out;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem 1.5rem;
|
||||
padding: 0 $page-margin;
|
||||
margin-bottom: 0.25rem;
|
||||
|
||||
html.is-macos & {
|
||||
// The window has an overlay titlebar: shift the whole pill clear of the
|
||||
// traffic lights, matching the home header's left edge for the controls.
|
||||
width: calc(100vw - 4em - 64px) !important;
|
||||
left: calc(2em + 64px) !important;
|
||||
right: 2em !important;
|
||||
&-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.6rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: -0.35em;
|
||||
pointer-events: none;
|
||||
border-radius: inherit;
|
||||
// Solid titlebar surface: no glass/blur.
|
||||
background-color: $clr-background-default;
|
||||
border: 1px solid rgb(255 255 255 / 0.08);
|
||||
box-shadow: 0 4px 20px rgb(0 0 0 / 0.4);
|
||||
opacity: 0;
|
||||
z-index: -1;
|
||||
transition: opacity 150ms;
|
||||
}
|
||||
&.scrolling {
|
||||
&::after {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
&-title {
|
||||
font-size: 1.35rem !important;
|
||||
font-weight: 650 !important;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
&-count {
|
||||
height: 1.7rem !important;
|
||||
border-radius: 999px !important;
|
||||
color: rgb(255 255 255 / 0.75) !important;
|
||||
}
|
||||
|
||||
&-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.music-shuffle-button {
|
||||
.material-symbols-rounded {
|
||||
@@ -70,39 +53,26 @@
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.library-header {
|
||||
inset: calc(0.5em + var(--safe-top)) 0.5em auto 0.5em !important;
|
||||
width: auto !important;
|
||||
flex-wrap: wrap;
|
||||
border-radius: 22px;
|
||||
padding: 0.3em 0.5em !important;
|
||||
row-gap: 0.2em;
|
||||
.library-toolbar {
|
||||
align-items: flex-start;
|
||||
gap: 0.4rem;
|
||||
padding: 0 1rem;
|
||||
margin-bottom: 0.15rem;
|
||||
|
||||
html.is-macos & {
|
||||
left: 76px !important;
|
||||
right: 0.5em !important;
|
||||
width: auto !important;
|
||||
}
|
||||
|
||||
> .flex.flex-row:first-child {
|
||||
[aria-label="Главная"] {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.library-header-center {
|
||||
order: 3;
|
||||
&-heading {
|
||||
width: 100%;
|
||||
padding-top: 0.35em;
|
||||
border-top: 1px solid rgb(255 255 255 / 0.08);
|
||||
gap: 0.4em !important;
|
||||
|
||||
.library-title-count {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&-title {
|
||||
font-size: 1.15rem !important;
|
||||
}
|
||||
|
||||
&-controls {
|
||||
width: 100%;
|
||||
gap: 0.35rem;
|
||||
|
||||
.MuiTextField-root {
|
||||
flex: 1 1 0;
|
||||
flex: 1 1 8rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@@ -114,17 +84,5 @@
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.library-header-actions {
|
||||
gap: 0.15em !important;
|
||||
}
|
||||
}
|
||||
|
||||
.library-items {
|
||||
padding: calc(8.4em + var(--safe-top)) 0.75rem calc(7.5em + var(--safe-bottom)) !important;
|
||||
}
|
||||
|
||||
.alpha-selector {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,15 @@ import { useWindowVirtualizer } from "@tanstack/react-virtual";
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import "./libraryItemsGrid.scss";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||
import { AVAILABLE_VIEWS } from "@/utils/constants/library";
|
||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||
import { getLibraryItemsQueryOptions } from "@/utils/queries/libraryItems";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
@@ -171,17 +172,34 @@ const LibraryItemsGrid = () => {
|
||||
}, [backdropItems, setBackdrop]);
|
||||
// --- Virtualization setup ---
|
||||
const parentRef = useRef<HTMLDivElement | null>(null);
|
||||
const [containerWidth, setContainerWidth] = useState<number>(0);
|
||||
|
||||
// The library grid is inset by the page margin on both sides. Start with a
|
||||
// close estimate so the first paint already uses the right card size, then
|
||||
// correct it from the real element before paint.
|
||||
const estimateLayout = useCallback(() => {
|
||||
const width = Math.max(
|
||||
0,
|
||||
(document.documentElement.clientWidth || window.innerWidth) - 128,
|
||||
);
|
||||
const minCardWidth = width < 700 ? 140 : 180;
|
||||
return {
|
||||
width,
|
||||
columns: Math.max(1, Math.floor(width / minCardWidth)),
|
||||
};
|
||||
}, []);
|
||||
|
||||
const [containerWidth, setContainerWidth] = useState(
|
||||
() => estimateLayout().width,
|
||||
);
|
||||
const [scrollMargin, setScrollMargin] = useState<number>(0);
|
||||
|
||||
// Determine column count based on container width (simple heuristic).
|
||||
// Only width changes matter: observing height caused re-layout feedback while
|
||||
// the window was resized, and a transitioned header made rows jump.
|
||||
const [columns, setColumns] = useState(1);
|
||||
useEffect(() => {
|
||||
const [columns, setColumns] = useState(() => estimateLayout().columns);
|
||||
useLayoutEffect(() => {
|
||||
const element = parentRef.current;
|
||||
if (!element) return;
|
||||
let frame = 0;
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
let lastWidth = -1;
|
||||
|
||||
@@ -190,14 +208,13 @@ const LibraryItemsGrid = () => {
|
||||
const width = element.clientWidth;
|
||||
if (Math.abs(width - lastWidth) < 1) return;
|
||||
lastWidth = width;
|
||||
setContainerWidth(width);
|
||||
const minCardWidth = width < 700 ? 140 : 180;
|
||||
setColumns(Math.max(1, Math.floor(width / minCardWidth)));
|
||||
// Read offsetTop after the browser has applied the new columns.
|
||||
frame = requestAnimationFrame(() => {
|
||||
frame = 0;
|
||||
const nextColumns = Math.max(1, Math.floor(width / minCardWidth));
|
||||
setContainerWidth(width);
|
||||
setColumns(nextColumns);
|
||||
// Read the grid offset in the same layout pass. Its top does not depend
|
||||
// on the column count, so no animation frame is needed here.
|
||||
setScrollMargin(element.offsetTop);
|
||||
});
|
||||
};
|
||||
|
||||
const schedule = () => {
|
||||
@@ -213,9 +230,8 @@ const LibraryItemsGrid = () => {
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
if (timer) clearTimeout(timer);
|
||||
if (frame) cancelAnimationFrame(frame);
|
||||
};
|
||||
}, []);
|
||||
}, [estimateLayout]);
|
||||
|
||||
const itemCount = items.data?.Items?.length ?? 0;
|
||||
// Compute number of virtual rows
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Overrides for virtualized library items layout to prevent horizontal overflow
|
||||
.library-items-container.virtualized {
|
||||
overflow-x: hidden;
|
||||
// The window is the only scroll container here. `overflow-x: hidden` used to
|
||||
// compute overflow-y as `auto`, so a nested scrollbar appeared, stole 13px of
|
||||
// width, changed the column/card size, disappeared, and repeated in a loop.
|
||||
overflow: hidden !important;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
display: block !important; // override grid from route styles
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { secToTicks } from "@/utils/date/time";
|
||||
import { isBlinkSession } from "@/utils/methods/blinkSessions";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
@@ -128,6 +129,7 @@ const PlaybackSync = () => {
|
||||
session.Id !== master.sessionId &&
|
||||
session.UserId === userId &&
|
||||
session.DeviceId !== api.deviceInfo.id &&
|
||||
isBlinkSession(session) &&
|
||||
session.NowPlayingItem?.Id === itemId,
|
||||
);
|
||||
|
||||
|
||||
@@ -10,24 +10,28 @@ import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
||||
import { useSnackbar } from "notistack";
|
||||
import React, {
|
||||
type SyntheticEvent,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import React, { type SyntheticEvent, useEffect, useRef, useState } from "react";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import { secToTicks, ticksToSec } from "@/utils/date/time";
|
||||
import {
|
||||
beginAudioPlaybackReport,
|
||||
endAudioPlaybackReport,
|
||||
reportAudioProgress,
|
||||
} from "@/utils/methods/audioPlaybackReporting";
|
||||
import { rememberAudioPlayerReturn } from "@/utils/methods/audioPlayerReturn";
|
||||
import {
|
||||
getBlinkDeviceName,
|
||||
useBlinkSessions,
|
||||
} from "@/utils/methods/blinkSessions";
|
||||
import getImageUrlsApi, {
|
||||
getPlayerCoverUrl,
|
||||
} from "@/utils/methods/getImageUrlsApi";
|
||||
import { rememberAudioPlayerReturn } from "@/utils/methods/audioPlayerReturn";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import {
|
||||
setAudioPlaying,
|
||||
setAudioRef,
|
||||
setIsMuted,
|
||||
useAudioPlayback,
|
||||
@@ -66,7 +70,11 @@ const AudioPlayer = () => {
|
||||
const openRemoteDialog = useRemoteControlStore((s) => s.openDialog);
|
||||
|
||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||
const [url, display, item, volume, isMuted, startTimeTicks] =
|
||||
const audioSessionRef = useRef<string | null>(null);
|
||||
const audioItemRef = useRef<BaseItemDto | null>(null);
|
||||
const audioLastPositionRef = useRef(0);
|
||||
const audioLastReportRef = useRef(0);
|
||||
const [url, display, item, volume, isMuted, startTimeTicks, audioPlaying] =
|
||||
useAudioPlayback((state) => [
|
||||
state.url,
|
||||
state.display,
|
||||
@@ -74,11 +82,54 @@ const AudioPlayer = () => {
|
||||
state.player.volume,
|
||||
state.player.isMuted,
|
||||
state.startTimeTicks,
|
||||
state.player.playing,
|
||||
]);
|
||||
const seekAppliedRef = useRef(false);
|
||||
useEffect(() => {
|
||||
seekAppliedRef.current = false;
|
||||
}, [item?.Id]);
|
||||
}, [item?.Id, startTimeTicks]);
|
||||
|
||||
// Report audio playback to Jellyfin. Without this the server session stays
|
||||
// idle, so audio cannot be cast, taken over, followed or synced.
|
||||
useEffect(() => {
|
||||
if (!api || !display || !item?.Id) {
|
||||
const previousItem = audioItemRef.current;
|
||||
const previousSession = audioSessionRef.current;
|
||||
if (api && previousItem && previousSession) {
|
||||
endAudioPlaybackReport(
|
||||
api,
|
||||
previousItem,
|
||||
previousSession,
|
||||
audioLastPositionRef.current,
|
||||
);
|
||||
}
|
||||
audioItemRef.current = null;
|
||||
audioSessionRef.current = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const playSessionId = beginAudioPlaybackReport(api, item, startTimeTicks);
|
||||
audioSessionRef.current = playSessionId;
|
||||
audioItemRef.current = item;
|
||||
audioLastPositionRef.current = startTimeTicks;
|
||||
audioLastReportRef.current = Date.now();
|
||||
|
||||
return () => {
|
||||
const previousItem = audioItemRef.current;
|
||||
const previousSession = audioSessionRef.current;
|
||||
if (api && previousItem && previousSession) {
|
||||
endAudioPlaybackReport(
|
||||
api,
|
||||
previousItem,
|
||||
previousSession,
|
||||
audioLastPositionRef.current,
|
||||
);
|
||||
}
|
||||
if (audioSessionRef.current === previousSession) {
|
||||
audioSessionRef.current = null;
|
||||
}
|
||||
};
|
||||
}, [api, display, item, startTimeTicks, url]);
|
||||
|
||||
const [tracks, currentTrack, repeatMode] = useQueue((state) => [
|
||||
state.tracks,
|
||||
@@ -88,40 +139,15 @@ const AudioPlayer = () => {
|
||||
|
||||
const [playing, setPlaying] = useState(false);
|
||||
const [progress, setProgress] = useState(0);
|
||||
const remoteActiveRef = useRef(false);
|
||||
|
||||
const sessions = useQuery({
|
||||
queryKey: ["remoteSessions"],
|
||||
queryFn: async () => {
|
||||
if (!api || !user?.Id) return [];
|
||||
const result = await getSessionApi(api).getSessions();
|
||||
return result.data;
|
||||
},
|
||||
enabled: !!api && !!user?.Id,
|
||||
// Poll quickly only while something is actually playing; idle devices
|
||||
// are checked less often, and never while the window is hidden.
|
||||
refetchInterval: () => {
|
||||
if (document.visibilityState !== "visible") return false;
|
||||
return display || remoteActiveRef.current ? 3000 : 8000;
|
||||
},
|
||||
refetchIntervalInBackground: false,
|
||||
staleTime: 1500,
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const remoteSessions = (sessions.data ?? []).filter(
|
||||
(session: SessionInfoDto) =>
|
||||
session.Id &&
|
||||
session.DeviceId !== api?.deviceInfo.id &&
|
||||
session.UserId === user?.Id,
|
||||
);
|
||||
const blink = useBlinkSessions();
|
||||
const remoteSessions = blink.sessions;
|
||||
const playingRemote = remoteSessions.find(
|
||||
(session: SessionInfoDto) => session.NowPlayingItem,
|
||||
);
|
||||
// Local playback takes precedence; otherwise follow the active remote
|
||||
// session (the bar is a compact remote as well).
|
||||
const remote = !display ? playingRemote : undefined;
|
||||
remoteActiveRef.current = Boolean(remote);
|
||||
|
||||
const activeItem: BaseItemDto | undefined | null =
|
||||
remote?.NowPlayingItem ?? item;
|
||||
@@ -129,9 +155,7 @@ const AudioPlayer = () => {
|
||||
? activeItem.ArtistItems
|
||||
: (activeItem?.AlbumArtists ?? []);
|
||||
const artistNames = artists.map((artist) => artist.Name).filter(Boolean);
|
||||
const remoteDevice = remote
|
||||
? remote.DeviceName || remote.Client || "другое устройство"
|
||||
: undefined;
|
||||
const remoteDevice = remote ? getBlinkDeviceName(remote) : undefined;
|
||||
const subtitle = remote
|
||||
? artistNames.length > 0
|
||||
? `${artistNames.join(", ")} · ${remoteDevice}`
|
||||
@@ -145,9 +169,7 @@ const AudioPlayer = () => {
|
||||
image.src = fullCoverUrl;
|
||||
void image.decode?.().catch(() => undefined);
|
||||
}, [fullCoverUrl]);
|
||||
const isPlaying = remote
|
||||
? !remote.PlayState?.IsPaused
|
||||
: playing;
|
||||
const isPlaying = remote ? !remote.PlayState?.IsPaused : playing;
|
||||
const remoteRepeat = remote?.PlayState?.RepeatMode ?? "RepeatNone";
|
||||
const remoteShuffled = remote?.PlayState?.PlaybackOrder === "Shuffle";
|
||||
const remoteVolume =
|
||||
@@ -200,6 +222,20 @@ const AudioPlayer = () => {
|
||||
}
|
||||
}, [display, url, tracks?.[currentTrack]?.Id, isMuted, volume]);
|
||||
|
||||
// The audio element is mounted with the bar. Playback is driven by the
|
||||
// store flag, not by `autoPlay`: the SyncPlay parking can pause the track
|
||||
// before the element exists, and autoPlay would override that and make the
|
||||
// group seek everyone back to the start a couple of seconds later.
|
||||
useEffect(() => {
|
||||
const element = audioRef.current;
|
||||
if (!element || !display) return;
|
||||
if (audioPlaying) {
|
||||
void element.play().catch(() => undefined);
|
||||
} else {
|
||||
element.pause();
|
||||
}
|
||||
}, [audioPlaying, display, url]);
|
||||
|
||||
useEffect(() => {
|
||||
if (audioRef.current) {
|
||||
audioRef.current.volume = isMuted ? 0 : volume;
|
||||
@@ -285,16 +321,41 @@ const AudioPlayer = () => {
|
||||
};
|
||||
|
||||
const handleTimeUpdate = (e: SyntheticEvent<HTMLAudioElement>) => {
|
||||
setProgress(secToTicks(e.currentTarget.currentTime));
|
||||
const ticks = secToTicks(e.currentTarget.currentTime);
|
||||
setProgress(ticks);
|
||||
audioLastPositionRef.current = ticks;
|
||||
if (
|
||||
api &&
|
||||
item?.Id &&
|
||||
audioSessionRef.current &&
|
||||
Date.now() - audioLastReportRef.current >= 10_000
|
||||
) {
|
||||
audioLastReportRef.current = Date.now();
|
||||
reportAudioProgress(
|
||||
api,
|
||||
item,
|
||||
audioSessionRef.current,
|
||||
ticks,
|
||||
e.currentTarget.paused,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleEnded = () => {
|
||||
const endedAt = item?.RunTimeTicks ?? audioLastPositionRef.current;
|
||||
audioLastPositionRef.current = endedAt;
|
||||
setPlaying(false);
|
||||
setAudioPlaying(false);
|
||||
if (api && item && audioSessionRef.current) {
|
||||
reportAudioProgress(api, item, audioSessionRef.current, endedAt, true);
|
||||
}
|
||||
if (useQueue.getState().repeatMode === "one" && audioRef.current) {
|
||||
audioRef.current.currentTime = 0;
|
||||
audioRef.current.play();
|
||||
audioLastPositionRef.current = 0;
|
||||
void audioRef.current.play();
|
||||
setAudioPlaying(true);
|
||||
return;
|
||||
}
|
||||
setPlaying(false);
|
||||
const nextIndex = getNextTrackIndex();
|
||||
if (nextIndex !== undefined && api && user?.Id) {
|
||||
playItemFromQueue(nextIndex, user.Id, api);
|
||||
@@ -323,17 +384,42 @@ const AudioPlayer = () => {
|
||||
|
||||
const onPlay = () => {
|
||||
setPlaying(true);
|
||||
setAudioPlaying(true);
|
||||
updatePositionState();
|
||||
if (navigator.mediaSession) {
|
||||
navigator.mediaSession.playbackState = "playing";
|
||||
}
|
||||
if (api && item && audioSessionRef.current) {
|
||||
reportAudioProgress(
|
||||
api,
|
||||
item,
|
||||
audioSessionRef.current,
|
||||
secToTicks(audioRef.current?.currentTime ?? 0),
|
||||
false,
|
||||
);
|
||||
}
|
||||
};
|
||||
const onPause = () => {
|
||||
setPlaying(false);
|
||||
const element = audioRef.current;
|
||||
// A source change (transfer/next track) pauses the old media before
|
||||
// metadata arrives. That is not a user pause: pausing the store here
|
||||
// would immediately stop the new track as well.
|
||||
if (element && element.readyState < 1) return;
|
||||
setAudioPlaying(false);
|
||||
updatePositionState();
|
||||
if (navigator.mediaSession) {
|
||||
navigator.mediaSession.playbackState = "paused";
|
||||
}
|
||||
if (api && item && audioSessionRef.current) {
|
||||
reportAudioProgress(
|
||||
api,
|
||||
item,
|
||||
audioSessionRef.current,
|
||||
secToTicks(audioRef.current?.currentTime ?? 0),
|
||||
true,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const remoteCommand = async (
|
||||
@@ -348,7 +434,7 @@ const AudioPlayer = () => {
|
||||
seekPositionTicks,
|
||||
controllingUserId: user?.Id,
|
||||
});
|
||||
await sessions.refetch();
|
||||
await blink.refetch();
|
||||
} catch (error) {
|
||||
console.error("Команда не выполнена", error);
|
||||
enqueueSnackbar("Команда не выполнена", { variant: "error" });
|
||||
@@ -377,7 +463,7 @@ const AudioPlayer = () => {
|
||||
ControllingUserId: user?.Id,
|
||||
},
|
||||
});
|
||||
await sessions.refetch();
|
||||
await blink.refetch();
|
||||
} catch (error) {
|
||||
console.error("Remote general command failed", error);
|
||||
enqueueSnackbar("Команда не выполнена", { variant: "error" });
|
||||
@@ -409,9 +495,7 @@ const AudioPlayer = () => {
|
||||
const handleMute = () => {
|
||||
if (remote) {
|
||||
sendGeneral(
|
||||
remoteMuted
|
||||
? GeneralCommandType.Unmute
|
||||
: GeneralCommandType.Mute,
|
||||
remoteMuted ? GeneralCommandType.Unmute : GeneralCommandType.Mute,
|
||||
);
|
||||
} else {
|
||||
handleMuteToggle();
|
||||
@@ -423,7 +507,6 @@ const AudioPlayer = () => {
|
||||
|
||||
const audioElement = display ? (
|
||||
<audio
|
||||
autoPlay
|
||||
src={url}
|
||||
ref={audioRef}
|
||||
key={item?.Id ?? "noItem"}
|
||||
@@ -622,7 +705,6 @@ const AudioPlayer = () => {
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
</motion.div>
|
||||
);
|
||||
|
||||
|
||||
@@ -1,30 +1,23 @@
|
||||
import {
|
||||
PlaystateCommand,
|
||||
type SessionInfoDto,
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import type {
|
||||
BaseItemDto,
|
||||
SessionInfoDto,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||
import {
|
||||
Button,
|
||||
Chip,
|
||||
CircularProgress,
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
Divider,
|
||||
IconButton,
|
||||
LinearProgress,
|
||||
List,
|
||||
ListItem,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { Dialog, DialogContent, DialogTitle, IconButton } from "@mui/material";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { useSnackbar } from "notistack";
|
||||
import React from "react";
|
||||
import {
|
||||
getBlinkDeviceName,
|
||||
useBlinkSessions,
|
||||
} from "@/utils/methods/blinkSessions";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import {
|
||||
playOnSession,
|
||||
queueStartingWith,
|
||||
transferSessionToLocal,
|
||||
} from "@/utils/methods/transferPlayback";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { stopPlayback } from "@/utils/store/audioPlayback";
|
||||
@@ -32,64 +25,30 @@ import { useCentralStore } from "@/utils/store/central";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
import { clearQueue } from "@/utils/store/queue";
|
||||
import useRemoteControlStore from "@/utils/store/remoteControl";
|
||||
import SessionCard from "./sessionCard";
|
||||
|
||||
const TICKS_PER_SECOND = 10_000_000;
|
||||
import "./remoteControl.scss";
|
||||
|
||||
const formatTime = (ticks: number | null | undefined) => {
|
||||
const total = Math.max(0, Math.round((ticks ?? 0) / TICKS_PER_SECOND));
|
||||
const h = Math.floor(total / 3600);
|
||||
const m = Math.floor((total % 3600) / 60);
|
||||
const s = total % 60;
|
||||
return h > 0
|
||||
? `${h}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`
|
||||
: `${m}:${String(s).padStart(2, "0")}`;
|
||||
const itemImage = (api: Api | undefined, item?: BaseItemDto | null) => {
|
||||
if (!api || !item?.Id) return undefined;
|
||||
const imageItemId = item.ImageTags?.Primary
|
||||
? item.Id
|
||||
: (item.SeriesId ?? item.Id);
|
||||
return getImageUrlsApi(api).getItemImageUrlById(imageItemId, "Primary", {
|
||||
fillHeight: 144,
|
||||
fillWidth: 96,
|
||||
quality: 82,
|
||||
});
|
||||
};
|
||||
|
||||
const sessionLabel = (session: SessionInfoDto) =>
|
||||
session.DeviceName || session.Client || session.DeviceId || "Неизвестное устройство";
|
||||
|
||||
const RemoteControlDialog = () => {
|
||||
const { open, transfer, closeDialog } = useRemoteControlStore();
|
||||
const item = transfer?.item;
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const sessions = useQuery({
|
||||
queryKey: ["remoteSessions"],
|
||||
queryFn: async () => {
|
||||
if (!api || !user?.Id) return [];
|
||||
const result = await getSessionApi(api).getSessions();
|
||||
return result.data;
|
||||
},
|
||||
enabled: open && !!api && !!user?.Id,
|
||||
refetchInterval: open ? 3000 : false,
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const sendCommand = useMutation({
|
||||
mutationFn: async ({
|
||||
session,
|
||||
command,
|
||||
seekPositionTicks,
|
||||
}: {
|
||||
session: SessionInfoDto;
|
||||
command: PlaystateCommand;
|
||||
seekPositionTicks?: number;
|
||||
}) => {
|
||||
if (!api || !session.Id) return;
|
||||
await getSessionApi(api).sendPlaystateCommand({
|
||||
sessionId: session.Id,
|
||||
command,
|
||||
seekPositionTicks,
|
||||
controllingUserId: user?.Id,
|
||||
});
|
||||
},
|
||||
onError: () =>
|
||||
enqueueSnackbar("Команда не выполнена", { variant: "error" }),
|
||||
onSettled: () => sessions.refetch(),
|
||||
});
|
||||
const blink = useBlinkSessions(Boolean(open));
|
||||
const item = transfer?.item ?? null;
|
||||
|
||||
const playOn = useMutation({
|
||||
mutationFn: async (session: SessionInfoDto) => {
|
||||
@@ -103,20 +62,15 @@ const RemoteControlDialog = () => {
|
||||
});
|
||||
},
|
||||
onSuccess: async (_data, session) => {
|
||||
enqueueSnackbar(
|
||||
transfer?.kind === "audio" || transfer?.kind === "video"
|
||||
? `Воспроизведение перенесено на ${sessionLabel(session)}`
|
||||
: `Воспроизведение на ${sessionLabel(session)}`,
|
||||
{ variant: "success" },
|
||||
);
|
||||
enqueueSnackbar(`Передано на ${getBlinkDeviceName(session)}`, {
|
||||
variant: "success",
|
||||
});
|
||||
if (transfer?.kind === "audio") {
|
||||
stopPlayback();
|
||||
} else if (transfer?.kind === "video") {
|
||||
const playback = usePlaybackStore.getState();
|
||||
const transferredItemId = playback.metadata.item?.Id;
|
||||
const stoppedPosition = playback.playerState.currentTime;
|
||||
// Stop local playback first so a trailing timeupdate cannot
|
||||
// re-mark the old session as playing after we report it stopped.
|
||||
(
|
||||
document
|
||||
.querySelector("hls-video")
|
||||
@@ -137,7 +91,10 @@ const RemoteControlDialog = () => {
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn("Could not report the transferred video as stopped", error);
|
||||
console.warn(
|
||||
"Could not report the transferred video as stopped",
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,276 +106,135 @@ const RemoteControlDialog = () => {
|
||||
}),
|
||||
});
|
||||
|
||||
// Show all other sessions: some clients report SupportsRemoteControl=false
|
||||
// even though they accept playstate commands, so do not hide them.
|
||||
const remoteSessions = (sessions.data ?? []).filter(
|
||||
(session) =>
|
||||
session.Id &&
|
||||
session.DeviceId !== api?.deviceInfo.id &&
|
||||
session.UserId === user?.Id,
|
||||
);
|
||||
|
||||
const seek = (session: SessionInfoDto, offsetSeconds: number) => {
|
||||
const current = (session.PlayState?.PositionTicks ?? 0) / TICKS_PER_SECOND;
|
||||
const next = Math.max(0, current + offsetSeconds);
|
||||
sendCommand.mutate({
|
||||
session,
|
||||
command: PlaystateCommand.Seek,
|
||||
seekPositionTicks: Math.round(next * TICKS_PER_SECOND),
|
||||
const takeHere = useMutation({
|
||||
mutationFn: async (session: SessionInfoDto) => {
|
||||
if (!api || !user?.Id) return "none";
|
||||
return transferSessionToLocal(api, user.Id, session);
|
||||
},
|
||||
onSuccess: async (kind, session) => {
|
||||
if (kind === "none") {
|
||||
enqueueSnackbar("На устройстве нечего забирать", { variant: "info" });
|
||||
return;
|
||||
}
|
||||
enqueueSnackbar(`Забрано с ${getBlinkDeviceName(session)}`, {
|
||||
variant: "success",
|
||||
});
|
||||
};
|
||||
closeDialog();
|
||||
navigate({ to: kind === "audio" ? "/player/audio" : "/player" });
|
||||
},
|
||||
onError: () =>
|
||||
enqueueSnackbar("Не удалось забрать воспроизведение", {
|
||||
variant: "error",
|
||||
}),
|
||||
});
|
||||
|
||||
const previewUrl = itemImage(api, item);
|
||||
const activeSessions = blink.sessions;
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
onClose={closeDialog}
|
||||
fullWidth
|
||||
maxWidth="sm"
|
||||
maxWidth="md"
|
||||
slotProps={{
|
||||
paper: {
|
||||
className: "glass-dialog-paper",
|
||||
sx: { borderRadius: 3 },
|
||||
className: "glass-dialog-paper remote-control-dialog",
|
||||
sx: { borderRadius: "24px" },
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DialogTitle sx={{ display: "flex", alignItems: "center", gap: 1 }}>
|
||||
<DialogTitle className="remote-control-title">
|
||||
<div className="remote-control-heading">
|
||||
<span className="material-symbols-rounded">cast</span>
|
||||
<span style={{ flex: 1 }}>
|
||||
{item ? `Воспроизвести «${item.Name}» на…` : "Удалённое управление"}
|
||||
</span>
|
||||
<div className="remote-control-heading-copy">
|
||||
<span>{item ? "Передать медиа" : "Устройства Blink"}</span>
|
||||
<small>
|
||||
{activeSessions.length} Blink
|
||||
{activeSessions.length === 1 ? " устройство" : " устройств"}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<div className="remote-control-title-actions">
|
||||
<span className="remote-control-only-badge">Только Blink</span>
|
||||
<IconButton
|
||||
onClick={() => blink.refetch()}
|
||||
aria-label="Обновить устройства"
|
||||
title="Обновить устройства"
|
||||
>
|
||||
<span className="material-symbols-rounded">refresh</span>
|
||||
</IconButton>
|
||||
<IconButton onClick={closeDialog} aria-label="Закрыть">
|
||||
<span className="material-symbols-rounded">close</span>
|
||||
</IconButton>
|
||||
</div>
|
||||
</DialogTitle>
|
||||
<DialogContent sx={{ pb: 2 }}>
|
||||
{item && (
|
||||
<Typography variant="body2" sx={{ opacity: 0.7, mb: 1 }}>
|
||||
Выберите устройство для запуска воспроизведения.
|
||||
</Typography>
|
||||
)}
|
||||
{sessions.isPending ? (
|
||||
<div style={{ display: "flex", justifyContent: "center", padding: 24 }}>
|
||||
<CircularProgress size={28} />
|
||||
</div>
|
||||
) : remoteSessions.length === 0 ? (
|
||||
<Typography sx={{ opacity: 0.7, py: 2 }}>
|
||||
Нет доступных устройств. Откройте клиент Jellyfin (например, на ТВ)
|
||||
и разрешите удалённое управление.
|
||||
</Typography>
|
||||
) : (
|
||||
<List disablePadding>
|
||||
{remoteSessions.map((session) => {
|
||||
const nowPlaying = session.NowPlayingItem;
|
||||
const playState = session.PlayState;
|
||||
const duration = nowPlaying?.RunTimeTicks ?? 0;
|
||||
const position = playState?.PositionTicks ?? 0;
|
||||
const supportsControl = true;
|
||||
return (
|
||||
<React.Fragment key={session.Id}>
|
||||
<ListItem
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "stretch",
|
||||
gap: 1,
|
||||
px: 0,
|
||||
py: 1.5,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: 8,
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">tv</span>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<Typography variant="subtitle1" noWrap>
|
||||
{sessionLabel(session)}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
sx={{ opacity: 0.6, display: "block" }}
|
||||
noWrap
|
||||
>
|
||||
{[session.Client, session.UserName]
|
||||
.filter(Boolean)
|
||||
.join(" · ")}
|
||||
</Typography>
|
||||
{session.SupportsRemoteControl === false && (
|
||||
<Typography
|
||||
variant="caption"
|
||||
color="warning.main"
|
||||
sx={{ display: "block" }}
|
||||
>
|
||||
Нет канала управления (WebSocket) — проверьте
|
||||
обратный прокси.
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
{item && (
|
||||
<Button
|
||||
size="small"
|
||||
variant="contained"
|
||||
disabled={playOn.isPending || !item.Id}
|
||||
onClick={() => playOn.mutate(session)}
|
||||
>
|
||||
Смотреть здесь
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{nowPlaying ? (
|
||||
<>
|
||||
<Typography variant="body2" noWrap>
|
||||
{nowPlaying.Name}
|
||||
{nowPlaying.Genres?.length ? (
|
||||
<Chip
|
||||
component="span"
|
||||
size="small"
|
||||
label={nowPlaying.Genres[0]}
|
||||
sx={{ ml: 1 }}
|
||||
/>
|
||||
) : null}
|
||||
</Typography>
|
||||
<LinearProgress
|
||||
variant="determinate"
|
||||
value={
|
||||
duration > 0
|
||||
? Math.min(100, (position / duration) * 100)
|
||||
: 0
|
||||
}
|
||||
sx={{ borderRadius: 1 }}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
}}
|
||||
>
|
||||
<Typography variant="caption" sx={{ opacity: 0.6 }}>
|
||||
{formatTime(position)} / {formatTime(duration)}
|
||||
{playState?.IsPaused ? " · пауза" : ""}
|
||||
</Typography>
|
||||
<div style={{ display: "flex" }}>
|
||||
<Tooltip title="Назад на 10 с">
|
||||
<span>
|
||||
<IconButton
|
||||
size="small"
|
||||
disabled={!supportsControl || playState?.CanSeek === false}
|
||||
onClick={() => seek(session, -10)}
|
||||
>
|
||||
<span className="material-symbols-rounded">
|
||||
replay_10
|
||||
</span>
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Tooltip title="Предыдущий">
|
||||
<span>
|
||||
<IconButton
|
||||
size="small"
|
||||
disabled={!supportsControl}
|
||||
onClick={() =>
|
||||
sendCommand.mutate({
|
||||
session,
|
||||
command: PlaystateCommand.PreviousTrack,
|
||||
})
|
||||
}
|
||||
>
|
||||
<span className="material-symbols-rounded">
|
||||
skip_previous
|
||||
</span>
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Tooltip
|
||||
title={playState?.IsPaused ? "Смотреть" : "Пауза"}
|
||||
>
|
||||
<span>
|
||||
<IconButton
|
||||
size="small"
|
||||
disabled={!supportsControl}
|
||||
onClick={() =>
|
||||
sendCommand.mutate({
|
||||
session,
|
||||
command: PlaystateCommand.PlayPause,
|
||||
})
|
||||
}
|
||||
>
|
||||
<span className="material-symbols-rounded">
|
||||
{playState?.IsPaused
|
||||
? "play_arrow"
|
||||
: "pause"}
|
||||
</span>
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Tooltip title="Следующий">
|
||||
<span>
|
||||
<IconButton
|
||||
size="small"
|
||||
disabled={!supportsControl}
|
||||
onClick={() =>
|
||||
sendCommand.mutate({
|
||||
session,
|
||||
command: PlaystateCommand.NextTrack,
|
||||
})
|
||||
}
|
||||
>
|
||||
<span className="material-symbols-rounded">
|
||||
skip_next
|
||||
</span>
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Tooltip title="Вперёд на 10 с">
|
||||
<span>
|
||||
<IconButton
|
||||
size="small"
|
||||
disabled={!supportsControl || playState?.CanSeek === false}
|
||||
onClick={() => seek(session, 10)}
|
||||
>
|
||||
<span className="material-symbols-rounded">
|
||||
forward_10
|
||||
</span>
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Tooltip title="Остановить">
|
||||
<span>
|
||||
<IconButton
|
||||
size="small"
|
||||
disabled={!supportsControl}
|
||||
onClick={() =>
|
||||
sendCommand.mutate({
|
||||
session,
|
||||
command: PlaystateCommand.Stop,
|
||||
})
|
||||
}
|
||||
>
|
||||
<span className="material-symbols-rounded">
|
||||
stop
|
||||
</span>
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
<DialogContent className="remote-control-content">
|
||||
{item && (
|
||||
<div className="remote-control-current">
|
||||
<div className="remote-control-current-poster">
|
||||
{previewUrl ? (
|
||||
<img src={previewUrl} alt="" />
|
||||
) : (
|
||||
<Typography variant="caption" sx={{ opacity: 0.6 }}>
|
||||
Свободно
|
||||
</Typography>
|
||||
<span className="material-symbols-rounded">movie</span>
|
||||
)}
|
||||
</ListItem>
|
||||
<Divider />
|
||||
</React.Fragment>
|
||||
);
|
||||
})}
|
||||
</List>
|
||||
</div>
|
||||
<div className="remote-control-current-copy">
|
||||
<span>Сейчас на этом устройстве</span>
|
||||
<strong>{item.SeriesName ?? item.Name ?? "Медиа"}</strong>
|
||||
<small>
|
||||
{typeof transfer?.positionTicks === "number"
|
||||
? `с ${Math.floor(transfer.positionTicks / 10_000_000 / 60)} мин`
|
||||
: "Передача текущей позиции"}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{blink.isLoading ? (
|
||||
<div className="remote-control-loading">
|
||||
<span className="material-symbols-rounded animate-rotate">
|
||||
progress_activity
|
||||
</span>
|
||||
<span>Ищем Blink-устройства…</span>
|
||||
</div>
|
||||
) : activeSessions.length === 0 ? (
|
||||
<div className="remote-control-empty">
|
||||
<span className="material-symbols-rounded">devices_other</span>
|
||||
<h3>Других Blink-устройств нет</h3>
|
||||
<p>
|
||||
Запустите Blink на другом устройстве под этим пользователем. В
|
||||
списке появятся только клиенты Blink — Jellyfin Web, телевизоры и
|
||||
другие приложения сюда не попадают.
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="remote-session-grid">
|
||||
{activeSessions.map((session) => (
|
||||
<SessionCard
|
||||
key={session.Id}
|
||||
session={session}
|
||||
api={api}
|
||||
transfer={transfer}
|
||||
onSend={item ? (target) => playOn.mutate(target) : undefined}
|
||||
onTake={(target) => takeHere.mutate(target)}
|
||||
onOpenRemote={(target) => {
|
||||
closeDialog();
|
||||
navigate({
|
||||
to: "/remote",
|
||||
search: { device: target.Id ?? "" },
|
||||
});
|
||||
}}
|
||||
sending={
|
||||
playOn.isPending && playOn.variables?.Id === session.Id
|
||||
}
|
||||
taking={
|
||||
takeHere.isPending && takeHere.variables?.Id === session.Id
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
.remote-control-dialog {
|
||||
background:
|
||||
radial-gradient(circle at 12% 0%, rgb(255 79 154 / 0.16), transparent 38%),
|
||||
radial-gradient(circle at 88% 8%, rgb(120 92 255 / 0.16), transparent 42%),
|
||||
rgb(12 11 22 / 0.9) !important;
|
||||
border: 1px solid rgb(255 255 255 / 0.12);
|
||||
box-shadow:
|
||||
0 30px 90px rgb(0 0 0 / 0.6),
|
||||
inset 0 1px 0 rgb(255 255 255 / 0.08);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.remote-control-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 1.1rem 1.25rem 0.7rem !important;
|
||||
}
|
||||
|
||||
.remote-control-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.7rem;
|
||||
min-width: 0;
|
||||
|
||||
> .material-symbols-rounded {
|
||||
width: 2.4rem;
|
||||
height: 2.4rem;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 12px;
|
||||
background: rgb(255 255 255 / 0.08);
|
||||
border: 1px solid rgb(255 255 255 / 0.1);
|
||||
color: rgb(255 255 255 / 0.9);
|
||||
}
|
||||
|
||||
&-copy {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.1rem;
|
||||
min-width: 0;
|
||||
|
||||
> span {
|
||||
font-size: 1rem;
|
||||
font-weight: 650;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
> small {
|
||||
font-size: 0.7rem;
|
||||
color: rgb(255 255 255 / 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.remote-control-title-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.remote-control-only-badge {
|
||||
padding: 0.22rem 0.6rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.64rem;
|
||||
font-weight: 650;
|
||||
letter-spacing: 0.04em;
|
||||
color: #ffd0e7;
|
||||
background: rgb(255 79 154 / 0.12);
|
||||
border: 1px solid rgb(255 79 154 / 0.22);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.remote-control-content {
|
||||
padding: 0.4rem 1.25rem 1.3rem !important;
|
||||
}
|
||||
|
||||
.remote-control-current {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.8rem;
|
||||
margin-bottom: 1rem;
|
||||
padding: 0.65rem;
|
||||
border-radius: 16px;
|
||||
background:
|
||||
linear-gradient(135deg, rgb(255 255 255 / 0.08), rgb(255 255 255 / 0.02)),
|
||||
rgb(255 255 255 / 0.02);
|
||||
border: 1px solid rgb(255 255 255 / 0.09);
|
||||
box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
|
||||
|
||||
&-poster {
|
||||
width: 52px;
|
||||
height: 72px;
|
||||
flex: 0 0 auto;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
overflow: hidden;
|
||||
border-radius: 10px;
|
||||
background: rgb(255 255 255 / 0.07);
|
||||
color: rgb(255 255 255 / 0.6);
|
||||
|
||||
> img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
}
|
||||
|
||||
&-copy {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.15rem;
|
||||
min-width: 0;
|
||||
|
||||
> span {
|
||||
font-size: 0.64rem;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: rgb(255 255 255 / 0.42);
|
||||
}
|
||||
|
||||
> strong {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 0.92rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
> small {
|
||||
font-size: 0.7rem;
|
||||
color: rgb(255 255 255 / 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.remote-session-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.7rem;
|
||||
}
|
||||
|
||||
.remote-control-loading,
|
||||
.remote-control-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.6rem;
|
||||
min-height: 220px;
|
||||
padding: 1.5rem;
|
||||
text-align: center;
|
||||
color: rgb(255 255 255 / 0.6);
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 2.6rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 1.05rem;
|
||||
color: rgb(255 255 255 / 0.9);
|
||||
}
|
||||
|
||||
p {
|
||||
max-width: 46ch;
|
||||
margin: 0;
|
||||
font-size: 0.82rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.remote-control-loading .material-symbols-rounded {
|
||||
color: #ff4f9a;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.remote-control-title {
|
||||
padding: 0.9rem 0.9rem 0.5rem !important;
|
||||
}
|
||||
|
||||
.remote-control-content {
|
||||
padding: 0.3rem 0.9rem 1rem !important;
|
||||
}
|
||||
|
||||
.remote-control-only-badge {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.remote-session-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
.session-card {
|
||||
--session-accent: hsl(266 32% 22%);
|
||||
--session-deep: hsl(266 40% 9%);
|
||||
|
||||
position: relative;
|
||||
isolation: isolate;
|
||||
display: grid;
|
||||
grid-template-columns: 64px minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 0.9rem;
|
||||
padding: 0.8rem;
|
||||
border-radius: 18px;
|
||||
overflow: hidden;
|
||||
background:
|
||||
linear-gradient(135deg, rgb(255 255 255 / 0.09), rgb(255 255 255 / 0.025)),
|
||||
rgb(17 15 32 / 0.62);
|
||||
border: 1px solid rgb(255 255 255 / 0.1);
|
||||
box-shadow:
|
||||
0 12px 32px rgb(0 0 0 / 0.24),
|
||||
inset 0 1px 0 rgb(255 255 255 / 0.08);
|
||||
backdrop-filter: blur(24px) saturate(165%);
|
||||
transition:
|
||||
border-color 180ms ease,
|
||||
background-color 180ms ease,
|
||||
box-shadow 180ms ease;
|
||||
|
||||
&-glow {
|
||||
position: absolute;
|
||||
inset: -50%;
|
||||
z-index: -1;
|
||||
pointer-events: none;
|
||||
background: radial-gradient(
|
||||
circle at 18% 25%,
|
||||
var(--session-accent),
|
||||
transparent 58%
|
||||
);
|
||||
opacity: 0.32;
|
||||
filter: blur(24px);
|
||||
transition: opacity 220ms ease;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: rgb(255 255 255 / 0.2);
|
||||
box-shadow:
|
||||
0 18px 40px rgb(0 0 0 / 0.34),
|
||||
inset 0 1px 0 rgb(255 255 255 / 0.12);
|
||||
|
||||
.session-card-glow {
|
||||
opacity: 0.55;
|
||||
}
|
||||
}
|
||||
|
||||
&.is-clickable {
|
||||
cursor: pointer;
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid rgb(255 79 154 / 0.7);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
&.is-selected {
|
||||
border-color: rgb(255 255 255 / 0.3);
|
||||
box-shadow:
|
||||
0 0 0 1px rgb(255 255 255 / 0.08),
|
||||
0 18px 44px rgb(0 0 0 / 0.42),
|
||||
inset 0 1px 0 rgb(255 255 255 / 0.16);
|
||||
|
||||
.session-card-glow {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
&-poster {
|
||||
position: relative;
|
||||
width: 64px;
|
||||
height: 88px;
|
||||
flex: 0 0 auto;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
overflow: hidden;
|
||||
border-radius: 12px;
|
||||
background:
|
||||
linear-gradient(145deg, rgb(255 255 255 / 0.12), rgb(255 255 255 / 0.03)),
|
||||
var(--session-deep);
|
||||
box-shadow: 0 8px 20px rgb(0 0 0 / 0.32);
|
||||
color: rgb(255 255 255 / 0.7);
|
||||
|
||||
> img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 2rem;
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
&-status-dot {
|
||||
position: absolute;
|
||||
right: 7px;
|
||||
bottom: 7px;
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
border-radius: 50%;
|
||||
background: #5ee39a;
|
||||
box-shadow:
|
||||
0 0 0 2px rgb(10 8 20 / 0.7),
|
||||
0 0 12px #5ee39a;
|
||||
animation: session-card-pulse 1.8s ease-in-out infinite;
|
||||
|
||||
&.is-paused {
|
||||
background: #ffc46b;
|
||||
box-shadow:
|
||||
0 0 0 2px rgb(10 8 20 / 0.7),
|
||||
0 0 12px #ffc46b;
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
&-main {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
&-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&-device-icon {
|
||||
font-size: 1rem !important;
|
||||
opacity: 0.65;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
&-name {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 650;
|
||||
letter-spacing: -0.01em;
|
||||
color: rgb(255 255 255 / 0.94);
|
||||
}
|
||||
|
||||
&-status {
|
||||
margin-left: auto;
|
||||
flex: 0 0 auto;
|
||||
padding: 0.12rem 0.45rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.64rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.03em;
|
||||
color: #b9f7d1;
|
||||
background: rgb(94 227 154 / 0.12);
|
||||
border: 1px solid rgb(94 227 154 / 0.2);
|
||||
|
||||
&.is-paused {
|
||||
color: #ffdca8;
|
||||
background: rgb(255 196 107 / 0.12);
|
||||
border-color: rgb(255 196 107 / 0.2);
|
||||
}
|
||||
|
||||
&.is-idle {
|
||||
color: rgb(255 255 255 / 0.5);
|
||||
background: rgb(255 255 255 / 0.06);
|
||||
border-color: rgb(255 255 255 / 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
&-title {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 0.82rem;
|
||||
color: rgb(255 255 255 / 0.78);
|
||||
}
|
||||
|
||||
&-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
min-width: 0;
|
||||
font-size: 0.68rem;
|
||||
color: rgb(255 255 255 / 0.42);
|
||||
}
|
||||
|
||||
&-idle-copy {
|
||||
color: rgb(255 255 255 / 0.4);
|
||||
}
|
||||
|
||||
&-progress {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 3px;
|
||||
margin-top: 0.2rem;
|
||||
border-radius: 999px;
|
||||
overflow: hidden;
|
||||
background: rgb(255 255 255 / 0.09);
|
||||
|
||||
> span {
|
||||
display: block;
|
||||
height: 100%;
|
||||
border-radius: inherit;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
var(--session-accent),
|
||||
#ff4f9a 55%,
|
||||
#a66bff
|
||||
);
|
||||
transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
}
|
||||
|
||||
&-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&-action {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.35rem;
|
||||
height: 2.15rem;
|
||||
padding: 0 0.8rem;
|
||||
border: 1px solid rgb(255 255 255 / 0.12);
|
||||
border-radius: 999px;
|
||||
background: rgb(255 255 255 / 0.06);
|
||||
color: rgb(255 255 255 / 0.82);
|
||||
font: inherit;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
backdrop-filter: blur(12px);
|
||||
transition:
|
||||
background-color 160ms ease,
|
||||
border-color 160ms ease,
|
||||
color 160ms ease,
|
||||
opacity 160ms ease;
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: rgb(255 255 255 / 0.12);
|
||||
border-color: rgb(255 255 255 / 0.22);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
&.is-primary {
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgb(255 79 154 / 0.92),
|
||||
rgb(166 107 255 / 0.92)
|
||||
);
|
||||
border-color: transparent;
|
||||
color: #fff;
|
||||
box-shadow: 0 6px 18px rgb(255 79 154 / 0.24);
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgb(255 110 175 / 0.98),
|
||||
rgb(184 132 255 / 0.98)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
&.is-icon {
|
||||
width: 2.15rem;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&.is-compact {
|
||||
grid-template-columns: 48px minmax(0, 1fr);
|
||||
gap: 0.7rem;
|
||||
padding: 0.6rem;
|
||||
border-radius: 15px;
|
||||
|
||||
.session-card-poster {
|
||||
width: 48px;
|
||||
height: 66px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.session-card-status {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.session-card-name {
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.session-card-actions {
|
||||
grid-column: 1 / -1;
|
||||
justify-content: stretch;
|
||||
|
||||
.session-card-action {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes session-card-pulse {
|
||||
0%,
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
transform: scale(0.82);
|
||||
opacity: 0.65;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.session-card {
|
||||
grid-template-columns: 52px minmax(0, 1fr);
|
||||
gap: 0.6rem;
|
||||
padding: 0.7rem;
|
||||
border-radius: 16px;
|
||||
|
||||
&-poster {
|
||||
width: 52px;
|
||||
height: 72px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
&-status {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&-actions {
|
||||
grid-column: 1 / -1;
|
||||
justify-content: stretch;
|
||||
|
||||
.session-card-action {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import type { SessionInfoDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { motion } from "motion/react";
|
||||
import React from "react";
|
||||
import CachedImage from "@/components/cachedImage";
|
||||
import { getRuntimeCompact } from "@/utils/date/time";
|
||||
import {
|
||||
getBlinkDeviceIcon,
|
||||
getBlinkDeviceName,
|
||||
} from "@/utils/methods/blinkSessions";
|
||||
import { getCoverPalette } from "@/utils/methods/coverColor";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import type { RemoteTransfer } from "@/utils/store/remoteControl";
|
||||
|
||||
import "./sessionCard.scss";
|
||||
|
||||
const TICKS_PER_SECOND = 10_000_000;
|
||||
|
||||
const formatTime = (ticks?: number | null) => {
|
||||
const total = Math.max(0, Math.round((ticks ?? 0) / TICKS_PER_SECOND));
|
||||
const h = Math.floor(total / 3600);
|
||||
const m = Math.floor((total % 3600) / 60);
|
||||
const s = total % 60;
|
||||
return h > 0
|
||||
? `${h}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`
|
||||
: `${m}:${String(s).padStart(2, "0")}`;
|
||||
};
|
||||
|
||||
type SessionCardProps = {
|
||||
session: SessionInfoDto;
|
||||
api?: Api;
|
||||
transfer?: RemoteTransfer | null;
|
||||
onSend?: (session: SessionInfoDto) => void;
|
||||
onTake?: (session: SessionInfoDto) => void;
|
||||
onOpenRemote?: (session: SessionInfoDto) => void;
|
||||
onSelect?: (session: SessionInfoDto) => void;
|
||||
selected?: boolean;
|
||||
compact?: boolean;
|
||||
sending?: boolean;
|
||||
taking?: boolean;
|
||||
};
|
||||
|
||||
const SessionCard = ({
|
||||
session,
|
||||
api,
|
||||
transfer,
|
||||
onSend,
|
||||
onTake,
|
||||
onOpenRemote,
|
||||
onSelect,
|
||||
selected = false,
|
||||
compact = false,
|
||||
sending = false,
|
||||
taking = false,
|
||||
}: SessionCardProps) => {
|
||||
const nowPlaying = session.NowPlayingItem;
|
||||
const playState = session.PlayState;
|
||||
const duration = nowPlaying?.RunTimeTicks ?? 0;
|
||||
const position = playState?.PositionTicks ?? 0;
|
||||
const progress = duration > 0 ? Math.min(1, position / duration) : 0;
|
||||
const paused = Boolean(playState?.IsPaused);
|
||||
const status = nowPlaying ? (paused ? "Пауза" : "Играет") : "Свободно";
|
||||
const palette = getCoverPalette(nowPlaying);
|
||||
const deviceName = getBlinkDeviceName(session);
|
||||
const deviceIcon = getBlinkDeviceIcon(session);
|
||||
const imageItemId =
|
||||
nowPlaying?.AlbumId ?? nowPlaying?.SeriesId ?? nowPlaying?.Id;
|
||||
const imageUrl =
|
||||
api && imageItemId
|
||||
? getImageUrlsApi(api).getItemImageUrlById(imageItemId, "Primary", {
|
||||
fillHeight: compact ? 144 : 192,
|
||||
fillWidth: compact ? 96 : 128,
|
||||
quality: 82,
|
||||
})
|
||||
: undefined;
|
||||
const canSend = Boolean(transfer?.item && onSend);
|
||||
const canTake = Boolean(nowPlaying && onTake);
|
||||
|
||||
return (
|
||||
<motion.article
|
||||
layout
|
||||
initial={{ opacity: 0, y: 10, scale: 0.985 }}
|
||||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||
exit={{ opacity: 0, y: -6, scale: 0.985 }}
|
||||
whileHover={{ y: -2 }}
|
||||
transition={{ type: "spring", stiffness: 420, damping: 34 }}
|
||||
className={`session-card${selected ? " is-selected" : ""}${
|
||||
compact ? " is-compact" : ""
|
||||
}${nowPlaying ? " is-playing" : " is-idle"}${
|
||||
onSelect ? " is-clickable" : ""
|
||||
}`}
|
||||
onClick={onSelect ? () => onSelect(session) : undefined}
|
||||
onKeyDown={
|
||||
onSelect
|
||||
? (event) => {
|
||||
if (event.key === "Enter" || event.key === " ") {
|
||||
event.preventDefault();
|
||||
onSelect(session);
|
||||
}
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
role={onSelect ? "button" : undefined}
|
||||
tabIndex={onSelect ? 0 : undefined}
|
||||
aria-current={selected ? "true" : undefined}
|
||||
style={
|
||||
{
|
||||
"--session-accent": palette.base,
|
||||
"--session-deep": palette.deep,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
>
|
||||
<div className="session-card-glow" aria-hidden="true" />
|
||||
<div className="session-card-poster">
|
||||
{imageUrl ? (
|
||||
<CachedImage src={imageUrl} alt="" loading="lazy" />
|
||||
) : (
|
||||
<span className="material-symbols-rounded">{deviceIcon}</span>
|
||||
)}
|
||||
{nowPlaying && (
|
||||
<span
|
||||
className={`session-card-status-dot${paused ? " is-paused" : ""}`}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="session-card-main">
|
||||
<div className="session-card-head">
|
||||
<span className="material-symbols-rounded session-card-device-icon">
|
||||
{deviceIcon}
|
||||
</span>
|
||||
<span className="session-card-name" title={deviceName}>
|
||||
{deviceName}
|
||||
</span>
|
||||
<span
|
||||
className={`session-card-status${paused ? " is-paused" : ""}${
|
||||
nowPlaying ? "" : " is-idle"
|
||||
}`}
|
||||
>
|
||||
{status}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{nowPlaying ? (
|
||||
<>
|
||||
<div className="session-card-title" title={nowPlaying.Name ?? ""}>
|
||||
{nowPlaying.SeriesName
|
||||
? `${nowPlaying.SeriesName} · ${nowPlaying.Name}`
|
||||
: (nowPlaying.Name ?? "Без названия")}
|
||||
</div>
|
||||
<div className="session-card-meta">
|
||||
<span>
|
||||
{formatTime(position)} / {formatTime(duration)}
|
||||
</span>
|
||||
{nowPlaying.ProductionYear ? (
|
||||
<span>{nowPlaying.ProductionYear}</span>
|
||||
) : null}
|
||||
{nowPlaying.RunTimeTicks ? (
|
||||
<span>{getRuntimeCompact(nowPlaying.RunTimeTicks)}</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="session-card-progress" aria-hidden="true">
|
||||
<span style={{ width: `${Math.round(progress * 100)}%` }} />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="session-card-meta session-card-idle-copy">
|
||||
Готово принять воспроизведение
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="session-card-actions">
|
||||
{canSend && (
|
||||
<motion.button
|
||||
type="button"
|
||||
className="session-card-action is-primary"
|
||||
whileTap={{ scale: 0.97 }}
|
||||
disabled={sending}
|
||||
onClick={() => onSend?.(session)}
|
||||
>
|
||||
<span className="material-symbols-rounded">
|
||||
{sending ? "progress_activity" : "send"}
|
||||
</span>
|
||||
{sending ? "Отправляем…" : "Отправить сюда"}
|
||||
</motion.button>
|
||||
)}
|
||||
{canTake && (
|
||||
<motion.button
|
||||
type="button"
|
||||
className="session-card-action"
|
||||
whileTap={{ scale: 0.97 }}
|
||||
disabled={taking}
|
||||
onClick={() => onTake?.(session)}
|
||||
>
|
||||
<span className="material-symbols-rounded">
|
||||
{taking ? "progress_activity" : "download"}
|
||||
</span>
|
||||
{taking ? "Забираем…" : "Забрать сюда"}
|
||||
</motion.button>
|
||||
)}
|
||||
{onOpenRemote && (
|
||||
<button
|
||||
type="button"
|
||||
className="session-card-action is-icon"
|
||||
title="Открыть пульт"
|
||||
aria-label="Открыть пульт"
|
||||
onClick={() => onOpenRemote(session)}
|
||||
>
|
||||
<span className="material-symbols-rounded">settings_remote</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</motion.article>
|
||||
);
|
||||
};
|
||||
|
||||
export default SessionCard;
|
||||
@@ -1,34 +1,70 @@
|
||||
import { Skeleton } from "@mui/material";
|
||||
import React from "react";
|
||||
|
||||
const LibraryItemsSkeleton = () => {
|
||||
type LibraryItemsSkeletonProps = {
|
||||
/** Square artwork (music, playlists, genres) instead of portrait posters. */
|
||||
square?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* Placeholder that matches the virtualized library grid: same card width,
|
||||
* gap and text block. A mismatched skeleton was making the real cards resize
|
||||
* when the first page of items arrived.
|
||||
*/
|
||||
const LibraryItemsSkeleton = ({
|
||||
square = false,
|
||||
}: LibraryItemsSkeletonProps) => {
|
||||
const viewportWidth =
|
||||
typeof window === "undefined"
|
||||
? 1200
|
||||
: document.documentElement.clientWidth || window.innerWidth;
|
||||
// Same inset as `.library-items` (4em on each side) used by the real grid.
|
||||
const width = Math.max(0, viewportWidth - 128);
|
||||
const minCardWidth = width < 700 ? 140 : 180;
|
||||
const columns = Math.max(1, Math.floor(width / minCardWidth));
|
||||
const gap = 16;
|
||||
const cardWidth = Math.max(
|
||||
1,
|
||||
Math.floor((width - (columns - 1) * gap) / columns),
|
||||
);
|
||||
const count = columns * 3;
|
||||
const placeholders = Array.from({ length: count }, (_, index) => ({
|
||||
id: `library-skeleton-${index}`,
|
||||
}));
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
width: "100%",
|
||||
overflow: "visible",
|
||||
flexWrap: "wrap",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
gap,
|
||||
width: "100%",
|
||||
alignItems: "flex-start",
|
||||
}}
|
||||
>
|
||||
{Array.from(new Array(18)).map((_, index) => (
|
||||
{placeholders.map((placeholder) => (
|
||||
<div
|
||||
key={placeholder.id}
|
||||
style={{ width: cardWidth, flex: "0 0 auto", minWidth: 0 }}
|
||||
>
|
||||
<Skeleton
|
||||
key={index}
|
||||
variant="rounded"
|
||||
sx={{
|
||||
flexBasis: 185,
|
||||
width: "100%",
|
||||
height: "auto",
|
||||
aspectRatio: 0.6666,
|
||||
// background: "red",
|
||||
marginRight: "1.5em",
|
||||
marginBottom: "1.5em",
|
||||
flexShrink: 1,
|
||||
flexGrow: 0,
|
||||
aspectRatio: square ? 1 : 0.6666,
|
||||
borderRadius: "10px",
|
||||
}}
|
||||
/>
|
||||
<Skeleton
|
||||
variant="text"
|
||||
sx={{ width: "82%", height: 18, mt: "8px", mb: 0 }}
|
||||
/>
|
||||
<Skeleton
|
||||
variant="text"
|
||||
sx={{ width: "52%", height: 16, mt: 0, mb: 0 }}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -64,7 +64,9 @@ const getCandidates = (): HTMLElement[] => {
|
||||
.filter((element) => element !== scope)
|
||||
.filter((element) => !element.closest("[data-tv-ignore]"))
|
||||
.filter(isVisible)
|
||||
.filter((element) => element.tabIndex >= 0 || element.hasAttribute("tabindex"));
|
||||
.filter(
|
||||
(element) => element.tabIndex >= 0 || element.hasAttribute("tabindex"),
|
||||
);
|
||||
};
|
||||
|
||||
const clearTvFocus = () => {
|
||||
@@ -102,7 +104,7 @@ const moveFocus = (direction: Direction) => {
|
||||
const contentCandidates = candidates.filter(
|
||||
(element) =>
|
||||
!element.closest(
|
||||
".appBar, .library-header, .home-header, .remote-topbar, .audio-player, .video-player, .window-chrome, .window-controls, .follow-me, .alpha-selector",
|
||||
".app-titlebar, .audio-player, .video-player, .window-chrome, .window-controls, .follow-me, .alpha-selector",
|
||||
),
|
||||
);
|
||||
const pool = contentCandidates.length > 0 ? contentCandidates : candidates;
|
||||
@@ -220,10 +222,14 @@ const SpatialNavigation = () => {
|
||||
const previousButtons = useRef<boolean[]>([]);
|
||||
|
||||
const onKeyDown = useCallback((event: KeyboardEvent) => {
|
||||
if (event.defaultPrevented || event.altKey || event.metaKey || event.ctrlKey)
|
||||
if (
|
||||
event.defaultPrevented ||
|
||||
event.altKey ||
|
||||
event.metaKey ||
|
||||
event.ctrlKey
|
||||
)
|
||||
return;
|
||||
const target =
|
||||
event.target instanceof HTMLElement ? event.target : null;
|
||||
const target = event.target instanceof HTMLElement ? event.target : null;
|
||||
if (
|
||||
target?.closest(
|
||||
"input, textarea, select, [contenteditable='true'], [role='slider'], .MuiSlider-root",
|
||||
|
||||
@@ -2,8 +2,16 @@ import { useNavigate } from "@tanstack/react-router";
|
||||
import React, { useEffect } from "react";
|
||||
import { getLocalPlayback } from "@/utils/methods/localPlayback";
|
||||
import {
|
||||
enforceSyncPlayLocalState,
|
||||
getCurrentGroupItemId,
|
||||
getExpectedSyncPlayPosition,
|
||||
isSyncPlayWaitingForStart,
|
||||
joinBlinkAutoGroupIfAvailable,
|
||||
parkLocalPlaybackForSync,
|
||||
pingSyncPlayGroup,
|
||||
refreshSyncPlayGroup,
|
||||
reportSyncPlayReady,
|
||||
syncPlayIgnoreWaitIfNeeded,
|
||||
} from "@/utils/methods/syncPlay";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
@@ -19,6 +27,7 @@ const SyncPlayController = () => {
|
||||
);
|
||||
const group = useSyncPlayStore((state) => state.group);
|
||||
const queue = useSyncPlayStore((state) => state.queue);
|
||||
const autoJoin = useSyncPlayStore((state) => state.autoJoin);
|
||||
const api = useApiInContext((state) => state.api);
|
||||
const user = useCentralStore((state) => state.currentUser);
|
||||
const navigate = useNavigate();
|
||||
@@ -31,6 +40,55 @@ const SyncPlayController = () => {
|
||||
});
|
||||
}, [pendingNavigation, setPendingNavigation, navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!api || !user?.Id || group || !autoJoin) return;
|
||||
let cancelled = false;
|
||||
let running = false;
|
||||
const tick = async () => {
|
||||
if (cancelled || running) {
|
||||
return;
|
||||
}
|
||||
running = true;
|
||||
try {
|
||||
await joinBlinkAutoGroupIfAvailable(api);
|
||||
} finally {
|
||||
running = false;
|
||||
}
|
||||
};
|
||||
void tick();
|
||||
const timer = window.setInterval(() => void tick(), 1000);
|
||||
return () => {
|
||||
cancelled = true;
|
||||
window.clearInterval(timer);
|
||||
};
|
||||
}, [api, user?.Id, group, autoJoin]);
|
||||
|
||||
// Keep the group state fresh while the dialog is closed. The ready retry
|
||||
// below depends on knowing that the server entered Waiting; a stale Idle
|
||||
// state otherwise leaves the whole group waiting until the server timeout.
|
||||
useEffect(() => {
|
||||
if (!api || !group?.GroupId) return;
|
||||
void refreshSyncPlayGroup(api);
|
||||
const timer = window.setInterval(() => {
|
||||
void refreshSyncPlayGroup(api);
|
||||
}, 3000);
|
||||
return () => window.clearInterval(timer);
|
||||
}, [api, group?.GroupId]);
|
||||
|
||||
// Reconcile play/pause with the group after the player becomes ready or a
|
||||
// command was missed. This is what keeps three already-open clients on the
|
||||
// same unpause state even when one of them was still loading.
|
||||
useEffect(() => {
|
||||
if (!api || !group?.GroupId) return;
|
||||
const tick = () => {
|
||||
enforceSyncPlayLocalState();
|
||||
syncPlayIgnoreWaitIfNeeded(api);
|
||||
};
|
||||
tick();
|
||||
const timer = window.setInterval(tick, 2000);
|
||||
return () => window.clearInterval(timer);
|
||||
}, [api, group?.GroupId, group?.State]);
|
||||
|
||||
// SyncPlay uses pings to estimate latency and schedule unpause commands.
|
||||
useEffect(() => {
|
||||
if (!api || !group?.GroupId) return;
|
||||
@@ -41,20 +99,28 @@ const SyncPlayController = () => {
|
||||
return () => window.clearInterval(timer);
|
||||
}, [api, group?.GroupId]);
|
||||
|
||||
// While a group is waiting, keep telling the server this player is ready.
|
||||
// Some clients miss the one-shot Ready after a queue update; retrying is
|
||||
// harmless and lets the server release the group as soon as it can.
|
||||
// While a group waits for a freshly set queue, park this client exactly at
|
||||
// the queue position and report ready. The server only accepts a ready
|
||||
// within 500 ms of that position; a client that keeps playing reports a
|
||||
// moving position and is sent back to the start over and over.
|
||||
useEffect(() => {
|
||||
if (!api || !user?.Id || !group || group.State !== "Waiting") return;
|
||||
if (!api || !group || group.State !== "Waiting") return;
|
||||
if (!queue?.Playlist?.length) return;
|
||||
const send = () => {
|
||||
const local = getLocalPlayback();
|
||||
if (local.kind === "none" || !local.ready) return;
|
||||
const groupItemId = getCurrentGroupItemId();
|
||||
if (!groupItemId || local.itemId !== groupItemId) return;
|
||||
const expected = getExpectedSyncPlayPosition();
|
||||
if (isSyncPlayWaitingForStart()) {
|
||||
if (!parkLocalPlaybackForSync(expected)) return;
|
||||
}
|
||||
reportSyncPlayReady(api, local.positionTicks, !local.paused);
|
||||
};
|
||||
send();
|
||||
const timer = window.setInterval(send, 2000);
|
||||
const timer = window.setInterval(send, 1000);
|
||||
return () => window.clearInterval(timer);
|
||||
}, [api, user?.Id, group?.GroupId, group?.State, queue]);
|
||||
}, [api, group?.GroupId, group?.State, queue]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,6 @@ import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { getSyncPlayApi } from "@jellyfin/sdk/lib/utils/api/sync-play-api";
|
||||
import {
|
||||
Alert,
|
||||
Box,
|
||||
Button,
|
||||
Chip,
|
||||
CircularProgress,
|
||||
@@ -11,19 +10,30 @@ import {
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
Divider,
|
||||
List,
|
||||
ListItem,
|
||||
ListItemText,
|
||||
FormControlLabel,
|
||||
Stack,
|
||||
Switch,
|
||||
TextField,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { motion } from "motion/react";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import {
|
||||
getDeviceDisplayName,
|
||||
getOrCreateDeviceId,
|
||||
} from "@/utils/deviceIdentity";
|
||||
import {
|
||||
getBlinkDeviceName,
|
||||
getBlinkGroupLabel,
|
||||
isBlinkGroup,
|
||||
useBlinkSessions,
|
||||
} from "@/utils/methods/blinkSessions";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import {
|
||||
closeSyncPlayDialog,
|
||||
createSyncPlayGroup,
|
||||
ensureBlinkAutoGroup,
|
||||
joinSyncPlayGroup,
|
||||
leaveSyncPlayGroup,
|
||||
pauseSyncPlayGroup,
|
||||
@@ -37,6 +47,8 @@ import { useCentralStore } from "@/utils/store/central";
|
||||
import useQueue from "@/utils/store/queue";
|
||||
import useSyncPlayStore from "@/utils/store/syncPlay";
|
||||
|
||||
import "./syncPlay.scss";
|
||||
|
||||
const stateLabel = (state?: string) => {
|
||||
switch (state) {
|
||||
case "Waiting":
|
||||
@@ -59,16 +71,23 @@ const SyncPlayDialog = () => {
|
||||
const queue = useSyncPlayStore((state) => state.queue);
|
||||
const loading = useSyncPlayStore((state) => state.loading);
|
||||
const error = useSyncPlayStore((state) => state.error);
|
||||
const autoJoin = useSyncPlayStore((state) => state.autoJoin);
|
||||
const pingMs = useSyncPlayStore((state) => state.pingMs);
|
||||
const localQueue = useQueue((state) => state.tracks ?? []);
|
||||
const [groupName, setGroupName] = useState("");
|
||||
const setGroups = useSyncPlayStore((state) => state.setGroups);
|
||||
const setGroup = useSyncPlayStore((state) => state.setGroup);
|
||||
const setAutoJoin = useSyncPlayStore((state) => state.setAutoJoin);
|
||||
const blink = useBlinkSessions(open);
|
||||
const selfName = getDeviceDisplayName(getOrCreateDeviceId());
|
||||
|
||||
const groupsQuery = useQuery({
|
||||
queryKey: ["syncPlayGroups", open],
|
||||
queryFn: async () => {
|
||||
if (!api) return [];
|
||||
return (await getSyncPlayApi(api).syncPlayGetGroups()).data ?? [];
|
||||
return (
|
||||
(await getSyncPlayApi(api).syncPlayGetGroups()).data ?? []
|
||||
).filter(isBlinkGroup);
|
||||
},
|
||||
enabled: open && Boolean(api),
|
||||
refetchInterval: open && !group ? 3000 : false,
|
||||
@@ -135,7 +154,13 @@ const SyncPlayDialog = () => {
|
||||
if (created) setGroupName("");
|
||||
};
|
||||
|
||||
const handleAutoGroup = async (shareQueue: boolean) => {
|
||||
if (!api) return;
|
||||
await ensureBlinkAutoGroup(api, { shareQueue });
|
||||
};
|
||||
|
||||
const handleClose = () => closeSyncPlayDialog();
|
||||
const onlineDevices = blink.sessions;
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
@@ -144,90 +169,112 @@ const SyncPlayDialog = () => {
|
||||
fullWidth
|
||||
maxWidth="sm"
|
||||
slotProps={{
|
||||
paper: { className: "glass", sx: { borderRadius: "22px" } },
|
||||
paper: {
|
||||
className: "glass-dialog-paper syncplay-dialog",
|
||||
sx: { borderRadius: "24px" },
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DialogTitle sx={{ display: "flex", alignItems: "center", gap: 1 }}>
|
||||
<DialogTitle className="syncplay-title">
|
||||
<div className="syncplay-heading">
|
||||
<span className="material-symbols-rounded">groups</span>
|
||||
Смотреть вместе
|
||||
<div>
|
||||
<strong>Смотреть вместе</strong>
|
||||
<small>Группы только для клиентов Blink</small>
|
||||
</div>
|
||||
</div>
|
||||
<Chip
|
||||
size="small"
|
||||
className="syncplay-latency"
|
||||
label={pingMs == null ? "Синхронизация" : `Пинг ${pingMs} мс`}
|
||||
/>
|
||||
</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContent className="syncplay-content">
|
||||
{error && (
|
||||
<Alert severity="warning" sx={{ mb: 2 }}>
|
||||
<Alert severity="warning" sx={{ mb: 1.5, borderRadius: "14px" }}>
|
||||
{error}
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{group ? (
|
||||
<Stack spacing={2}>
|
||||
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
|
||||
<Typography variant="h6" sx={{ flex: 1 }} noWrap>
|
||||
{group.GroupName || "Группа SyncPlay"}
|
||||
<Stack spacing={1.5}>
|
||||
<div className="syncplay-card syncplay-group-head">
|
||||
<div className="syncplay-group-copy">
|
||||
<span className="syncplay-eyebrow">Группа Blink</span>
|
||||
<Typography variant="h6" noWrap>
|
||||
{getBlinkGroupLabel(group)}
|
||||
</Typography>
|
||||
<Typography variant="body2" className="syncplay-muted">
|
||||
{onlineDevices.length + 1} Blink в сети ·{" "}
|
||||
{group.Participants?.length ?? 0} пользовател
|
||||
{(group.Participants?.length ?? 0) === 1 ? "ь" : "я"}
|
||||
</Typography>
|
||||
</div>
|
||||
<Chip
|
||||
size="small"
|
||||
label={stateLabel(group.State)}
|
||||
color={group.State === "Playing" ? "success" : "default"}
|
||||
variant={group.State === "Playing" ? "filled" : "outlined"}
|
||||
/>
|
||||
</Box>
|
||||
<Typography variant="body2" sx={{ opacity: 0.65 }}>
|
||||
{group.Participants?.length
|
||||
? `${group.Participants.length} device${
|
||||
group.Participants.length === 1 ? "" : "s"
|
||||
} connected: ${group.Participants.join(", ")}`
|
||||
: "Это первое устройство в группе."}
|
||||
</Typography>
|
||||
<Divider />
|
||||
<Box sx={{ display: "flex", gap: 2, alignItems: "center" }}>
|
||||
{imageUrl ? (
|
||||
<Box
|
||||
component="img"
|
||||
src={imageUrl}
|
||||
alt=""
|
||||
sx={{
|
||||
width: 64,
|
||||
height: 96,
|
||||
objectFit: "cover",
|
||||
borderRadius: "10px",
|
||||
flex: "0 0 auto",
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<Box
|
||||
sx={{
|
||||
width: 64,
|
||||
height: 96,
|
||||
borderRadius: "10px",
|
||||
background: "rgba(255,255,255,0.07)",
|
||||
display: "grid",
|
||||
placeItems: "center",
|
||||
flex: "0 0 auto",
|
||||
}}
|
||||
</div>
|
||||
|
||||
<div className="syncplay-card">
|
||||
<div className="syncplay-card-title">
|
||||
<span className="material-symbols-rounded">devices</span>
|
||||
<span>Blink-устройства</span>
|
||||
</div>
|
||||
<div className="syncplay-device-chips">
|
||||
<span className="syncplay-device-chip is-self">
|
||||
<span className="syncplay-device-dot" />
|
||||
{selfName} · это устройство
|
||||
</span>
|
||||
{onlineDevices.map((session) => (
|
||||
<span
|
||||
key={session.Id}
|
||||
className="syncplay-device-chip"
|
||||
title={getBlinkDeviceName(session)}
|
||||
>
|
||||
<span className="material-symbols-rounded">movie</span>
|
||||
</Box>
|
||||
<span className="syncplay-device-dot" />
|
||||
{getBlinkDeviceName(session)}
|
||||
</span>
|
||||
))}
|
||||
{onlineDevices.length === 0 && (
|
||||
<span className="syncplay-muted">
|
||||
Других Blink-устройств сейчас нет.
|
||||
</span>
|
||||
)}
|
||||
<Box sx={{ minWidth: 0 }}>
|
||||
<Typography variant="overline" sx={{ opacity: 0.6 }}>
|
||||
Очередь группы
|
||||
</div>
|
||||
<Typography variant="caption" className="syncplay-note">
|
||||
Jellyfin считает участников по пользователям, поэтому список
|
||||
устройств собран из сессий Blink.
|
||||
</Typography>
|
||||
<Typography variant="subtitle1" noWrap>
|
||||
</div>
|
||||
|
||||
<div className="syncplay-card syncplay-queue-card">
|
||||
{imageUrl ? (
|
||||
<img className="syncplay-queue-poster" src={imageUrl} alt="" />
|
||||
) : (
|
||||
<div className="syncplay-queue-poster is-empty">
|
||||
<span className="material-symbols-rounded">movie</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="syncplay-queue-copy">
|
||||
<span className="syncplay-eyebrow">Очередь группы</span>
|
||||
<strong>
|
||||
{currentItem.data?.Name ??
|
||||
(queueItemIds.length
|
||||
? "Загрузка…"
|
||||
: "Очередь пока пуста")}
|
||||
</Typography>
|
||||
<Typography variant="caption" sx={{ opacity: 0.65 }}>
|
||||
(queueItemIds.length ? "Загрузка…" : "Очередь пока пуста")}
|
||||
</strong>
|
||||
<small>
|
||||
{queueItemIds.length
|
||||
? `${queueItemIds.length} item${
|
||||
queueItemIds.length === 1 ? "" : "s"
|
||||
} · item ${currentQueueIndex + 1}`
|
||||
: "Запустите очередь на устройстве, которое будет ведущим."}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Box>
|
||||
<Divider />
|
||||
<Box sx={{ display: "flex", gap: 1, flexWrap: "wrap" }}>
|
||||
? `${queueItemIds.length} элементов · сейчас ${
|
||||
currentQueueIndex + 1
|
||||
}`
|
||||
: "Запустите очередь на ведущем устройстве."}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="syncplay-actions">
|
||||
<Button
|
||||
variant="contained"
|
||||
disabled={loading || localQueue.length === 0 || !user?.Id}
|
||||
@@ -260,7 +307,9 @@ const SyncPlayDialog = () => {
|
||||
: resumeSyncPlayGroup(api))
|
||||
}
|
||||
>
|
||||
{group.State === "Playing" ? "Пауза у всех" : "Воспроизвести у всех"}
|
||||
{group.State === "Playing"
|
||||
? "Пауза у всех"
|
||||
: "Воспроизвести у всех"}
|
||||
</Button>
|
||||
<Button
|
||||
color="error"
|
||||
@@ -269,16 +318,85 @@ const SyncPlayDialog = () => {
|
||||
>
|
||||
Покинуть группу
|
||||
</Button>
|
||||
</Box>
|
||||
</div>
|
||||
{loading && <CircularProgress size={20} />}
|
||||
</Stack>
|
||||
) : (
|
||||
<Stack spacing={2}>
|
||||
<Typography variant="body2" sx={{ opacity: 0.75 }}>
|
||||
Создайте группу и запустите текущую очередь или войдите в
|
||||
группу, созданную на другом устройстве. Все устройства следуют
|
||||
одному таймлайну.
|
||||
<Stack spacing={1.5}>
|
||||
<div className="syncplay-hero">
|
||||
<div className="syncplay-hero-icon">
|
||||
<span className="material-symbols-rounded">bolt</span>
|
||||
</div>
|
||||
<div>
|
||||
<Typography variant="h6">Автогруппа Blink</Typography>
|
||||
<Typography variant="body2" className="syncplay-muted">
|
||||
Соберёт все запущенные клиенты Blink в одну группу и
|
||||
синхронизирует текущую очередь.
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="syncplay-hero-actions">
|
||||
<Button
|
||||
variant="contained"
|
||||
disabled={loading || localQueue.length === 0}
|
||||
onClick={() => void handleAutoGroup(true)}
|
||||
>
|
||||
Собрать и включить
|
||||
</Button>
|
||||
<Button
|
||||
variant="outlined"
|
||||
disabled={loading}
|
||||
onClick={() => void handleAutoGroup(false)}
|
||||
>
|
||||
Только собрать
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="syncplay-card syncplay-auto-row">
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Switch
|
||||
checked={autoJoin}
|
||||
onChange={(event) => setAutoJoin(event.target.checked)}
|
||||
/>
|
||||
}
|
||||
label={
|
||||
<div className="syncplay-auto-copy">
|
||||
<strong>Автоподключение</strong>
|
||||
<Typography variant="caption" className="syncplay-muted">
|
||||
Другие Blink-клиенты сами войдут в автогруппу.
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="syncplay-card">
|
||||
<div className="syncplay-card-title">
|
||||
<span className="material-symbols-rounded">devices</span>
|
||||
<span>Сейчас в сети</span>
|
||||
<span className="syncplay-count">
|
||||
{onlineDevices.length + 1}
|
||||
</span>
|
||||
</div>
|
||||
<div className="syncplay-device-chips">
|
||||
<span className="syncplay-device-chip is-self">
|
||||
<span className="syncplay-device-dot" />
|
||||
{selfName}
|
||||
</span>
|
||||
{onlineDevices.map((session) => (
|
||||
<span key={session.Id} className="syncplay-device-chip">
|
||||
{getBlinkDeviceName(session)}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
<div className="syncplay-card-title">
|
||||
<span className="material-symbols-rounded">add_circle</span>
|
||||
<span>Создать группу Blink</span>
|
||||
</div>
|
||||
<Stack direction="row" spacing={1}>
|
||||
<TextField
|
||||
size="small"
|
||||
@@ -295,28 +413,38 @@ const SyncPlayDialog = () => {
|
||||
variant="contained"
|
||||
disabled={loading || !api}
|
||||
onClick={handleCreate}
|
||||
sx={{ flex: "0 0 auto" }}
|
||||
>
|
||||
Создать
|
||||
</Button>
|
||||
</Stack>
|
||||
<Divider />
|
||||
<Typography variant="overline" sx={{ opacity: 0.65 }}>
|
||||
Доступные группы
|
||||
|
||||
<Typography variant="overline" className="syncplay-list-label">
|
||||
Группы Blink
|
||||
</Typography>
|
||||
{groupsQuery.isPending ? (
|
||||
<CircularProgress size={20} />
|
||||
) : groups.length === 0 ? (
|
||||
<Typography variant="body2" sx={{ opacity: 0.6 }}>
|
||||
Групп пока нет. Создайте выше.
|
||||
<Typography variant="body2" className="syncplay-muted">
|
||||
Групп пока нет. Соберите автогруппу или создайте свою.
|
||||
</Typography>
|
||||
) : (
|
||||
<List dense disablePadding>
|
||||
<Stack spacing={0.7}>
|
||||
{groups.map((entry) => (
|
||||
<ListItem
|
||||
<motion.div
|
||||
key={entry.GroupId}
|
||||
divider
|
||||
secondaryAction={
|
||||
layout
|
||||
initial={{ opacity: 0, y: 6 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
className="syncplay-group-row"
|
||||
>
|
||||
<div className="syncplay-group-row-copy">
|
||||
<strong>{getBlinkGroupLabel(entry)}</strong>
|
||||
<small>
|
||||
{stateLabel(entry.State)} ·{" "}
|
||||
{entry.Participants?.length ?? 0} пользовател
|
||||
{(entry.Participants?.length ?? 0) === 1 ? "ь" : "я"}
|
||||
</small>
|
||||
</div>
|
||||
<Button
|
||||
size="small"
|
||||
variant="outlined"
|
||||
@@ -329,17 +457,9 @@ const SyncPlayDialog = () => {
|
||||
>
|
||||
Войти
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<ListItemText
|
||||
primary={entry.GroupName || "Смотреть вместе"}
|
||||
secondary={`${stateLabel(entry.State)} · ${
|
||||
entry.Participants?.length ?? 0
|
||||
} device${(entry.Participants?.length ?? 0) === 1 ? "" : "s"}`}
|
||||
/>
|
||||
</ListItem>
|
||||
</motion.div>
|
||||
))}
|
||||
</List>
|
||||
</Stack>
|
||||
)}
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,328 @@
|
||||
.syncplay-dialog {
|
||||
background:
|
||||
radial-gradient(circle at 12% 0%, rgb(255 79 154 / 0.13), transparent 42%),
|
||||
radial-gradient(circle at 90% 6%, rgb(120 92 255 / 0.15), transparent 44%),
|
||||
rgb(12 11 22 / 0.92) !important;
|
||||
border: 1px solid rgb(255 255 255 / 0.12);
|
||||
box-shadow:
|
||||
0 30px 90px rgb(0 0 0 / 0.6),
|
||||
inset 0 1px 0 rgb(255 255 255 / 0.08);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.syncplay-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 1.1rem 1.25rem 0.6rem !important;
|
||||
}
|
||||
|
||||
.syncplay-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.65rem;
|
||||
|
||||
> .material-symbols-rounded {
|
||||
width: 2.35rem;
|
||||
height: 2.35rem;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 12px;
|
||||
color: #ffd3e8;
|
||||
background: rgb(255 79 154 / 0.12);
|
||||
border: 1px solid rgb(255 79 154 / 0.2);
|
||||
}
|
||||
|
||||
> div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.05rem;
|
||||
|
||||
strong {
|
||||
font-size: 1rem;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size: 0.7rem;
|
||||
color: rgb(255 255 255 / 0.48);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.syncplay-latency {
|
||||
color: #c9f8dd !important;
|
||||
background: rgb(94 227 154 / 0.1) !important;
|
||||
border: 1px solid rgb(94 227 154 / 0.2) !important;
|
||||
}
|
||||
|
||||
.syncplay-content {
|
||||
padding: 0.3rem 1.25rem 1rem !important;
|
||||
}
|
||||
|
||||
.syncplay-card {
|
||||
padding: 0.85rem;
|
||||
border-radius: 16px;
|
||||
background:
|
||||
linear-gradient(135deg, rgb(255 255 255 / 0.08), rgb(255 255 255 / 0.02)),
|
||||
rgb(17 15 32 / 0.48);
|
||||
border: 1px solid rgb(255 255 255 / 0.09);
|
||||
box-shadow:
|
||||
0 12px 30px rgb(0 0 0 / 0.18),
|
||||
inset 0 1px 0 rgb(255 255 255 / 0.06);
|
||||
backdrop-filter: blur(20px) saturate(150%);
|
||||
}
|
||||
|
||||
.syncplay-group-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.syncplay-group-copy {
|
||||
min-width: 0;
|
||||
|
||||
.MuiTypography-h6 {
|
||||
font-size: 1.05rem;
|
||||
font-weight: 650;
|
||||
}
|
||||
}
|
||||
|
||||
.syncplay-eyebrow {
|
||||
display: block;
|
||||
margin-bottom: 0.15rem;
|
||||
font-size: 0.62rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: rgb(255 255 255 / 0.4);
|
||||
}
|
||||
|
||||
.syncplay-muted {
|
||||
color: rgb(255 255 255 / 0.5) !important;
|
||||
}
|
||||
|
||||
.syncplay-card-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
margin-bottom: 0.55rem;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: rgb(255 255 255 / 0.52);
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1rem;
|
||||
color: #ff7fb6;
|
||||
}
|
||||
}
|
||||
|
||||
.syncplay-count {
|
||||
margin-left: auto;
|
||||
min-width: 1.35rem;
|
||||
height: 1.35rem;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
padding: 0 0.3rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.66rem;
|
||||
letter-spacing: 0;
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.09);
|
||||
}
|
||||
|
||||
.syncplay-device-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.syncplay-device-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
max-width: 100%;
|
||||
padding: 0.3rem 0.6rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
border-radius: 999px;
|
||||
font-size: 0.72rem;
|
||||
color: rgb(255 255 255 / 0.78);
|
||||
background: rgb(255 255 255 / 0.06);
|
||||
border: 1px solid rgb(255 255 255 / 0.09);
|
||||
|
||||
&.is-self {
|
||||
color: #ffd3e8;
|
||||
background: rgb(255 79 154 / 0.09);
|
||||
border-color: rgb(255 79 154 / 0.18);
|
||||
}
|
||||
}
|
||||
|
||||
.syncplay-device-dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
flex: 0 0 auto;
|
||||
border-radius: 50%;
|
||||
background: #5ee39a;
|
||||
box-shadow: 0 0 8px #5ee39a;
|
||||
}
|
||||
|
||||
.syncplay-note {
|
||||
display: block;
|
||||
margin-top: 0.5rem;
|
||||
color: rgb(255 255 255 / 0.38) !important;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.syncplay-queue-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.syncplay-queue-poster {
|
||||
width: 52px;
|
||||
height: 72px;
|
||||
flex: 0 0 auto;
|
||||
object-fit: cover;
|
||||
border-radius: 10px;
|
||||
background: rgb(255 255 255 / 0.06);
|
||||
box-shadow: 0 8px 20px rgb(0 0 0 / 0.3);
|
||||
|
||||
&.is-empty {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: rgb(255 255 255 / 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
.syncplay-queue-copy {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.15rem;
|
||||
min-width: 0;
|
||||
|
||||
strong {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size: 0.7rem;
|
||||
color: rgb(255 255 255 / 0.48);
|
||||
}
|
||||
}
|
||||
|
||||
.syncplay-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.syncplay-hero {
|
||||
display: grid;
|
||||
grid-template-columns: 2.6rem minmax(0, 1fr);
|
||||
gap: 0.35rem 0.7rem;
|
||||
align-items: start;
|
||||
padding: 0.9rem;
|
||||
border-radius: 18px;
|
||||
background:
|
||||
linear-gradient(135deg, rgb(255 79 154 / 0.17), rgb(120 92 255 / 0.08)),
|
||||
rgb(17 15 32 / 0.62);
|
||||
border: 1px solid rgb(255 255 255 / 0.1);
|
||||
box-shadow:
|
||||
0 16px 40px rgb(0 0 0 / 0.24),
|
||||
inset 0 1px 0 rgb(255 255 255 / 0.1);
|
||||
}
|
||||
|
||||
.syncplay-hero-icon {
|
||||
width: 2.6rem;
|
||||
height: 2.6rem;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 12px;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, rgb(255 79 154 / 0.8), rgb(166 107 255 / 0.8));
|
||||
}
|
||||
|
||||
.syncplay-hero-actions {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
margin-top: 0.35rem;
|
||||
}
|
||||
|
||||
.syncplay-auto-row {
|
||||
.MuiFormControlLabel-root {
|
||||
margin: 0;
|
||||
align-items: flex-start;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.MuiFormControlLabel-label {
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.syncplay-auto-copy {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.1rem;
|
||||
}
|
||||
|
||||
.syncplay-list-label {
|
||||
display: block;
|
||||
margin-top: 0.3rem !important;
|
||||
color: rgb(255 255 255 / 0.46) !important;
|
||||
}
|
||||
|
||||
.syncplay-group-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
padding: 0.65rem 0.75rem;
|
||||
border-radius: 14px;
|
||||
background: rgb(255 255 255 / 0.045);
|
||||
border: 1px solid rgb(255 255 255 / 0.08);
|
||||
|
||||
&-copy {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
|
||||
strong {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 0.84rem;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size: 0.68rem;
|
||||
color: rgb(255 255 255 / 0.48);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.syncplay-title {
|
||||
padding: 0.9rem 0.9rem 0.5rem !important;
|
||||
}
|
||||
|
||||
.syncplay-content {
|
||||
padding: 0.2rem 0.9rem 0.8rem !important;
|
||||
}
|
||||
|
||||
.syncplay-latency {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,16 @@ import React, {
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { useQuickConnectApprovalStore } from "@/utils/store/quickConnectApproval";
|
||||
|
||||
import "./userAvatarMenu.scss";
|
||||
|
||||
const isAndroidDevice = /Android/i.test(navigator.userAgent);
|
||||
|
||||
export const UserAvatarMenu = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
@@ -70,18 +75,18 @@ export const UserAvatarMenu = () => {
|
||||
>
|
||||
{!!user?.Id &&
|
||||
(user?.PrimaryImageTag === undefined ? (
|
||||
<Avatar className="appBar-avatar" alt={user?.Name ?? "image"}>
|
||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||
<Avatar className="user-avatar" alt={user?.Name ?? "image"}>
|
||||
<span className="material-symbols-rounded user-avatar-icon">
|
||||
account_circle
|
||||
</span>
|
||||
</Avatar>
|
||||
) : (
|
||||
<Avatar
|
||||
className="appBar-avatar"
|
||||
className="user-avatar"
|
||||
src={`${api?.basePath}/Users/${user?.Id}/Images/Primary`}
|
||||
alt={user?.Name ?? "image"}
|
||||
>
|
||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||
<span className="material-symbols-rounded user-avatar-icon">
|
||||
account_circle
|
||||
</span>
|
||||
</Avatar>
|
||||
@@ -97,29 +102,51 @@ export const UserAvatarMenu = () => {
|
||||
>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
handleLogout();
|
||||
openSyncPlayDialog();
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<span className="material-symbols-rounded">logout</span>
|
||||
<span className="material-symbols-rounded">groups</span>
|
||||
</ListItemIcon>
|
||||
Выйти
|
||||
Смотреть вместе
|
||||
</MenuItem>
|
||||
<Divider />
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
useQuickConnectApprovalStore
|
||||
.getState()
|
||||
.openQuickConnectApproval();
|
||||
navigate({ to: "/remote" });
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<span className="material-symbols-rounded">qr_code_2</span>
|
||||
<span className="material-symbols-rounded">settings_remote</span>
|
||||
</ListItemIcon>
|
||||
Подтвердить вход на устройство
|
||||
Пульт
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
navigate({ to: "/favorite" });
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<span className="material-symbols-rounded">favorite</span>
|
||||
</ListItemIcon>
|
||||
Избранное
|
||||
</MenuItem>
|
||||
{!isAndroidDevice && (
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
navigate({ to: "/downloads" });
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<span className="material-symbols-rounded">download</span>
|
||||
</ListItemIcon>
|
||||
Загрузки
|
||||
</MenuItem>
|
||||
)}
|
||||
<Divider />
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
navigate({ to: "/settings/preferences" });
|
||||
@@ -142,6 +169,30 @@ export const UserAvatarMenu = () => {
|
||||
</ListItemIcon>
|
||||
О приложении
|
||||
</MenuItem>
|
||||
<Divider />
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
useQuickConnectApprovalStore.getState().openQuickConnectApproval();
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<span className="material-symbols-rounded">qr_code_2</span>
|
||||
</ListItemIcon>
|
||||
Подтвердить вход на устройство
|
||||
</MenuItem>
|
||||
<Divider />
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
handleLogout();
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<span className="material-symbols-rounded">logout</span>
|
||||
</ListItemIcon>
|
||||
Выйти
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
.user-avatar {
|
||||
width: 32px !important;
|
||||
height: 32px !important;
|
||||
background: rgb(255 255 255 / 0.12) !important;
|
||||
}
|
||||
|
||||
.user-avatar-icon {
|
||||
color: #fff;
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useLocation } from "@tanstack/react-router";
|
||||
import React from "react";
|
||||
import { shouldShowAppBar } from "@/components/appBar/appBar";
|
||||
import { shouldShowTitlebar } from "@/components/appTitlebar/routeVisibility";
|
||||
import WindowControls from ".";
|
||||
|
||||
import "./windowControls.scss";
|
||||
@@ -9,28 +9,15 @@ const isMac = navigator.userAgent.includes("Macintosh");
|
||||
const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
|
||||
|
||||
/**
|
||||
* Frameless-window fallback for pages that do not draw the app header:
|
||||
* a small drag strip plus the window buttons in the top-right corner.
|
||||
*
|
||||
* Pages with a header (home, library, search, player) put the window buttons
|
||||
* in that header's row instead, so every page has one titlebar plane and the
|
||||
* buttons never float over the avatar or the page controls.
|
||||
* Frameless-window fallback for pages without the global titlebar (login and
|
||||
* setup): a small drag strip plus the window buttons in the top-right corner.
|
||||
*/
|
||||
const WindowChrome = () => {
|
||||
const { pathname } = useLocation();
|
||||
if (isMac || isMobile) return null;
|
||||
// The global app header owns the window buttons on these routes.
|
||||
if (shouldShowAppBar(pathname)) return null;
|
||||
// The home page draws its own header inside the hero frame.
|
||||
if (pathname === "/home") return null;
|
||||
if (shouldShowTitlebar(pathname)) return null;
|
||||
// The video/photo players have their own fullscreen UI.
|
||||
if (pathname.startsWith("/player")) return null;
|
||||
// Library and search headers draw the window buttons themselves.
|
||||
if (pathname.startsWith("/library") || pathname.startsWith("/search")) {
|
||||
return null;
|
||||
}
|
||||
// The remote control page has its own titlebar with window buttons.
|
||||
if (pathname.startsWith("/remote")) return null;
|
||||
|
||||
return (
|
||||
<div className="window-chrome">
|
||||
|
||||
@@ -36,11 +36,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
html.is-windows .home-header .window-controls,
|
||||
html.is-linux .home-header .window-controls {
|
||||
margin-left: 0.6rem;
|
||||
}
|
||||
|
||||
.window-resize-handles {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { useEffect } from "react";
|
||||
|
||||
/**
|
||||
* Height of the draggable titlebar hit area. Headers on every page fit inside
|
||||
* it; interactive controls are filtered out below.
|
||||
*/
|
||||
const DRAG_ZONE = 64;
|
||||
const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
|
||||
|
||||
/**
|
||||
* Interactive elements inside the titlebar must keep receiving clicks
|
||||
@@ -47,9 +43,12 @@ const INTERACTIVE_SELECTOR = [
|
||||
*/
|
||||
const WindowDrag = () => {
|
||||
useEffect(() => {
|
||||
if (isMobile) return;
|
||||
const onMouseDown = (event: MouseEvent) => {
|
||||
if (event.button !== 0 || event.buttons !== 1) return;
|
||||
if (event.clientY > DRAG_ZONE) return;
|
||||
const titlebar = document.querySelector<HTMLElement>(".app-titlebar");
|
||||
if (!titlebar) return;
|
||||
if (event.clientY > titlebar.getBoundingClientRect().bottom) return;
|
||||
if (document.fullscreenElement) return;
|
||||
if (window.location.pathname.startsWith("/player")) return;
|
||||
|
||||
|
||||
@@ -143,6 +143,12 @@ const init = async () => {
|
||||
document.documentElement.classList.add("is-linux");
|
||||
}
|
||||
|
||||
// The overlay scrollbar hides the native page scrollbar. Apply it before the
|
||||
// first render so layout measurements do not see a ~13px scrollbar that is
|
||||
// removed a frame later (which made library cards resize after load).
|
||||
document.documentElement.classList.add("has-overlay-scrollbar");
|
||||
document.body.classList.add("has-overlay-scrollbar");
|
||||
|
||||
// Layout transitions during a live window resize cause visible wobble
|
||||
// (headers, cards, MUI components). Disable them until resizing settles.
|
||||
let resizeTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ThemeProvider } from "@mui/material/styles";
|
||||
import { createRootRouteWithContext, Outlet } from "@tanstack/react-router";
|
||||
import { SnackbarProvider } from "notistack";
|
||||
import React from "react";
|
||||
import { AppBar } from "@/components/appBar/appBar";
|
||||
import { AppTitlebar } from "@/components/appTitlebar";
|
||||
import MobilePreview from "@/components/mobilePreview";
|
||||
// import NProgress from "@/components/nProgress";
|
||||
import AudioPlayer from "@/components/playback/audioPlayer";
|
||||
@@ -25,22 +25,22 @@ import Backdrop from "@/components/backdrop";
|
||||
import DeepLinkHandler from "@/components/deepLinks";
|
||||
import FollowMe from "@/components/followMe";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import QuickConnectApprovalDialog from "@/components/quickConnectApproval";
|
||||
import ShareDialog from "@/components/share";
|
||||
import OverlayScrollbar from "@/components/overlayScrollbar";
|
||||
import PlaybackSync from "@/components/playback/PlaybackSync";
|
||||
import QuickConnectApprovalDialog from "@/components/quickConnectApproval";
|
||||
import RealtimeBridge from "@/components/realtime";
|
||||
import SplashHider from "@/components/splash";
|
||||
import RemoteControlDialog from "@/components/remoteControl";
|
||||
import RouterLoading from "@/components/routerLoading";
|
||||
import SpatialNavigation from "@/components/spatialNavigation";
|
||||
import SyncPlayController from "@/components/syncPlay/controller";
|
||||
import SyncPlayDialog from "@/components/syncPlay";
|
||||
import Search from "@/components/search";
|
||||
import ShareDialog from "@/components/share";
|
||||
import SpatialNavigation from "@/components/spatialNavigation";
|
||||
import SplashHider from "@/components/splash";
|
||||
import SyncPlayDialog from "@/components/syncPlay";
|
||||
import SyncPlayController from "@/components/syncPlay/controller";
|
||||
import Updater from "@/components/updater";
|
||||
import WindowResizeHandles from "@/components/windowControls/resizeHandles";
|
||||
import WindowChrome from "@/components/windowControls/windowChrome";
|
||||
import WindowDrag from "@/components/windowControls/windowDrag";
|
||||
import WindowResizeHandles from "@/components/windowControls/resizeHandles";
|
||||
|
||||
type ApiContext = {
|
||||
api: Api | undefined;
|
||||
@@ -72,7 +72,7 @@ export const Route = createRootRouteWithContext<ApiContext>()({
|
||||
<ShareDialog />
|
||||
<QuickConnectApprovalDialog />
|
||||
<DeepLinkHandler />
|
||||
<AppBar />
|
||||
<AppTitlebar />
|
||||
<MobilePreview />
|
||||
<WindowChrome />
|
||||
<WindowDrag />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* Home page: a full-bleed cinema window with an integrated header. */
|
||||
/* Home page: a full-bleed cinema window under the global titlebar. The route
|
||||
root starts at y=0; the titlebar floats over the hero. */
|
||||
.home-cinema {
|
||||
--home-trending-space: 200px;
|
||||
|
||||
@@ -22,107 +23,6 @@ body.has-player-bar .home-cinema {
|
||||
background: #08090d;
|
||||
}
|
||||
|
||||
/* Header floating over the hero artwork. */
|
||||
.home-header {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 20;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding: 1.3rem clamp(1.5rem, 3vw, 2.5rem) 1.4rem;
|
||||
color: #fff;
|
||||
background: linear-gradient(180deg, rgb(0 0 0 / 0.42), transparent);
|
||||
|
||||
&-left,
|
||||
&-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&-right {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
// Keep the menu clear of the macOS traffic lights now that the frame
|
||||
// reaches the window edges, and align it vertically with them.
|
||||
html.is-macos & {
|
||||
padding-top: 0.6rem;
|
||||
|
||||
&-left {
|
||||
padding-left: 64px;
|
||||
}
|
||||
}
|
||||
|
||||
&-logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-family: "Medeo Sans", system-ui, sans-serif;
|
||||
font-size: 2.55rem;
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
letter-spacing: 0;
|
||||
line-height: 0.9;
|
||||
user-select: none;
|
||||
text-shadow: 0 2px 18px rgb(0 0 0 / 0.5);
|
||||
|
||||
&-mark {
|
||||
width: 2.15rem;
|
||||
height: 1.72rem;
|
||||
flex: 0 0 auto;
|
||||
color: currentColor;
|
||||
overflow: visible;
|
||||
}
|
||||
}
|
||||
|
||||
.home-nav-link {
|
||||
padding: 0.5rem 0.7rem;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
color: rgb(255 255 255 / 0.76);
|
||||
font: inherit;
|
||||
font-size: 0.92rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
color 0.18s ease,
|
||||
background-color 0.18s ease;
|
||||
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.08);
|
||||
}
|
||||
}
|
||||
|
||||
.MuiIconButton-root {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
color: rgb(255 255 255 / 0.88);
|
||||
background: rgb(255 255 255 / 0.08);
|
||||
border: 1px solid rgb(255 255 255 / 0.1);
|
||||
backdrop-filter: blur(10px);
|
||||
transition:
|
||||
background-color 0.18s ease,
|
||||
color 0.18s ease;
|
||||
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.16);
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.home-sections {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -244,14 +144,9 @@ body.has-player-bar .home-sections {
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.home-header {
|
||||
.home-nav-link {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&-logo {
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
.cinema-trending {
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,30 +161,6 @@ body.has-player-bar .home-sections {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.home-header {
|
||||
padding: calc(0.55rem + var(--safe-top)) 0.8rem 1rem;
|
||||
|
||||
.home-header-groups,
|
||||
.home-header-cast {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&-logo {
|
||||
font-size: 1.4rem;
|
||||
gap: 0.35rem;
|
||||
|
||||
&-mark {
|
||||
width: 1.7rem;
|
||||
height: 1.4rem;
|
||||
}
|
||||
}
|
||||
|
||||
.MuiIconButton-root {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
}
|
||||
}
|
||||
|
||||
.cinema-trending {
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import React, { useCallback, useState } from "react";
|
||||
import { NavigationDrawer } from "@/components/appBar/navigationDrawer";
|
||||
import CastButton from "@/components/buttons/castButton";
|
||||
import { UserAvatarMenu } from "@/components/userAvatarMenu";
|
||||
import WindowControls from "@/components/windowControls";
|
||||
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
||||
import useSearchStore from "@/utils/store/search";
|
||||
|
||||
type HomeHeaderProps = {
|
||||
libraries: BaseItemDto[];
|
||||
onNewAndPopular: () => void;
|
||||
};
|
||||
|
||||
const HomeHeader = ({ libraries, onNewAndPopular }: HomeHeaderProps) => {
|
||||
const navigate = useNavigate();
|
||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||
const toggleSearchDialog = useSearchStore((s) => s.toggleSearchDialog);
|
||||
|
||||
const moviesLibrary = libraries.find(
|
||||
(library) => library.CollectionType === "movies",
|
||||
);
|
||||
const showsLibrary = libraries.find(
|
||||
(library) => library.CollectionType === "tvshows",
|
||||
);
|
||||
|
||||
const openMovies = useCallback(() => {
|
||||
if (!moviesLibrary?.Id) return;
|
||||
navigate({ to: "/library/$id", params: { id: moviesLibrary.Id } });
|
||||
}, [moviesLibrary?.Id, navigate]);
|
||||
|
||||
const openShows = useCallback(() => {
|
||||
if (!showsLibrary?.Id) return;
|
||||
navigate({ to: "/library/$id", params: { id: showsLibrary.Id } });
|
||||
}, [showsLibrary?.Id, navigate]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<header className="home-header" data-tauri-drag-region>
|
||||
<div className="home-header-left" data-tauri-drag-region>
|
||||
<IconButton
|
||||
aria-label="Открыть меню"
|
||||
onClick={() => setDrawerOpen(true)}
|
||||
>
|
||||
<span className="material-symbols-rounded">menu</span>
|
||||
</IconButton>
|
||||
{moviesLibrary?.Id && (
|
||||
<button
|
||||
type="button"
|
||||
className="home-nav-link"
|
||||
onClick={openMovies}
|
||||
>
|
||||
Фильмы
|
||||
</button>
|
||||
)}
|
||||
{showsLibrary?.Id && (
|
||||
<button
|
||||
type="button"
|
||||
className="home-nav-link"
|
||||
onClick={openShows}
|
||||
>
|
||||
Сериалы
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="home-nav-link"
|
||||
onClick={onNewAndPopular}
|
||||
>
|
||||
Новинки
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="home-header-logo" data-tauri-drag-region>
|
||||
<svg
|
||||
className="home-header-logo-mark"
|
||||
viewBox="0 0 40 32"
|
||||
fill="none"
|
||||
aria-hidden="true"
|
||||
>
|
||||
{/* Quick marker doodle: a blinking eye with little rays. */}
|
||||
<g
|
||||
stroke="currentColor"
|
||||
strokeWidth="2.2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<path d="M8.5 7.6 4.7 4.2" />
|
||||
<path d="M14.2 5.4 13.4 1.4" />
|
||||
<path d="M20.4 5.2 21.1 1.3" />
|
||||
<path d="M5.2 18.4c3.7-5.9 10.5-8.3 16.6-5.7 4.2 1.8 7.6 5 9.8 8.2-4.8 4.7-12.4 6.1-18.2 3.5-3.7-1.7-6.4-3.7-8.2-6Z" />
|
||||
<path
|
||||
d="M18.7 18.5a2.9 2.9 0 1 0 0-5.8 2.9 2.9 0 0 0 0 5.8Z"
|
||||
fill="currentColor"
|
||||
stroke="none"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
<span>Blink</span>
|
||||
</div>
|
||||
|
||||
<div className="home-header-right">
|
||||
<IconButton
|
||||
className="home-header-groups"
|
||||
aria-label="Смотреть вместе"
|
||||
title="Смотреть вместе"
|
||||
onClick={openSyncPlayDialog}
|
||||
>
|
||||
<span className="material-symbols-rounded">groups</span>
|
||||
</IconButton>
|
||||
<IconButton aria-label="Поиск" onClick={toggleSearchDialog}>
|
||||
<span className="material-symbols-rounded">search</span>
|
||||
</IconButton>
|
||||
<span className="home-header-cast">
|
||||
<CastButton />
|
||||
</span>
|
||||
<IconButton
|
||||
aria-label="Избранное"
|
||||
onClick={() => navigate({ to: "/favorite" })}
|
||||
>
|
||||
<span className="material-symbols-rounded">favorite</span>
|
||||
</IconButton>
|
||||
<UserAvatarMenu />
|
||||
<WindowControls />
|
||||
</div>
|
||||
</header>
|
||||
<NavigationDrawer
|
||||
open={drawerOpen}
|
||||
onClose={() => setDrawerOpen(false)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default HomeHeader;
|
||||
@@ -28,7 +28,6 @@ import { getLatestItemsQueryOptions } from "@/utils/queries/items";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import HomeHeader from "./homeHeader";
|
||||
|
||||
export const Route = createFileRoute("/_api/home/")({
|
||||
component: Home,
|
||||
@@ -62,9 +61,7 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const latestMedia = useQuery(
|
||||
getLatestItemsQueryOptions(api, user.Id),
|
||||
);
|
||||
const latestMedia = useQuery(getLatestItemsQueryOptions(api, user.Id));
|
||||
|
||||
const resumeItemsVideo = useQuery({
|
||||
queryKey: ["home", "resume", "video"],
|
||||
@@ -172,12 +169,6 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
||||
[heroItems, setBackdropForItem],
|
||||
);
|
||||
|
||||
const scrollToNewAndPopular = useCallback(() => {
|
||||
document
|
||||
.getElementById("home-sections")
|
||||
?.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!libraries.data || !latestMedia.data) return;
|
||||
performance.mark("blink:home-ready");
|
||||
@@ -188,10 +179,6 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
||||
return (
|
||||
<main className="home-cinema">
|
||||
<div className="home-frame">
|
||||
<HomeHeader
|
||||
libraries={libraries.data?.Items ?? []}
|
||||
onNewAndPopular={scrollToNewAndPopular}
|
||||
/>
|
||||
<section
|
||||
className="home-skeleton"
|
||||
aria-busy="true"
|
||||
@@ -220,11 +207,6 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
||||
return (
|
||||
<main className="home-cinema">
|
||||
<div className="home-frame">
|
||||
<HomeHeader
|
||||
libraries={libraries.data?.Items ?? []}
|
||||
onNewAndPopular={scrollToNewAndPopular}
|
||||
/>
|
||||
|
||||
<ErrorBoundary FallbackComponent={ErrorNotice}>
|
||||
{heroItems.length > 0 && (
|
||||
<Carousel content={heroItems} onChange={handleOnChangeCarousel} />
|
||||
@@ -251,7 +233,10 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
||||
disableOverlay
|
||||
onClick={() => {
|
||||
if (item.Id) {
|
||||
navigate({ to: "/library/$id", params: { id: item.Id } });
|
||||
navigate({
|
||||
to: "/library/$id",
|
||||
params: { id: item.Id },
|
||||
});
|
||||
}
|
||||
}}
|
||||
overrideIcon={item.CollectionType}
|
||||
@@ -297,9 +282,12 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
||||
: item.Type === BaseItemKind.Series
|
||||
? `${item.ProductionYear} - ${
|
||||
item.EndDate
|
||||
? new Date(item.EndDate).toLocaleString("ru-RU", {
|
||||
? new Date(item.EndDate).toLocaleString(
|
||||
"ru-RU",
|
||||
{
|
||||
year: "numeric",
|
||||
})
|
||||
},
|
||||
)
|
||||
: "н.в."
|
||||
}`
|
||||
: item.ProductionYear
|
||||
@@ -348,9 +336,12 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
||||
: item.Type === BaseItemKind.Series
|
||||
? `${item.ProductionYear} - ${
|
||||
item.EndDate
|
||||
? new Date(item.EndDate).toLocaleString("ru-RU", {
|
||||
? new Date(item.EndDate).toLocaleString(
|
||||
"ru-RU",
|
||||
{
|
||||
year: "numeric",
|
||||
})
|
||||
},
|
||||
)
|
||||
: "н.в."
|
||||
}`
|
||||
: item.ProductionYear
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BaseItemKind, ItemSortBy } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||
import React, { Suspense, useEffect } from "react";
|
||||
import React, { Suspense } from "react";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import "./library.scss";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
@@ -13,7 +13,6 @@ import { getDefaultSortByForCollectionType } from "@/utils/constants/library";
|
||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import useHeaderStore from "@/utils/store/header";
|
||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||
|
||||
// type SortByObject = { title: string; value: string };
|
||||
@@ -66,12 +65,10 @@ function Library() {
|
||||
getLibraryQueryOptions(api, user?.Id, id),
|
||||
);
|
||||
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||
const { libraryName: storeLibraryName, currentViewType } =
|
||||
useLibraryStateStore(
|
||||
const { currentViewType } = useLibraryStateStore(
|
||||
useShallow((s) => {
|
||||
const sl = s.libraries[id || ""];
|
||||
return {
|
||||
libraryName: sl?.libraryName,
|
||||
currentViewType: sl?.currentViewType,
|
||||
} as const;
|
||||
}),
|
||||
@@ -83,18 +80,6 @@ function Library() {
|
||||
updateLibrary(id, { libraryName: currentLib.data.Name ?? undefined });
|
||||
}, [id, updateLibrary, currentLib.data]);
|
||||
|
||||
const { setPageTitle } = useHeaderStore(
|
||||
useShallow((state) => ({
|
||||
setPageTitle: state.setPageTitle,
|
||||
})),
|
||||
);
|
||||
// Derive top app title from Zustand slice (library name)
|
||||
useEffect(() => {
|
||||
const title = storeLibraryName ?? "Библиотека";
|
||||
setPageTitle(title);
|
||||
return () => setPageTitle(null);
|
||||
}, [storeLibraryName, setPageTitle]);
|
||||
|
||||
/* if (!id) {
|
||||
// show loading if any route param is missing
|
||||
return <LoadingIndicator />;
|
||||
@@ -122,7 +107,20 @@ function Library() {
|
||||
</div>
|
||||
)}
|
||||
>
|
||||
<Suspense fallback={<LibraryItemsSkeleton />}>
|
||||
<Suspense
|
||||
fallback={
|
||||
<LibraryItemsSkeleton
|
||||
square={
|
||||
currentViewType === BaseItemKind.MusicAlbum ||
|
||||
currentViewType === BaseItemKind.Audio ||
|
||||
currentViewType === BaseItemKind.Genre ||
|
||||
currentViewType === BaseItemKind.MusicGenre ||
|
||||
currentViewType === BaseItemKind.Studio ||
|
||||
currentViewType === BaseItemKind.Playlist
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<div className="library-items">
|
||||
<LibraryItemsGrid />
|
||||
</div>
|
||||
@@ -134,7 +132,7 @@ function Library() {
|
||||
currentLib.data.CollectionType === "music"
|
||||
? "max(14px, calc((100vw - 1180px) / 2 + 18px))"
|
||||
: 14,
|
||||
top: 80,
|
||||
top: "calc(var(--app-titlebar-height) + 96px)",
|
||||
}}
|
||||
>
|
||||
<AlphaSelector />
|
||||
|
||||
@@ -215,13 +215,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.alpha-selector {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.library.padded-top {
|
||||
padding-top: 0 !important;
|
||||
padding-top: calc(var(--app-titlebar-height) + 0.75rem) !important;
|
||||
}
|
||||
|
||||
.library-items {
|
||||
padding-top: calc(8.4em + var(--safe-top)) !important;
|
||||
padding-top: 0.5rem !important;
|
||||
padding-bottom: calc(7.5em + var(--safe-bottom)) !important;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
max-width: 1180px;
|
||||
margin: 0 auto;
|
||||
padding: clamp(3.4em, 6vw, 4.6em) clamp(1.5em, 4vw, 3.5em) 7em;
|
||||
padding-top: calc(var(--app-titlebar-height) + clamp(3.4em, 6vw, 4.6em));
|
||||
|
||||
.music-hero {
|
||||
display: flex;
|
||||
|
||||
@@ -10,7 +10,11 @@ import "./videoPlayer.scss";
|
||||
|
||||
import { RepeatMode } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { createFileRoute, useNavigate, useRouter } from "@tanstack/react-router";
|
||||
import {
|
||||
createFileRoute,
|
||||
useNavigate,
|
||||
useRouter,
|
||||
} from "@tanstack/react-router";
|
||||
import JASSUB from "jassub";
|
||||
import wasmUrl from "jassub/dist/wasm/jassub-worker.wasm?url"; // non-SIMD fallback
|
||||
import modernWasmUrl from "jassub/dist/wasm/jassub-worker-modern.wasm?url"; // SIMD
|
||||
@@ -27,14 +31,6 @@ import StatsForNerds from "@/components/playback/videoPlayer/StatsForNerds";
|
||||
import UpNextFlyout from "@/components/playback/videoPlayer/upNextFlyout";
|
||||
import VolumeChangeOverlay from "@/components/playback/videoPlayer/VolumeChangeOverlay";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import {
|
||||
getAutoSkipSegments,
|
||||
getVideoFitMode,
|
||||
setVideoFitMode,
|
||||
} from "@/utils/storage/player";
|
||||
import type { VideoFitMode } from "@/utils/types/videoFitMode";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import {
|
||||
inSyncPlayGroup,
|
||||
nextSyncPlayItem,
|
||||
@@ -44,9 +40,17 @@ import {
|
||||
reportSyncPlayResume,
|
||||
reportSyncPlaySeek,
|
||||
} from "@/utils/methods/syncPlay";
|
||||
import {
|
||||
getAutoSkipSegments,
|
||||
getVideoFitMode,
|
||||
setVideoFitMode,
|
||||
} from "@/utils/storage/player";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import useQueue, { clearQueue } from "@/utils/store/queue";
|
||||
import type subtitlePlaybackInfo from "@/utils/types/subtitlePlaybackInfo";
|
||||
import type { VideoFitMode } from "@/utils/types/videoFitMode";
|
||||
import font from "./Noto-Sans-Indosphere.ttf?url";
|
||||
|
||||
/**
|
||||
@@ -100,6 +104,7 @@ export function VideoPlayer() {
|
||||
const navigate = useNavigate();
|
||||
const { history } = useRouter();
|
||||
const player = useRef<HTMLVideoElement | null>(null);
|
||||
const exitingPlayerRef = useRef(false);
|
||||
/** Re-apply the transfer/resume position until the HLS player stabilises. */
|
||||
const startSeekRef = useRef<{ target: number; expiresAt: number } | null>(
|
||||
null,
|
||||
@@ -204,11 +209,7 @@ export function VideoPlayer() {
|
||||
const cycleFitMode = useCallback(() => {
|
||||
setFitMode((current) => {
|
||||
const next =
|
||||
current === "fit"
|
||||
? "fill"
|
||||
: current === "fill"
|
||||
? "stretch"
|
||||
: "fit";
|
||||
current === "fit" ? "fill" : current === "fill" ? "stretch" : "fit";
|
||||
void setVideoFitMode(next);
|
||||
return next;
|
||||
});
|
||||
@@ -393,15 +394,24 @@ export function VideoPlayer() {
|
||||
VolumeLevel: Math.floor(volume * 100),
|
||||
},
|
||||
});
|
||||
const player = getVideoElement();
|
||||
reportSyncPlayReady(
|
||||
api,
|
||||
secToTicks(getVideoElement()?.currentTime ?? 0),
|
||||
true,
|
||||
secToTicks(player?.currentTime ?? 0),
|
||||
Boolean(player && !player.paused),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const lastReportTimeRef = useRef<number>(0);
|
||||
const bufferReportTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (bufferReportTimer.current) clearTimeout(bufferReportTimer.current);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const handleTimeUpdate = useCallback(async () => {
|
||||
const videoElement = getVideoElement();
|
||||
@@ -491,7 +501,9 @@ export function VideoPlayer() {
|
||||
VolumeLevel: Math.floor(volume * 100),
|
||||
},
|
||||
});
|
||||
reportSyncPlayPause(api);
|
||||
// Leaving the player is not a request to pause the whole SyncPlay
|
||||
// group; the player pauses as it unmounts.
|
||||
if (!exitingPlayerRef.current) reportSyncPlayPause(api);
|
||||
}, [
|
||||
setCurrentTime,
|
||||
api,
|
||||
@@ -505,6 +517,7 @@ export function VideoPlayer() {
|
||||
]);
|
||||
|
||||
const handleExitPlayer = useCallback(async () => {
|
||||
exitingPlayerRef.current = true;
|
||||
appWindow.getCurrent().setFullscreen(false);
|
||||
|
||||
history.back();
|
||||
@@ -531,7 +544,8 @@ export function VideoPlayer() {
|
||||
clearQueue();
|
||||
}, []);
|
||||
|
||||
const handleKeyPress = useCallback((event: KeyboardEvent) => {
|
||||
const handleKeyPress = useCallback(
|
||||
(event: KeyboardEvent) => {
|
||||
const videoElement = getVideoElement();
|
||||
if (videoElement) {
|
||||
event.preventDefault();
|
||||
@@ -585,7 +599,9 @@ export function VideoPlayer() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, [cycleFitMode]);
|
||||
},
|
||||
[cycleFitMode],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
// attach the event listener
|
||||
@@ -718,22 +734,35 @@ export function VideoPlayer() {
|
||||
|
||||
const handleOnBuffer = useCallback(() => {
|
||||
setIsBuffering(true);
|
||||
// A few hundred milliseconds of network jitter should not pause the
|
||||
// whole group; only report a real stall.
|
||||
if (bufferReportTimer.current) clearTimeout(bufferReportTimer.current);
|
||||
bufferReportTimer.current = setTimeout(() => {
|
||||
bufferReportTimer.current = null;
|
||||
reportSyncPlayBuffering(
|
||||
api,
|
||||
true,
|
||||
secToTicks(getVideoElement()?.currentTime ?? 0),
|
||||
isPlayerPlaying,
|
||||
);
|
||||
}, 700);
|
||||
}, [setIsBuffering, api, isPlayerPlaying]);
|
||||
const handleOnBufferEnd = useCallback(() => {
|
||||
setIsBuffering(false);
|
||||
reportSyncPlayBuffering(
|
||||
if (bufferReportTimer.current) {
|
||||
clearTimeout(bufferReportTimer.current);
|
||||
bufferReportTimer.current = null;
|
||||
}
|
||||
// A Buffer request always marks the session as buffering on the
|
||||
// server. When buffering ends the session is ready, not buffering:
|
||||
// sending another Buffer request here would leave the whole group
|
||||
// waiting for a client that is already playing.
|
||||
reportSyncPlayReady(
|
||||
api,
|
||||
false,
|
||||
secToTicks(getVideoElement()?.currentTime ?? 0),
|
||||
true,
|
||||
isPlayerPlaying,
|
||||
);
|
||||
}, [setIsBuffering, api]);
|
||||
}, [setIsBuffering, api, isPlayerPlaying]);
|
||||
|
||||
const handleError = useCallback((e: any) => {
|
||||
console.error("Video playback error:", e);
|
||||
|
||||
+115
-74
@@ -14,8 +14,10 @@
|
||||
--remote-surface-hover: rgb(255 255 255 / 0.14);
|
||||
--remote-border: rgb(255 255 255 / 0.1);
|
||||
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
position: relative;
|
||||
height: 100vh;
|
||||
padding-top: var(--app-titlebar-height);
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
@@ -29,62 +31,6 @@
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ top */
|
||||
|
||||
.remote-topbar {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 24px;
|
||||
height: 58px;
|
||||
padding: 0 var(--remote-gutter);
|
||||
box-sizing: border-box;
|
||||
|
||||
html.is-macos & {
|
||||
padding-left: calc(var(--remote-gutter) + 64px);
|
||||
}
|
||||
|
||||
.MuiIconButton-root {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
color: rgb(255 255 255 / 0.88);
|
||||
background: rgb(255 255 255 / 0.08);
|
||||
border: 1px solid rgb(255 255 255 / 0.1);
|
||||
backdrop-filter: blur(10px);
|
||||
transition:
|
||||
background-color 0.18s ease,
|
||||
color 0.18s ease;
|
||||
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.16);
|
||||
}
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
&-left,
|
||||
&-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&-divider {
|
||||
width: 1px;
|
||||
height: 26px;
|
||||
background: rgb(255 255 255 / 0.12);
|
||||
}
|
||||
}
|
||||
|
||||
html.is-macos .remote-topbar-right .remote-topbar-divider {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.remote-chevron {
|
||||
opacity: 0.6;
|
||||
font-size: 1.15rem !important;
|
||||
@@ -109,6 +55,9 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
|
||||
}
|
||||
|
||||
.remote-devices-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5em;
|
||||
margin: 0 0 0.5em 0.45em;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 500;
|
||||
@@ -117,14 +66,29 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
|
||||
color: rgb(255 255 255 / 0.5);
|
||||
}
|
||||
|
||||
.remote-devices-count {
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
min-width: 1.35rem;
|
||||
height: 1.35rem;
|
||||
padding: 0 0.3rem;
|
||||
border-radius: 999px;
|
||||
letter-spacing: 0;
|
||||
font-size: 0.66rem;
|
||||
color: #fff;
|
||||
background: rgb(255 255 255 / 0.1);
|
||||
border: 1px solid rgb(255 255 255 / 0.1);
|
||||
}
|
||||
|
||||
.remote-device-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25em;
|
||||
gap: 0.55em;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow-y: auto;
|
||||
list-style: none;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: rgb(255 255 255 / 0.16) transparent;
|
||||
}
|
||||
|
||||
.remote-device {
|
||||
@@ -282,6 +246,95 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
|
||||
backdrop-filter: blur(12px);
|
||||
}
|
||||
|
||||
.remote-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.remote-action {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
height: 2.4rem;
|
||||
padding: 0 0.95rem;
|
||||
border: 1px solid rgb(255 255 255 / 0.12);
|
||||
border-radius: 999px;
|
||||
background: rgb(255 255 255 / 0.07);
|
||||
color: rgb(255 255 255 / 0.85);
|
||||
font: inherit;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
backdrop-filter: blur(14px);
|
||||
transition:
|
||||
background-color 160ms ease,
|
||||
border-color 160ms ease,
|
||||
color 160ms ease,
|
||||
opacity 160ms ease;
|
||||
|
||||
.material-symbols-rounded {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: rgb(255 255 255 / 0.13);
|
||||
border-color: rgb(255 255 255 / 0.22);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
&.is-primary {
|
||||
border-color: transparent;
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgb(255 79 154 / 0.92),
|
||||
rgb(166 107 255 / 0.92)
|
||||
);
|
||||
color: #fff;
|
||||
box-shadow: 0 8px 24px rgb(255 79 154 / 0.24);
|
||||
}
|
||||
}
|
||||
|
||||
.remote-group-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
height: 2.2rem;
|
||||
padding: 0 0.8rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
color: #c9f8dd;
|
||||
background: rgb(94 227 154 / 0.1);
|
||||
border: 1px solid rgb(94 227 154 / 0.2);
|
||||
}
|
||||
|
||||
.remote-group-dot {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: #5ee39a;
|
||||
box-shadow: 0 0 10px #5ee39a;
|
||||
}
|
||||
|
||||
@media (max-width: 820px) {
|
||||
.remote-actions {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.remote-action {
|
||||
font-size: 0.74rem;
|
||||
padding: 0 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.remote-overview {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 4;
|
||||
@@ -515,10 +568,6 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
|
||||
/* ------------------------------------------------------------ adapt */
|
||||
|
||||
@media (max-height: 780px) {
|
||||
.remote-topbar {
|
||||
height: 52px;
|
||||
}
|
||||
|
||||
.remote-title {
|
||||
font-size: clamp(1.6rem, 2.6vw, 2.3rem);
|
||||
}
|
||||
@@ -578,15 +627,6 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.remote-topbar {
|
||||
height: calc(52px + var(--safe-top));
|
||||
padding: var(--safe-top) 16px 0;
|
||||
}
|
||||
|
||||
html.is-macos .remote-topbar {
|
||||
padding-left: 76px;
|
||||
}
|
||||
|
||||
.remote-body {
|
||||
flex: 0 0 auto;
|
||||
flex-direction: column;
|
||||
@@ -649,7 +689,8 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
|
||||
|
||||
.remote-transport {
|
||||
justify-content: center;
|
||||
gap: 0.55rem;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.45rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
|
||||
+276
-119
@@ -9,23 +9,43 @@ import Menu from "@mui/material/Menu";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import Slider from "@mui/material/Slider";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import { useSnackbar } from "notistack";
|
||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
import CachedImage from "@/components/cachedImage";
|
||||
import { UserAvatarMenu } from "@/components/userAvatarMenu";
|
||||
import WindowControls from "@/components/windowControls";
|
||||
import SessionCard from "@/components/remoteControl/sessionCard";
|
||||
import { getRuntimeCompact } from "@/utils/date/time";
|
||||
import {
|
||||
getBlinkDeviceName,
|
||||
useBlinkSessions,
|
||||
} from "@/utils/methods/blinkSessions";
|
||||
import { getCoverPalette } from "@/utils/methods/coverColor";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import {
|
||||
getLocalMediaTransfer,
|
||||
useCurrentMediaItem,
|
||||
} from "@/utils/methods/localTransfer";
|
||||
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
||||
import {
|
||||
playOnSession,
|
||||
queueStartingWith,
|
||||
transferSessionToLocal,
|
||||
} from "@/utils/methods/transferPlayback";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { stopPlayback } from "@/utils/store/audioPlayback";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import useSearchStore from "@/utils/store/search";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
import { clearQueue } from "@/utils/store/queue";
|
||||
import useSyncPlayStore from "@/utils/store/syncPlay";
|
||||
|
||||
import "./remote.scss";
|
||||
|
||||
export const Route = createFileRoute("/_api/remote")({
|
||||
component: RemotePage,
|
||||
validateSearch: (search: Record<string, unknown>): { device?: string } => ({
|
||||
device: typeof search.device === "string" ? search.device : undefined,
|
||||
}),
|
||||
});
|
||||
|
||||
const TICKS_PER_SECOND = 10_000_000;
|
||||
@@ -40,11 +60,7 @@ const formatTime = (ticks: number | null | undefined) => {
|
||||
: `${m}:${String(s).padStart(2, "0")}`;
|
||||
};
|
||||
|
||||
const sessionLabel = (session: SessionInfoDto) =>
|
||||
session.DeviceName ||
|
||||
session.Client ||
|
||||
session.DeviceId ||
|
||||
"Неизвестное устройство";
|
||||
const sessionLabel = (session: SessionInfoDto) => getBlinkDeviceName(session);
|
||||
|
||||
const channelLabel = (channels?: number | null) => {
|
||||
if (!channels) return null;
|
||||
@@ -55,30 +71,33 @@ const channelLabel = (channels?: number | null) => {
|
||||
return `${channels} ch`;
|
||||
};
|
||||
|
||||
const sessionKind = (session: SessionInfoDto) => {
|
||||
const type = session.NowPlayingItem?.Type;
|
||||
if (type === "TvChannel") return "tv";
|
||||
if (type === "Audio" || type === "MusicAlbum") return "speaker";
|
||||
if (type) return "tv";
|
||||
return session.Client?.toLowerCase().includes("web") ? "computer" : "tv";
|
||||
};
|
||||
|
||||
function RemotePage() {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
const { device: requestedDevice } = Route.useSearch();
|
||||
const navigate = useNavigate();
|
||||
const toggleSearchDialog = useSearchStore((s) => s.toggleSearchDialog);
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const blink = useBlinkSessions();
|
||||
const group = useSyncPlayStore((state) => state.group);
|
||||
|
||||
const [selectedId, setSelectedId] = useState<string | null>(null);
|
||||
const [selectedId, setSelectedId] = useState<string | null>(
|
||||
requestedDevice ?? null,
|
||||
);
|
||||
const [subtitleAnchor, setSubtitleAnchor] = useState<HTMLElement | null>(
|
||||
null,
|
||||
);
|
||||
const [audioAnchor, setAudioAnchor] = useState<HTMLElement | null>(null);
|
||||
const [subtitleIndex, setSubtitleIndex] = useState<number>(-1);
|
||||
const [audioIndex, setAudioIndex] = useState<number>(-1);
|
||||
const [volumeDraft, setVolumeDraft] = useState<number | null>(null);
|
||||
const [displayPosition, setDisplayPosition] = useState(0);
|
||||
const [isSeeking, setIsSeeking] = useState(false);
|
||||
const volumeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (requestedDevice) setSelectedId(requestedDevice);
|
||||
}, [requestedDevice]);
|
||||
|
||||
const clearVolumeTimer = () => {
|
||||
if (volumeTimerRef.current) {
|
||||
clearTimeout(volumeTimerRef.current);
|
||||
@@ -88,28 +107,7 @@ function RemotePage() {
|
||||
|
||||
useEffect(() => clearVolumeTimer, []);
|
||||
|
||||
const sessions = useQuery({
|
||||
queryKey: ["remoteSessions"],
|
||||
queryFn: async () => {
|
||||
if (!api || !user?.Id) return [];
|
||||
const result = await getSessionApi(api).getSessions();
|
||||
return result.data;
|
||||
},
|
||||
enabled: !!api && !!user?.Id,
|
||||
refetchInterval: () => {
|
||||
if (document.visibilityState !== "visible") return false;
|
||||
return 2500;
|
||||
},
|
||||
refetchIntervalInBackground: false,
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const remoteSessions = (sessions.data ?? []).filter(
|
||||
(session) =>
|
||||
session.Id &&
|
||||
session.DeviceId !== api?.deviceInfo.id &&
|
||||
session.UserId === user?.Id,
|
||||
);
|
||||
const remoteSessions = blink.sessions;
|
||||
|
||||
const playing = remoteSessions.find((session) => session.NowPlayingItem);
|
||||
const selected =
|
||||
@@ -120,6 +118,7 @@ function RemotePage() {
|
||||
useEffect(() => {
|
||||
setVolumeDraft(null);
|
||||
setSubtitleIndex(-1);
|
||||
setAudioIndex(-1);
|
||||
clearVolumeTimer();
|
||||
}, [selected?.Id]);
|
||||
|
||||
@@ -147,7 +146,7 @@ function RemotePage() {
|
||||
seekPositionTicks,
|
||||
controllingUserId: user?.Id,
|
||||
});
|
||||
await sessions.refetch();
|
||||
await blink.refetch();
|
||||
} catch (error) {
|
||||
console.error("Remote command failed", error);
|
||||
}
|
||||
@@ -168,12 +167,101 @@ function RemotePage() {
|
||||
ControllingUserId: user?.Id,
|
||||
},
|
||||
});
|
||||
await sessions.refetch();
|
||||
await blink.refetch();
|
||||
} catch (error) {
|
||||
console.error("Remote general command failed", error);
|
||||
enqueueSnackbar("Команда не выполнена", { variant: "error" });
|
||||
}
|
||||
};
|
||||
|
||||
const takeHere = useMutation({
|
||||
mutationFn: async (session: SessionInfoDto) => {
|
||||
if (!api || !user?.Id) return "none";
|
||||
return transferSessionToLocal(api, user.Id, session);
|
||||
},
|
||||
onSuccess: (kind, session) => {
|
||||
if (kind === "none") {
|
||||
enqueueSnackbar("На устройстве нечего забирать", { variant: "info" });
|
||||
return;
|
||||
}
|
||||
enqueueSnackbar(`Забрано с ${sessionLabel(session)}`, {
|
||||
variant: "success",
|
||||
});
|
||||
navigate({ to: kind === "audio" ? "/player/audio" : "/player" });
|
||||
},
|
||||
onError: () =>
|
||||
enqueueSnackbar("Не удалось забрать воспроизведение", {
|
||||
variant: "error",
|
||||
}),
|
||||
});
|
||||
|
||||
const sendLocalHere = useMutation({
|
||||
mutationFn: async (session: SessionInfoDto) => {
|
||||
if (!api || !user?.Id || !session.Id) {
|
||||
throw new Error("Нет устройства или сессии");
|
||||
}
|
||||
const transfer = getLocalMediaTransfer();
|
||||
if (!transfer?.item?.Id) {
|
||||
throw new Error("На этом устройстве ничего не играет");
|
||||
}
|
||||
const queueIds = queueStartingWith(
|
||||
transfer.queue ?? [],
|
||||
transfer.item.Id,
|
||||
);
|
||||
await playOnSession(api, user.Id, session.Id, {
|
||||
itemIds: queueIds.length > 0 ? queueIds : [transfer.item.Id],
|
||||
startIndex: 0,
|
||||
startPositionTicks: transfer.positionTicks ?? 0,
|
||||
mediaSourceId: transfer.item.MediaSources?.[0]?.Id ?? undefined,
|
||||
});
|
||||
if (transfer.kind === "audio") {
|
||||
stopPlayback();
|
||||
} else if (transfer.kind === "video") {
|
||||
const playback = usePlaybackStore.getState();
|
||||
const stoppedItemId = playback.metadata.item?.Id;
|
||||
const stoppedPosition = playback.playerState.currentTime;
|
||||
const mediaSourceId = playback.mediaSource.id;
|
||||
const playSessionId = playback.playsessionId;
|
||||
(
|
||||
document
|
||||
.querySelector("hls-video")
|
||||
?.shadowRoot?.querySelector("video") as HTMLVideoElement | null
|
||||
)?.pause();
|
||||
usePlaybackStore.setState(usePlaybackStore.getInitialState());
|
||||
clearQueue();
|
||||
if (stoppedItemId) {
|
||||
await getSessionApi(api)
|
||||
.reportPlaybackStopped({
|
||||
playbackStopInfo: {
|
||||
Failed: false,
|
||||
ItemId: stoppedItemId,
|
||||
MediaSourceId: mediaSourceId,
|
||||
PlaySessionId: playSessionId,
|
||||
PositionTicks: stoppedPosition,
|
||||
},
|
||||
})
|
||||
.catch((error) =>
|
||||
console.warn("Could not report local playback stopped", error),
|
||||
);
|
||||
}
|
||||
}
|
||||
return transfer.item.Name ?? "медиа";
|
||||
},
|
||||
onSuccess: (name, session) => {
|
||||
enqueueSnackbar(`${name} передано на ${sessionLabel(session)}`, {
|
||||
variant: "success",
|
||||
});
|
||||
},
|
||||
onError: (error) =>
|
||||
enqueueSnackbar(
|
||||
error instanceof Error ? error.message : "Не удалось передать медиа",
|
||||
{ variant: "error" },
|
||||
),
|
||||
});
|
||||
|
||||
const localMediaItem = useCurrentMediaItem();
|
||||
const canSendLocal = Boolean(localMediaItem);
|
||||
|
||||
const nowPlaying = selected?.NowPlayingItem;
|
||||
const playState = selected?.PlayState;
|
||||
const isPaused = playState?.IsPaused ?? true;
|
||||
@@ -242,9 +330,16 @@ function RemotePage() {
|
||||
const audioStream = nowPlaying?.MediaStreams?.find(
|
||||
(stream) => stream.Type === "Audio",
|
||||
);
|
||||
const audioStreams =
|
||||
nowPlaying?.MediaStreams?.filter((stream) => stream.Type === "Audio") ?? [];
|
||||
const subtitleStreams =
|
||||
nowPlaying?.MediaStreams?.filter((stream) => stream.Type === "Subtitle") ??
|
||||
[];
|
||||
const audioLabel =
|
||||
audioIndex < 0
|
||||
? (audioStreams.find((s) => s.IsDefault)?.DisplayTitle ?? "Авто")
|
||||
: (audioStreams.find((s) => s.Index === audioIndex)?.DisplayTitle ??
|
||||
`Дорожка ${audioIndex}`);
|
||||
|
||||
const chips = [
|
||||
nowPlaying?.OfficialRating,
|
||||
@@ -279,6 +374,15 @@ function RemotePage() {
|
||||
});
|
||||
};
|
||||
|
||||
const chooseAudio = (index: number) => {
|
||||
if (!selected) return;
|
||||
setAudioIndex(index);
|
||||
setAudioAnchor(null);
|
||||
void general(selected, GeneralCommandType.SetAudioStreamIndex, {
|
||||
Index: String(index),
|
||||
});
|
||||
};
|
||||
|
||||
const transport = (name: PlaystateCommand) => {
|
||||
if (!selected) return;
|
||||
void command(selected, name);
|
||||
@@ -294,90 +398,46 @@ function RemotePage() {
|
||||
} as React.CSSProperties
|
||||
}
|
||||
>
|
||||
<header className="remote-topbar" data-tauri-drag-region>
|
||||
<div className="remote-topbar-left">
|
||||
<IconButton
|
||||
aria-label="Главная"
|
||||
title="Главная"
|
||||
onClick={() => navigate({ to: "/home" })}
|
||||
>
|
||||
<span className="material-symbols-rounded">home</span>
|
||||
</IconButton>
|
||||
{blink.isLoading ? (
|
||||
<div className="remote-empty">
|
||||
<span className="material-symbols-rounded animate-rotate">
|
||||
progress_activity
|
||||
</span>
|
||||
<h1>Ищем Blink-устройства</h1>
|
||||
<p>Подключаемся к серверу и собираем список клиентов Blink.</p>
|
||||
</div>
|
||||
|
||||
<div className="remote-topbar-right">
|
||||
<IconButton
|
||||
aria-label="Поиск"
|
||||
title="Поиск"
|
||||
onClick={toggleSearchDialog}
|
||||
>
|
||||
<span className="material-symbols-rounded">search</span>
|
||||
</IconButton>
|
||||
<UserAvatarMenu />
|
||||
<IconButton
|
||||
aria-label="Настройки"
|
||||
title="Настройки"
|
||||
onClick={() => navigate({ to: "/settings/preferences" })}
|
||||
>
|
||||
<span className="material-symbols-rounded">settings</span>
|
||||
</IconButton>
|
||||
<span className="remote-topbar-divider" />
|
||||
<WindowControls />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{!selected ? (
|
||||
) : !selected ? (
|
||||
<div className="remote-empty">
|
||||
<span className="material-symbols-rounded">settings_remote</span>
|
||||
<h1>Нет доступных устройств</h1>
|
||||
<h1>Нет Blink-устройств</h1>
|
||||
<p>
|
||||
Откройте клиент Jellyfin (телевизор, браузер, телефон) под этой
|
||||
учётной записью, и он появится здесь.
|
||||
Запустите Blink на другом устройстве под этой учётной записью. В
|
||||
пульте показываются только клиенты Blink — Jellyfin Web, телевизоры
|
||||
и другие приложения не попадают в этот список.
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<div className="remote-body">
|
||||
<aside className="remote-devices" aria-label="Устройства">
|
||||
<div className="remote-devices-title">Устройства</div>
|
||||
<ul className="remote-device-list">
|
||||
{remoteSessions.map((session) => {
|
||||
const isActive = session.Id === selected?.Id;
|
||||
const sessionItem = session.NowPlayingItem;
|
||||
return (
|
||||
<li key={session.Id}>
|
||||
<button
|
||||
type="button"
|
||||
className={`remote-device${isActive ? " is-active" : ""}`}
|
||||
onClick={() => setSelectedId(session.Id ?? null)}
|
||||
>
|
||||
<span className="material-symbols-rounded remote-device-icon">
|
||||
{sessionKind(session)}
|
||||
<aside className="remote-devices" aria-label="Blink-устройства">
|
||||
<div className="remote-devices-title">
|
||||
Устройства Blink
|
||||
<span className="remote-devices-count">
|
||||
{remoteSessions.length}
|
||||
</span>
|
||||
<span className="remote-device-info">
|
||||
<span className="remote-device-name">
|
||||
{sessionLabel(session)}
|
||||
</span>
|
||||
<span className="remote-device-meta">
|
||||
{sessionItem?.Name
|
||||
? session.PlayState?.IsPaused
|
||||
? `Пауза · ${sessionItem.Name}`
|
||||
: `Играет · ${sessionItem.Name}`
|
||||
: "Свободно"}
|
||||
</span>
|
||||
</span>
|
||||
{sessionItem && (
|
||||
<span
|
||||
className={`remote-device-dot${
|
||||
session.PlayState?.IsPaused ? " is-paused" : ""
|
||||
}`}
|
||||
</div>
|
||||
<div className="remote-device-list">
|
||||
{remoteSessions.map((session) => (
|
||||
<SessionCard
|
||||
key={session.Id}
|
||||
session={session}
|
||||
api={api}
|
||||
compact
|
||||
selected={session.Id === selected?.Id}
|
||||
onSelect={(target) => setSelectedId(target.Id ?? null)}
|
||||
/>
|
||||
)}
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
))}
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main className="remote-hero">
|
||||
@@ -407,6 +467,52 @@ function RemotePage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="remote-actions">
|
||||
{nowPlaying && (
|
||||
<button
|
||||
type="button"
|
||||
className="remote-action is-primary"
|
||||
disabled={takeHere.isPending}
|
||||
onClick={() => takeHere.mutate(selected)}
|
||||
>
|
||||
<span className="material-symbols-rounded">
|
||||
{takeHere.isPending ? "progress_activity" : "download"}
|
||||
</span>
|
||||
{takeHere.isPending ? "Забираем…" : "Забрать сюда"}
|
||||
</button>
|
||||
)}
|
||||
{canSendLocal && localMediaItem && (
|
||||
<button
|
||||
type="button"
|
||||
className="remote-action"
|
||||
disabled={sendLocalHere.isPending}
|
||||
onClick={() => sendLocalHere.mutate(selected)}
|
||||
>
|
||||
<span className="material-symbols-rounded">
|
||||
{sendLocalHere.isPending ? "progress_activity" : "send"}
|
||||
</span>
|
||||
{sendLocalHere.isPending
|
||||
? "Отправляем…"
|
||||
: `Отправить «${localMediaItem.Name ?? "медиа"}»`}
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="remote-action"
|
||||
onClick={openSyncPlayDialog}
|
||||
>
|
||||
<span className="material-symbols-rounded">groups</span>
|
||||
{group ? "Группа" : "Смотреть вместе"}
|
||||
</button>
|
||||
{group && (
|
||||
<span className="remote-group-chip">
|
||||
<span className="remote-group-dot" />
|
||||
{group.GroupName?.replace("Blink ·", "").trim() ||
|
||||
"В группе"}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{nowPlaying?.Overview && (
|
||||
<p className="remote-overview">{nowPlaying.Overview}</p>
|
||||
)}
|
||||
@@ -435,9 +541,7 @@ function RemotePage() {
|
||||
<button
|
||||
type="button"
|
||||
className="remote-round"
|
||||
onClick={() =>
|
||||
transport(PlaystateCommand.PreviousTrack)
|
||||
}
|
||||
onClick={() => transport(PlaystateCommand.PreviousTrack)}
|
||||
disabled={!nowPlaying}
|
||||
aria-label="Предыдущий"
|
||||
>
|
||||
@@ -483,6 +587,20 @@ function RemotePage() {
|
||||
</span>
|
||||
</button>
|
||||
</Tooltip>
|
||||
<Tooltip title="Остановить">
|
||||
<button
|
||||
type="button"
|
||||
className="remote-round"
|
||||
onClick={() => {
|
||||
if (!selected) return;
|
||||
void command(selected, PlaystateCommand.Stop);
|
||||
}}
|
||||
disabled={!nowPlaying}
|
||||
aria-label="Остановить"
|
||||
>
|
||||
<span className="material-symbols-rounded">stop</span>
|
||||
</button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
@@ -519,6 +637,19 @@ function RemotePage() {
|
||||
</div>
|
||||
|
||||
<footer className="remote-bottombar">
|
||||
<button
|
||||
type="button"
|
||||
className="remote-bottom-item"
|
||||
onClick={(event) => setAudioAnchor(event.currentTarget)}
|
||||
disabled={!nowPlaying || audioStreams.length === 0}
|
||||
>
|
||||
<span className="material-symbols-rounded">audiotrack</span>
|
||||
<span>Аудио: {audioLabel}</span>
|
||||
<span className="material-symbols-rounded remote-chevron">
|
||||
expand_more
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="remote-bottom-item"
|
||||
@@ -582,10 +713,36 @@ function RemotePage() {
|
||||
</button>
|
||||
</footer>
|
||||
|
||||
<Menu
|
||||
anchorEl={audioAnchor}
|
||||
open={Boolean(audioAnchor)}
|
||||
onClose={() => setAudioAnchor(null)}
|
||||
slotProps={{ paper: { className: "glass-menu-paper" } }}
|
||||
>
|
||||
<MenuItem
|
||||
selected={audioIndex === -1}
|
||||
onClick={() => chooseAudio(-1)}
|
||||
>
|
||||
Авто
|
||||
</MenuItem>
|
||||
{audioStreams.map((stream) => (
|
||||
<MenuItem
|
||||
key={stream.Index}
|
||||
selected={audioIndex === stream.Index}
|
||||
onClick={() => chooseAudio(stream.Index ?? -1)}
|
||||
>
|
||||
{stream.DisplayTitle ??
|
||||
stream.Language ??
|
||||
`Дорожка ${stream.Index}`}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Menu>
|
||||
|
||||
<Menu
|
||||
anchorEl={subtitleAnchor}
|
||||
open={Boolean(subtitleAnchor)}
|
||||
onClose={() => setSubtitleAnchor(null)}
|
||||
slotProps={{ paper: { className: "glass-menu-paper" } }}
|
||||
>
|
||||
<MenuItem
|
||||
selected={subtitleIndex === -1}
|
||||
|
||||
@@ -3,13 +3,12 @@ import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { getPersonApi } from "@jellyfin/sdk/lib/utils/api/person-api";
|
||||
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { Card } from "@/components/card/card";
|
||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import "./search.scss";
|
||||
import {
|
||||
AppBar,
|
||||
Box,
|
||||
Chip,
|
||||
Fade,
|
||||
@@ -22,16 +21,11 @@ import {
|
||||
Select,
|
||||
type SelectChangeEvent,
|
||||
Typography,
|
||||
useScrollTrigger,
|
||||
} from "@mui/material";
|
||||
import { createFileRoute, Outlet, useNavigate } from "@tanstack/react-router";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { NavigationDrawer } from "@/components/appBar/navigationDrawer";
|
||||
import BackButton from "@/components/buttons/backButton";
|
||||
import { UserAvatarMenu } from "@/components/userAvatarMenu";
|
||||
import WindowControls from "@/components/windowControls";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import useDebounce from "@/utils/hooks/useDebounce";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
|
||||
export const Route = createFileRoute("/_api/search/")({
|
||||
@@ -46,7 +40,11 @@ const CATEGORIES = [
|
||||
{ label: "Сериалы", value: "Series", kind: BaseItemKind.Series },
|
||||
{ label: "Серии", value: "Episode", kind: "Episode" },
|
||||
{ label: "Музыка", value: "MusicAlbum", kind: BaseItemKind.MusicAlbum },
|
||||
{ label: "Исполнители", value: "MusicArtist", kind: BaseItemKind.MusicArtist },
|
||||
{
|
||||
label: "Исполнители",
|
||||
value: "MusicArtist",
|
||||
kind: BaseItemKind.MusicArtist,
|
||||
},
|
||||
{ label: "Люди", value: "Person", kind: "Person" },
|
||||
{ label: "Книги", value: "Book", kind: BaseItemKind.Book },
|
||||
];
|
||||
@@ -100,7 +98,7 @@ function SearchPage() {
|
||||
className={`search-page-bg ${debouncedSearchTerm ? "active" : ""}`}
|
||||
/>
|
||||
|
||||
<SearchAppBar
|
||||
<SearchToolbar
|
||||
searchTerm={searchTerm}
|
||||
setSearchTerm={setSearchTerm}
|
||||
selectedCategories={selectedCategories}
|
||||
@@ -147,7 +145,7 @@ function SearchPage() {
|
||||
);
|
||||
}
|
||||
|
||||
interface SearchAppBarProps {
|
||||
interface SearchToolbarProps {
|
||||
searchTerm: string;
|
||||
setSearchTerm: (term: string) => void;
|
||||
selectedCategories: string[];
|
||||
@@ -155,72 +153,15 @@ interface SearchAppBarProps {
|
||||
handleClearCategories: () => void;
|
||||
}
|
||||
|
||||
function SearchAppBar({
|
||||
function SearchToolbar({
|
||||
searchTerm,
|
||||
setSearchTerm,
|
||||
selectedCategories,
|
||||
handleCategoryChange,
|
||||
handleClearCategories,
|
||||
}: SearchAppBarProps) {
|
||||
const scrollTrigger = useScrollTrigger({
|
||||
disableHysteresis: true,
|
||||
threshold: 20,
|
||||
});
|
||||
|
||||
const appBarStyling = useMemo(
|
||||
() => ({ backgroundColor: "transparent", paddingRight: "0 !important" }),
|
||||
[],
|
||||
);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const handleNavigateToHome = useCallback(() => navigate({ to: "/home" }), []);
|
||||
const handleNavigateToFavorite = useCallback(() => {
|
||||
navigate({ to: "/favorite" });
|
||||
}, []);
|
||||
|
||||
const [showDrawer, setShowDrawer] = useState(false);
|
||||
|
||||
}: SearchToolbarProps) {
|
||||
return (
|
||||
<>
|
||||
<AppBar
|
||||
className={
|
||||
scrollTrigger
|
||||
? "appBar search-header scrolling flex flex-row"
|
||||
: "appBar search-header flex flex-row"
|
||||
}
|
||||
style={appBarStyling}
|
||||
elevation={0}
|
||||
color="transparent"
|
||||
>
|
||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||
<IconButton
|
||||
onClick={() => setShowDrawer(true)}
|
||||
aria-label="Открыть меню"
|
||||
title="Открыть меню"
|
||||
>
|
||||
<div className="material-symbols-rounded">menu</div>
|
||||
</IconButton>
|
||||
<BackButton />
|
||||
<IconButton
|
||||
onClick={handleNavigateToHome}
|
||||
aria-label="Главная"
|
||||
title="Главная"
|
||||
>
|
||||
<div
|
||||
className={
|
||||
location.pathname === "/home"
|
||||
? "material-symbols-rounded fill"
|
||||
: "material-symbols-rounded"
|
||||
}
|
||||
>
|
||||
home
|
||||
</div>
|
||||
</IconButton>
|
||||
</div>
|
||||
<div
|
||||
className="flex flex-row library-header-center"
|
||||
style={{ gap: "0.6em" }}
|
||||
>
|
||||
<div className="search-toolbar">
|
||||
<Box className="search-input-container">
|
||||
<span className="material-symbols-rounded search-icon">search</span>
|
||||
<InputBase
|
||||
@@ -314,8 +255,7 @@ function SearchAppBar({
|
||||
>
|
||||
{selected.map((value) => {
|
||||
const label =
|
||||
CATEGORIES.find((c) => c.value === value)?.label ||
|
||||
value;
|
||||
CATEGORIES.find((c) => c.value === value)?.label || value;
|
||||
return (
|
||||
<Chip
|
||||
key={value}
|
||||
@@ -348,23 +288,6 @@ function SearchAppBar({
|
||||
</FormControl>
|
||||
</Box>
|
||||
</div>
|
||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||
<IconButton
|
||||
onClick={handleNavigateToFavorite}
|
||||
aria-label="Избранное"
|
||||
title="Избранное"
|
||||
>
|
||||
<div className="material-symbols-rounded">favorite</div>
|
||||
</IconButton>
|
||||
<UserAvatarMenu />
|
||||
<WindowControls />
|
||||
</div>
|
||||
</AppBar>
|
||||
<NavigationDrawer
|
||||
open={showDrawer}
|
||||
onClose={() => setShowDrawer(false)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
|
||||
.search-page {
|
||||
position: relative;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
// Glossy subtle background animation - fixed to viewport so it stays while scrolling
|
||||
/* Glossy background that stays put while the results scroll. */
|
||||
&-bg {
|
||||
position: fixed;
|
||||
top: -50%;
|
||||
left: -50%;
|
||||
right: -50%;
|
||||
bottom: -50%;
|
||||
background: radial-gradient(circle at center, rgba(var(--mui-palette-primary-mainChannel), 0.15) 0%, transparent 60%);
|
||||
background: radial-gradient(
|
||||
circle at center,
|
||||
rgba(var(--mui-palette-primary-mainChannel), 0.15) 0%,
|
||||
transparent 60%
|
||||
);
|
||||
opacity: 0;
|
||||
transition: opacity 0.8s ease;
|
||||
pointer-events: none;
|
||||
@@ -23,62 +26,38 @@
|
||||
}
|
||||
}
|
||||
|
||||
// New Sticky AppBar styles mirroring LibraryHeader exactly
|
||||
.search-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
inset: 1em 1em auto 1em !important;
|
||||
border-radius: 9999px;
|
||||
margin: 0 auto;
|
||||
position: fixed;
|
||||
width: calc(100vw - 4em) !important;
|
||||
z-index: 100;
|
||||
padding: 0.25em !important;
|
||||
transition: all 0.2s ease-in-out;
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0 -0.35em;
|
||||
pointer-events: none;
|
||||
border-radius: inherit;
|
||||
@include glass-effect;
|
||||
opacity: 0;
|
||||
z-index: -1;
|
||||
transition: all $transition-time-fast;
|
||||
}
|
||||
|
||||
&.scrolling {
|
||||
&::after {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-content {
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
align-self: center;
|
||||
z-index: 1;
|
||||
padding-top: 4.4em;
|
||||
}
|
||||
}
|
||||
|
||||
/* Search lives inside the page now; the app titlebar owns navigation. */
|
||||
.search-toolbar {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
padding: 0 0 1.25rem;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
// Input Container adapted for the pill header
|
||||
.search-input-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-radius: 9999px; // Match pill
|
||||
border-radius: 9999px;
|
||||
padding: 2px 4px 2px 16px;
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
height: 48px; // Match library header elements roughly
|
||||
height: 48px;
|
||||
|
||||
&:hover, &:focus-within {
|
||||
&:hover,
|
||||
&:focus-within {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-color: rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
@@ -88,7 +67,7 @@
|
||||
max-width: 40%;
|
||||
|
||||
.MuiSelect-select {
|
||||
padding-right: 24px !important; // Make room for clear icon inside select if needed, though we put it in EndAdornment
|
||||
padding-right: 24px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,9 +105,10 @@
|
||||
font-size: 0.85rem;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
fieldset { border: none; }
|
||||
fieldset {
|
||||
border: none;
|
||||
}
|
||||
|
||||
// Keep the clear button clear of the absolutely positioned dropdown arrow
|
||||
&.MuiInputBase-adornedEnd {
|
||||
padding-right: 32px;
|
||||
}
|
||||
@@ -139,12 +119,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
&-empty-state {
|
||||
.search-empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 60vh; // Take up vertical space to look nice
|
||||
height: 60vh;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
|
||||
@@ -161,7 +141,9 @@
|
||||
font-size: 5rem;
|
||||
z-index: 2;
|
||||
color: var(--mui-palette-primary-main);
|
||||
filter: drop-shadow(0 0 20px rgba(var(--mui-palette-primary-mainChannel), 0.4));
|
||||
filter: drop-shadow(
|
||||
0 0 20px rgba(var(--mui-palette-primary-mainChannel), 0.4)
|
||||
);
|
||||
}
|
||||
.icon-md {
|
||||
font-size: 3.5rem;
|
||||
@@ -182,7 +164,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
&-no-results {
|
||||
.search-no-results {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
@@ -190,30 +172,10 @@
|
||||
padding: 4em;
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.search-page .search-header {
|
||||
inset: calc(0.5em + var(--safe-top)) 0.5em auto 0.5em !important;
|
||||
width: auto !important;
|
||||
flex-wrap: wrap;
|
||||
border-radius: 22px;
|
||||
padding: 0.3em 0.5em !important;
|
||||
row-gap: 0.25em;
|
||||
|
||||
html.is-macos & {
|
||||
left: 76px !important;
|
||||
right: 0.5em !important;
|
||||
width: auto !important;
|
||||
/* The window traffic lights are already cleared by the offset. */
|
||||
padding-left: 0.5em !important;
|
||||
}
|
||||
|
||||
.library-header-center {
|
||||
order: 3;
|
||||
width: 100%;
|
||||
.search-toolbar {
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
|
||||
.search-input-container {
|
||||
@@ -223,26 +185,4 @@
|
||||
.search-category-select {
|
||||
display: none;
|
||||
}
|
||||
|
||||
> .flex.flex-row:last-child [aria-label="Избранное"] {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.search-page-content {
|
||||
padding: calc(8.4em + var(--safe-top)) 1rem calc(8rem + var(--safe-bottom));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media (min-width: 701px) and (max-width: 900px) {
|
||||
.search-page .search-header {
|
||||
.search-category-select {
|
||||
display: block;
|
||||
}
|
||||
|
||||
> .flex.flex-row:last-child [aria-label="Избранное"] {
|
||||
display: inline-flex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,53 @@
|
||||
@use "../../styles/variables.scss" as *;
|
||||
|
||||
.settings-device-name {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.8rem;
|
||||
margin-bottom: 1.4rem;
|
||||
padding: 1rem;
|
||||
border-radius: 18px;
|
||||
background:
|
||||
linear-gradient(135deg, rgb(255 255 255 / 0.08), rgb(255 255 255 / 0.02)),
|
||||
rgb(17 15 32 / 0.42);
|
||||
border: 1px solid rgb(255 255 255 / 0.09);
|
||||
box-shadow:
|
||||
0 14px 34px rgb(0 0 0 / 0.2),
|
||||
inset 0 1px 0 rgb(255 255 255 / 0.06);
|
||||
backdrop-filter: blur(20px) saturate(150%);
|
||||
|
||||
&-hint {
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
&-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.7rem;
|
||||
|
||||
.MuiTextField-root {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.MuiButton-root {
|
||||
flex: 0 0 auto;
|
||||
height: 40px;
|
||||
border-radius: 999px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.settings {
|
||||
&-page {
|
||||
&-container {
|
||||
display: grid;
|
||||
grid-template-columns: 16em 1fr;
|
||||
padding: 0;
|
||||
padding: var(--app-titlebar-height) 0 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
|
||||
// Frameless window on Windows/Linux: the floating window buttons
|
||||
// sit in the top 44px, so the settings grid starts below that strip.
|
||||
html.is-windows &,
|
||||
html.is-linux & {
|
||||
padding-top: 44px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
&-scrollY {
|
||||
padding: 2em;
|
||||
overflow-x: hidden;
|
||||
@@ -89,27 +120,6 @@
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
html.is-macos & {
|
||||
// Overlay titlebar: leave room for the traffic lights.
|
||||
padding-top: 2.9em;
|
||||
}
|
||||
|
||||
&-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-bottom: 0.5em; // Reduced
|
||||
|
||||
// Adjust back button for this context
|
||||
.MuiIconButton-root {
|
||||
color: rgba(255,255,255,0.7);
|
||||
&:hover {
|
||||
color: white;
|
||||
background: rgba(255,255,255,0.05);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -198,10 +208,21 @@
|
||||
}
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
.settings-device-name-row {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
.MuiButton-root {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-page-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
padding-top: var(--app-titlebar-height);
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -211,28 +232,18 @@
|
||||
align-items: center;
|
||||
gap: 0.25em;
|
||||
width: 100%;
|
||||
padding: calc(0.4rem + var(--safe-top)) 0.6rem 0.4rem;
|
||||
padding: 0.4rem 0.6rem;
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid rgb(255 255 255 / 0.06);
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
box-sizing: border-box;
|
||||
|
||||
html.is-macos & {
|
||||
padding-top: calc(0.4rem + var(--safe-top));
|
||||
padding-left: 76px;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-sidebar-header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.settings-sidebar-controls {
|
||||
padding-bottom: 0;
|
||||
gap: 0.15em;
|
||||
}
|
||||
|
||||
.settings-sidebar-list {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
@@ -317,15 +328,6 @@
|
||||
padding-right: 2em !important;
|
||||
}
|
||||
|
||||
.settings-sidebar-controls {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
|
||||
[aria-label="Главная"] {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-page-scrollY {
|
||||
padding: 0.75rem 1rem calc(7.5rem + var(--safe-bottom)) !important;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
import {
|
||||
createFileRoute,
|
||||
Outlet,
|
||||
useLocation,
|
||||
useNavigate,
|
||||
} from "@tanstack/react-router";
|
||||
import React, { useCallback, useEffect } from "react";
|
||||
import { createFileRoute, Outlet, useLocation } from "@tanstack/react-router";
|
||||
import React, { useEffect } from "react";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import "./settings.scss";
|
||||
import { IconButton, List, Typography } from "@mui/material";
|
||||
import { List, Typography } from "@mui/material";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import BackButton from "@/components/buttons/backButton";
|
||||
import ListItemLink from "@/components/listItemLink";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
@@ -26,11 +20,7 @@ function SettingsRoute() {
|
||||
useEffect(() => {
|
||||
setBackdrop("");
|
||||
});
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const handleNavigateHome = useCallback(() => {
|
||||
navigate({ to: "/home" });
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const active = document.querySelector(
|
||||
@@ -39,23 +29,8 @@ function SettingsRoute() {
|
||||
active?.scrollIntoView({ block: "nearest", inline: "center" });
|
||||
}, [location.pathname]);
|
||||
return (
|
||||
<div className="settings-page-container" data-tauri-drag-region>
|
||||
<div className="settings-page-container">
|
||||
<div className="settings-sidebar">
|
||||
<div className="settings-sidebar-controls">
|
||||
<BackButton />
|
||||
<IconButton
|
||||
onClick={handleNavigateHome}
|
||||
aria-label="Главная"
|
||||
title="Главная"
|
||||
sx={{
|
||||
background: "rgba(255, 255, 255, 0.05)",
|
||||
"&:hover": { background: "rgba(255, 255, 255, 0.1)" },
|
||||
}}
|
||||
>
|
||||
<span className="material-symbols-rounded">home</span>
|
||||
</IconButton>
|
||||
</div>
|
||||
|
||||
<div className="settings-sidebar-header">
|
||||
<img
|
||||
className="settings-sidebar-header-image"
|
||||
|
||||
@@ -8,6 +8,12 @@ import {
|
||||
} from "@mui/material";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import React from "react";
|
||||
import {
|
||||
getDefaultDeviceName,
|
||||
getDeviceDisplayName,
|
||||
getOrCreateDeviceId,
|
||||
setDeviceDisplayName,
|
||||
} from "@/utils/deviceIdentity";
|
||||
|
||||
import "../settings.scss";
|
||||
import { getLocalizationApi } from "@jellyfin/sdk/lib/utils/api/localization-api";
|
||||
@@ -38,6 +44,19 @@ function RouteComponent() {
|
||||
});
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const deviceId = getOrCreateDeviceId();
|
||||
const defaultDeviceName = getDefaultDeviceName(deviceId);
|
||||
const [deviceName, setDeviceName] = React.useState(() =>
|
||||
getDeviceDisplayName(deviceId),
|
||||
);
|
||||
const saveDeviceName = () => {
|
||||
const next = setDeviceDisplayName(deviceName);
|
||||
setDeviceName(next);
|
||||
enqueueSnackbar(
|
||||
"Имя устройства сохранено. Перезапустите Blink, чтобы оно обновилось на сервере.",
|
||||
{ variant: "success" },
|
||||
);
|
||||
};
|
||||
|
||||
const form = useForm({
|
||||
defaultValues: {
|
||||
@@ -81,6 +100,27 @@ function RouteComponent() {
|
||||
return (
|
||||
<div className="settings-page-scrollY">
|
||||
<Typography variant="h4">Настройки</Typography>
|
||||
<div className="settings-device-name">
|
||||
<div>
|
||||
<Typography variant="h6">Это устройство</Typography>
|
||||
<Typography variant="body2" className="settings-device-name-hint">
|
||||
Имя видно другим клиентам Blink в пульте и SyncPlay.
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="settings-device-name-row">
|
||||
<TextField
|
||||
size="small"
|
||||
fullWidth
|
||||
label="Имя устройства"
|
||||
value={deviceName}
|
||||
onChange={(event) => setDeviceName(event.target.value)}
|
||||
helperText={`По умолчанию: ${defaultDeviceName}`}
|
||||
/>
|
||||
<Button variant="outlined" onClick={saveDeviceName}>
|
||||
Сохранить имя
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{/* <form.Pro */}
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
@@ -89,7 +129,9 @@ function RouteComponent() {
|
||||
form.handleSubmit();
|
||||
}}
|
||||
onError={() =>
|
||||
enqueueSnackbar("Не удалось сохранить настройки", { variant: "error" })
|
||||
enqueueSnackbar("Не удалось сохранить настройки", {
|
||||
variant: "error",
|
||||
})
|
||||
}
|
||||
className="settings-form"
|
||||
>
|
||||
@@ -171,14 +213,15 @@ function RouteComponent() {
|
||||
fontWeight: 400,
|
||||
}}
|
||||
>
|
||||
Воспроизводить аудиодорожку по умолчанию независимо от языка
|
||||
Воспроизводить аудиодорожку по умолчанию независимо от
|
||||
языка
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
className="settings-option-info-caption"
|
||||
>
|
||||
Воспроизводить аудиодорожку по умолчанию, даже если она
|
||||
не совпадает с предпочитаемым языком.
|
||||
Воспроизводить аудиодорожку по умолчанию, даже если она не
|
||||
совпадает с предпочитаемым языком.
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
|
||||
+12
-20
@@ -177,28 +177,26 @@ body {
|
||||
the content changes underneath them. */
|
||||
@supports (view-transition-name: none) {
|
||||
::view-transition-group(root) {
|
||||
animation-duration: 300ms;
|
||||
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
|
||||
animation-duration: 320ms;
|
||||
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
::view-transition-old(root),
|
||||
::view-transition-new(root) {
|
||||
animation-fill-mode: both;
|
||||
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
|
||||
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
mix-blend-mode: normal;
|
||||
transform-origin: 50% 42%;
|
||||
will-change: opacity, transform, filter;
|
||||
will-change: opacity;
|
||||
}
|
||||
|
||||
::view-transition-old(root) {
|
||||
animation-name: routeExit;
|
||||
animation-duration: 180ms;
|
||||
animation-timing-function: cubic-bezier(0.4, 0, 1, 1);
|
||||
animation-duration: 220ms;
|
||||
}
|
||||
|
||||
::view-transition-new(root) {
|
||||
animation-name: routeEnter;
|
||||
animation-duration: 300ms;
|
||||
animation-duration: 320ms;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,26 +211,18 @@ body {
|
||||
@keyframes routeExit {
|
||||
from {
|
||||
opacity: 1;
|
||||
transform: translateY(0) scale(1);
|
||||
filter: blur(0);
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
transform: translateY(-5px) scale(0.995);
|
||||
filter: blur(2px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes routeEnter {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(14px) scale(1.003);
|
||||
filter: blur(6px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0) scale(1);
|
||||
filter: blur(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,9 +298,9 @@ h1 {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
min-height: 100vh;
|
||||
padding: ($page-margin - 1.2em) $page-margin;
|
||||
padding: calc(var(--app-titlebar-height) + 1.5rem) $page-margin 1.5rem;
|
||||
&.padded-top {
|
||||
padding-top: 4.4em;
|
||||
padding-top: calc(var(--app-titlebar-height) + 1.5rem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,11 +492,13 @@ a {
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.scrollY {
|
||||
padding: 0.75rem 1rem calc(0.75rem + var(--safe-bottom));
|
||||
padding: calc(var(--app-titlebar-height) + 0.75rem) 1rem calc(
|
||||
0.75rem + var(--safe-bottom)
|
||||
);
|
||||
}
|
||||
|
||||
.scrollY.padded-top {
|
||||
padding-top: calc(4.8rem + var(--safe-top));
|
||||
padding-top: calc(var(--app-titlebar-height) + 0.75rem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
const DEVICE_ID_KEY = "deviceId";
|
||||
const DEVICE_NAME_KEY = "blinkDeviceName";
|
||||
|
||||
const readLocalStorage = (key: string) => {
|
||||
try {
|
||||
return localStorage.getItem(key);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const writeLocalStorage = (key: string, value: string) => {
|
||||
try {
|
||||
localStorage.setItem(key, value);
|
||||
} catch {
|
||||
// Private browsing/WebView storage may be unavailable; the id remains
|
||||
// stable for this runtime through the in-memory fallback below.
|
||||
}
|
||||
};
|
||||
|
||||
let memoryDeviceId: string | undefined;
|
||||
|
||||
export const getOrCreateDeviceId = (): string => {
|
||||
if (memoryDeviceId) return memoryDeviceId;
|
||||
const stored = readLocalStorage(DEVICE_ID_KEY)?.trim();
|
||||
if (stored) {
|
||||
memoryDeviceId = stored;
|
||||
return stored;
|
||||
}
|
||||
const id =
|
||||
typeof crypto !== "undefined" && "randomUUID" in crypto
|
||||
? crypto.randomUUID()
|
||||
: `blink-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
||||
writeLocalStorage(DEVICE_ID_KEY, id);
|
||||
memoryDeviceId = id;
|
||||
return id;
|
||||
};
|
||||
|
||||
/** Human-readable platform, including the Android model when the UA has it. */
|
||||
export const getPlatformLabel = (): string => {
|
||||
const ua = navigator.userAgent;
|
||||
if (/Android/i.test(ua)) {
|
||||
const model = ua
|
||||
.match(/Android[^;]*;\s*([^;)]+?)(?:\s+Build\/|\))/i)?.[1]
|
||||
?.trim();
|
||||
if (model && !/^(wv|K|Mobile)$/i.test(model)) {
|
||||
return `Android · ${model}`;
|
||||
}
|
||||
return "Android";
|
||||
}
|
||||
if (/iPhone|iPad|iPod/i.test(ua)) return "iOS";
|
||||
if (/Macintosh/i.test(ua)) return "macOS";
|
||||
if (/Windows/i.test(ua)) return "Windows";
|
||||
if (/Linux/i.test(ua)) return "Linux";
|
||||
return "Web";
|
||||
};
|
||||
|
||||
export const getDefaultDeviceName = (deviceId: string): string =>
|
||||
`Blink · ${getPlatformLabel()} · ${deviceId.slice(-4).toUpperCase()}`;
|
||||
|
||||
export const getStoredDeviceName = (): string =>
|
||||
readLocalStorage(DEVICE_NAME_KEY)?.trim() ?? "";
|
||||
|
||||
/** Stable readable name used in Jellyfin sessions and remote device lists. */
|
||||
export const getDeviceDisplayName = (deviceId: string): string =>
|
||||
getStoredDeviceName() || getDefaultDeviceName(deviceId);
|
||||
|
||||
export const setDeviceDisplayName = (name: string): string => {
|
||||
const deviceId = getOrCreateDeviceId();
|
||||
const value = name.trim() || getDefaultDeviceName(deviceId);
|
||||
writeLocalStorage(DEVICE_NAME_KEY, value);
|
||||
return value;
|
||||
};
|
||||
@@ -0,0 +1,86 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import {
|
||||
type BaseItemDto,
|
||||
PlayMethod,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||
|
||||
/**
|
||||
* Audio playback used to be invisible to Jellyfin: the `<audio>` element played
|
||||
* locally but no PlaybackStart/Progress/Stopped was reported. That made audio
|
||||
* impossible to cast, take over, follow or synchronise, because other clients
|
||||
* only see a session through `NowPlayingItem` and `PlayState`.
|
||||
*/
|
||||
const mediaSourceId = (item: BaseItemDto) =>
|
||||
item.MediaSources?.[0]?.Id ?? undefined;
|
||||
|
||||
export const beginAudioPlaybackReport = (
|
||||
api: Api,
|
||||
item: BaseItemDto,
|
||||
positionTicks: number,
|
||||
): string | null => {
|
||||
if (!item.Id) return null;
|
||||
const playSessionId = `${item.Id}-${Date.now()}-${Math.random()
|
||||
.toString(36)
|
||||
.slice(2, 8)}`;
|
||||
getSessionApi(api)
|
||||
.reportPlaybackStart({
|
||||
playbackStartInfo: {
|
||||
CanSeek: true,
|
||||
IsPaused: false,
|
||||
IsMuted: false,
|
||||
ItemId: item.Id,
|
||||
MediaSourceId: mediaSourceId(item),
|
||||
PlayMethod: PlayMethod.DirectStream,
|
||||
PlaySessionId: playSessionId,
|
||||
PositionTicks: Math.max(0, Math.round(positionTicks)),
|
||||
PlaybackStartTimeTicks: Math.max(0, Math.round(positionTicks)),
|
||||
},
|
||||
})
|
||||
.catch((error) => console.warn("Could not report audio start", error));
|
||||
return playSessionId;
|
||||
};
|
||||
|
||||
export const reportAudioProgress = (
|
||||
api: Api,
|
||||
item: BaseItemDto,
|
||||
playSessionId: string,
|
||||
positionTicks: number,
|
||||
isPaused: boolean,
|
||||
) => {
|
||||
if (!item.Id) return;
|
||||
getSessionApi(api)
|
||||
.reportPlaybackProgress({
|
||||
playbackProgressInfo: {
|
||||
CanSeek: true,
|
||||
IsPaused: isPaused,
|
||||
IsMuted: false,
|
||||
ItemId: item.Id,
|
||||
MediaSourceId: mediaSourceId(item),
|
||||
PlayMethod: PlayMethod.DirectStream,
|
||||
PlaySessionId: playSessionId,
|
||||
PositionTicks: Math.max(0, Math.round(positionTicks)),
|
||||
},
|
||||
})
|
||||
.catch((error) => console.warn("Could not report audio progress", error));
|
||||
};
|
||||
|
||||
export const endAudioPlaybackReport = (
|
||||
api: Api,
|
||||
item: BaseItemDto,
|
||||
playSessionId: string,
|
||||
positionTicks: number,
|
||||
) => {
|
||||
if (!item.Id) return;
|
||||
getSessionApi(api)
|
||||
.reportPlaybackStopped({
|
||||
playbackStopInfo: {
|
||||
Failed: false,
|
||||
ItemId: item.Id,
|
||||
MediaSourceId: mediaSourceId(item),
|
||||
PlaySessionId: playSessionId,
|
||||
PositionTicks: Math.max(0, Math.round(positionTicks)),
|
||||
},
|
||||
})
|
||||
.catch((error) => console.warn("Could not report audio stop", error));
|
||||
};
|
||||
@@ -0,0 +1,151 @@
|
||||
import type {
|
||||
GroupInfoDto,
|
||||
SessionInfoDto,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMemo } from "react";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import useRealtimeStore from "@/utils/store/realtime";
|
||||
|
||||
export const BLINK_CLIENT_NAME = "Blink";
|
||||
export const BLINK_GROUP_PREFIX = "Blink ·";
|
||||
export const BLINK_AUTO_GROUP_NAME = `${BLINK_GROUP_PREFIX} Автогруппа`;
|
||||
|
||||
export const isBlinkSession = (session: SessionInfoDto): boolean =>
|
||||
session.Client?.trim().toLowerCase() === BLINK_CLIENT_NAME.toLowerCase();
|
||||
|
||||
export const isBlinkGroup = (group: GroupInfoDto): boolean =>
|
||||
Boolean(group.GroupName?.trim().startsWith(BLINK_GROUP_PREFIX));
|
||||
|
||||
export const isBlinkAutoGroup = (group: GroupInfoDto): boolean =>
|
||||
group.GroupName?.trim() === BLINK_AUTO_GROUP_NAME;
|
||||
|
||||
export const getBlinkGroupLabel = (group: GroupInfoDto): string =>
|
||||
group.GroupName?.replace(BLINK_GROUP_PREFIX, "").trim() || "Смотреть вместе";
|
||||
|
||||
const shortId = (id?: string | null): string =>
|
||||
id
|
||||
? id
|
||||
.replace(/[^a-z0-9]/gi, "")
|
||||
.slice(-4)
|
||||
.toUpperCase()
|
||||
: "????";
|
||||
|
||||
/**
|
||||
* Some old Blink builds reported the generic name "Blink". Keep those
|
||||
* distinguishable by appending the short device id, and always prefer the
|
||||
* human name captured in Settings → Preferences.
|
||||
*/
|
||||
export const getBlinkDeviceName = (session: SessionInfoDto): string => {
|
||||
const name = session.DeviceName?.trim();
|
||||
if (name && name.toLowerCase() !== BLINK_CLIENT_NAME.toLowerCase()) {
|
||||
return name;
|
||||
}
|
||||
const client = session.Client?.trim() || BLINK_CLIENT_NAME;
|
||||
const type = session.DeviceType?.trim();
|
||||
return `${client}${type ? ` · ${type}` : ""} · ${shortId(session.DeviceId)}`;
|
||||
};
|
||||
|
||||
export type BlinkDeviceKind =
|
||||
| "tv"
|
||||
| "phone"
|
||||
| "tablet"
|
||||
| "desktop"
|
||||
| "speaker"
|
||||
| "cast";
|
||||
|
||||
export const getBlinkDeviceKind = (
|
||||
session: SessionInfoDto,
|
||||
): BlinkDeviceKind => {
|
||||
const type =
|
||||
`${session.DeviceType ?? ""} ${session.Client ?? ""}`.toLowerCase();
|
||||
if (type.includes("phone") || type.includes("mobile")) return "phone";
|
||||
if (type.includes("tablet")) return "tablet";
|
||||
if (type.includes("speaker") || type.includes("audio")) return "speaker";
|
||||
if (type.includes("cast")) return "cast";
|
||||
if (type.includes("tv")) return "tv";
|
||||
if (type.includes("desktop") || type.includes("computer")) return "desktop";
|
||||
return session.NowPlayingItem?.Type === "Audio" ? "speaker" : "desktop";
|
||||
};
|
||||
|
||||
export const getBlinkDeviceIcon = (session: SessionInfoDto): string => {
|
||||
switch (getBlinkDeviceKind(session)) {
|
||||
case "phone":
|
||||
return "smartphone";
|
||||
case "tablet":
|
||||
return "tablet";
|
||||
case "speaker":
|
||||
return "speaker";
|
||||
case "cast":
|
||||
return "cast";
|
||||
case "tv":
|
||||
return "tv";
|
||||
default:
|
||||
return "computer";
|
||||
}
|
||||
};
|
||||
|
||||
/** Blink sessions of the current user, excluding the client that asks. */
|
||||
export const getBlinkSessions = (
|
||||
sessions: SessionInfoDto[],
|
||||
userId: string | undefined,
|
||||
selfDeviceId: string | undefined,
|
||||
): SessionInfoDto[] =>
|
||||
sessions.filter(
|
||||
(session) =>
|
||||
Boolean(session.Id) &&
|
||||
session.IsActive !== false &&
|
||||
session.UserId === userId &&
|
||||
session.DeviceId !== selfDeviceId &&
|
||||
isBlinkSession(session),
|
||||
);
|
||||
|
||||
/** Realtime snapshot, with a polling fallback when the socket is not ready. */
|
||||
export const useBlinkSessions = (enabled = true) => {
|
||||
const api = useApiInContext((state) => state.api);
|
||||
const user = useCentralStore((state) => state.currentUser);
|
||||
const realtimeSessions = useRealtimeStore((state) => state.sessions);
|
||||
const connected = useRealtimeStore((state) => state.connected);
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ["remoteSessions"],
|
||||
queryFn: async () => {
|
||||
if (!api || !user?.Id) return [];
|
||||
return (await getSessionApi(api).getSessions()).data;
|
||||
},
|
||||
enabled: enabled && Boolean(api && user?.Id),
|
||||
refetchInterval: enabled && !connected ? 4000 : false,
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const source =
|
||||
realtimeSessions.length > 0 ? realtimeSessions : (query.data ?? []);
|
||||
const sessions = useMemo(
|
||||
() => getBlinkSessions(source, user?.Id, api?.deviceInfo.id),
|
||||
[source, user?.Id, api?.deviceInfo.id],
|
||||
);
|
||||
|
||||
return {
|
||||
sessions,
|
||||
allSessions: source,
|
||||
connected,
|
||||
isLoading: query.isPending && realtimeSessions.length === 0,
|
||||
refetch: query.refetch,
|
||||
};
|
||||
};
|
||||
|
||||
/** Non-reactive helper for command handlers that only need a current count. */
|
||||
export const getOnlineBlinkSessionCount = (
|
||||
selfDeviceId: string | undefined,
|
||||
userId?: string,
|
||||
): number | undefined => {
|
||||
const snapshot = useRealtimeStore.getState().sessions;
|
||||
if (snapshot.length === 0) return undefined;
|
||||
const effectiveUserId =
|
||||
userId ??
|
||||
snapshot.find((session) => session.DeviceId === selfDeviceId)?.UserId;
|
||||
if (!effectiveUserId) return undefined;
|
||||
return getBlinkSessions(snapshot, effectiveUserId, selfDeviceId).length;
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
import { secToTicks, ticksToSec } from "@/utils/date/time";
|
||||
import {
|
||||
setAudioPlaying,
|
||||
setVolume as setAudioVolume,
|
||||
setIsMuted,
|
||||
stopPlayback,
|
||||
@@ -12,6 +13,8 @@ export type LocalPlaybackSnapshot = {
|
||||
itemId: string | null;
|
||||
positionTicks: number;
|
||||
paused: boolean;
|
||||
/** True once media is actually loaded enough to start in sync. */
|
||||
ready: boolean;
|
||||
};
|
||||
|
||||
const getVideoElement = () =>
|
||||
@@ -23,11 +26,23 @@ const getVideoElement = () =>
|
||||
export const getLocalPlayback = (): LocalPlaybackSnapshot => {
|
||||
const video = usePlaybackStore.getState();
|
||||
if (video.playbackStream && video.metadata.item?.Id) {
|
||||
const videoElement = getVideoElement();
|
||||
return {
|
||||
kind: "video",
|
||||
itemId: video.metadata.item.Id,
|
||||
positionTicks: video.playerState.currentTime ?? 0,
|
||||
// Read the element directly: the store's currentTime is only updated
|
||||
// by timeupdate, which can stay stale while the player is paused.
|
||||
positionTicks: videoElement
|
||||
? secToTicks(videoElement.currentTime)
|
||||
: (video.playerState.currentTime ?? 0),
|
||||
paused: !video.playerState.isPlayerPlaying,
|
||||
// A paused player may stop at HAVE_METADATA until playback is
|
||||
// requested, so require only that the media is loaded. Waiting for
|
||||
// HAVE_CURRENT_DATA (or for onReady) here deadlocks the group on
|
||||
// clients that park before their first frame arrives.
|
||||
ready: videoElement
|
||||
? videoElement.readyState >= 1
|
||||
: Boolean(video.playerState.isPlayerReady),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,10 +56,17 @@ export const getLocalPlayback = (): LocalPlaybackSnapshot => {
|
||||
? secToTicks(element.currentTime)
|
||||
: audio.player.currentTick,
|
||||
paused: element ? element.paused : !audio.player.playing,
|
||||
ready: Boolean(element && element.readyState >= 1),
|
||||
};
|
||||
}
|
||||
|
||||
return { kind: "none", itemId: null, positionTicks: 0, paused: false };
|
||||
return {
|
||||
kind: "none",
|
||||
itemId: null,
|
||||
positionTicks: 0,
|
||||
paused: false,
|
||||
ready: false,
|
||||
};
|
||||
};
|
||||
|
||||
export const pauseLocalPlayback = () => {
|
||||
@@ -54,6 +76,9 @@ export const pauseLocalPlayback = () => {
|
||||
video.setIsPlaying(false);
|
||||
}
|
||||
useAudioPlayback.getState().player.ref?.current?.pause();
|
||||
// Keep the store in sync even when the audio element has not mounted yet:
|
||||
// the player uses this flag to decide whether to autoplay on mount.
|
||||
setAudioPlaying(false);
|
||||
};
|
||||
|
||||
export const resumeLocalPlayback = () => {
|
||||
@@ -68,6 +93,7 @@ export const resumeLocalPlayback = () => {
|
||||
}
|
||||
const audio = useAudioPlayback.getState();
|
||||
if (audio.display && audio.item?.Id) {
|
||||
setAudioPlaying(true);
|
||||
audio.player.ref?.current?.play().catch(() => undefined);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getLocalPlayback } from "@/utils/methods/localPlayback";
|
||||
import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
import useQueue from "@/utils/store/queue";
|
||||
import type { RemoteTransfer } from "@/utils/store/remoteControl";
|
||||
|
||||
/** Current local media as a ready-to-send transfer, or null when idle. */
|
||||
export const getLocalMediaTransfer = (): RemoteTransfer | null => {
|
||||
const queueState = useQueue.getState();
|
||||
const local = getLocalPlayback();
|
||||
if (!local.itemId || local.kind === "none") return null;
|
||||
|
||||
const video = usePlaybackStore.getState();
|
||||
const audio = useAudioPlayback.getState();
|
||||
const item = local.kind === "video" ? video.metadata.item : audio.item;
|
||||
if (!item?.Id) return null;
|
||||
|
||||
const queue =
|
||||
queueState.tracks && queueState.tracks.length > 0
|
||||
? queueState.tracks
|
||||
: [item];
|
||||
return {
|
||||
item,
|
||||
kind: local.kind,
|
||||
positionTicks: local.positionTicks,
|
||||
queue,
|
||||
startIndex: Math.max(0, queueState.currentItemIndex),
|
||||
};
|
||||
};
|
||||
|
||||
/** Reactive item for the titlebar cast button/tooltip. */
|
||||
export const useCurrentMediaItem = (): BaseItemDto | null => {
|
||||
const videoItem = usePlaybackStore((state) =>
|
||||
state.playbackStream && state.metadata.item?.Id
|
||||
? state.metadata.item
|
||||
: null,
|
||||
);
|
||||
const audioItem = useAudioPlayback((state) =>
|
||||
state.display && state.item?.Id ? state.item : null,
|
||||
);
|
||||
return videoItem ?? audioItem ?? null;
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Starting one medium stops the other (audio <-> video). The old player's
|
||||
* pause/seek events must not be reported to a SyncPlay group as user requests:
|
||||
* that is what paused a whole group when someone started music, and what made
|
||||
* the group wait for a client that had deliberately switched media.
|
||||
*/
|
||||
let switchingUntil = 0;
|
||||
|
||||
export const markLocalMediaSwitch = (ms = 2500) => {
|
||||
switchingUntil = Date.now() + ms;
|
||||
};
|
||||
|
||||
export const isLocalMediaSwitching = () => Date.now() < switchingUntil;
|
||||
+400
-46
@@ -6,12 +6,20 @@ import {
|
||||
SendCommandType,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getSyncPlayApi } from "@jellyfin/sdk/lib/utils/api/sync-play-api";
|
||||
import {
|
||||
BLINK_AUTO_GROUP_NAME,
|
||||
BLINK_GROUP_PREFIX,
|
||||
getOnlineBlinkSessionCount,
|
||||
isBlinkAutoGroup,
|
||||
isBlinkGroup,
|
||||
} from "@/utils/methods/blinkSessions";
|
||||
import {
|
||||
getLocalPlayback,
|
||||
pauseLocalPlayback,
|
||||
resumeLocalPlayback,
|
||||
seekLocalPlayback,
|
||||
} from "@/utils/methods/localPlayback";
|
||||
import { isLocalMediaSwitching } from "@/utils/methods/mediaSwitch";
|
||||
import { startPlaybackFromIds } from "@/utils/methods/startPlayback";
|
||||
import useQueue from "@/utils/store/queue";
|
||||
import useSyncPlayStore from "@/utils/store/syncPlay";
|
||||
@@ -19,13 +27,35 @@ import useSyncPlayStore from "@/utils/store/syncPlay";
|
||||
const SEEK_REPORT_INTERVAL_MS = 300;
|
||||
const PAUSE_REPORT_INTERVAL_MS = 400;
|
||||
const AUTO_START_GUARD_MS = 5000;
|
||||
const DRIFT_TOLERANCE_TICKS = 2 * 10_000_000;
|
||||
const DRIFT_TOLERANCE_TICKS = 5_000_000;
|
||||
let pingEstimateMs = 50;
|
||||
let pingInFlight = false;
|
||||
|
||||
let applyingRemoteUntil = 0;
|
||||
let lastSeekReport = { at: 0, ticks: 0 };
|
||||
let lastPauseReport = { at: 0, paused: false };
|
||||
let lastAutoStart = { itemId: "", at: 0 };
|
||||
|
||||
/**
|
||||
* Reference point for the group timeline, taken from the server's own
|
||||
* Unpause/Pause/Seek commands. The command's `When` is the server time the
|
||||
* action is scheduled for; before it playback is still parked.
|
||||
*/
|
||||
type SyncAnchor = { ticks: number; at: number; playing: boolean };
|
||||
let playAnchor: SyncAnchor | null = null;
|
||||
let scheduledUnpauseAt = 0;
|
||||
let groupStateChangedAt = 0;
|
||||
let ignoreWaitSent: boolean | null = null;
|
||||
let lastGroupItemLocalAt = 0;
|
||||
|
||||
export const resetSyncPlayTimeline = () => {
|
||||
playAnchor = null;
|
||||
scheduledUnpauseAt = 0;
|
||||
groupStateChangedAt = 0;
|
||||
ignoreWaitSent = null;
|
||||
lastGroupItemLocalAt = 0;
|
||||
};
|
||||
|
||||
const syncApi = (api: Api) => getSyncPlayApi(api);
|
||||
|
||||
const guardRemote = (ms = 1200) => {
|
||||
@@ -46,10 +76,86 @@ const currentQueueItem = (queue: PlayQueueUpdate | null) => {
|
||||
];
|
||||
};
|
||||
|
||||
/** Group position at the current instant, extrapolated from the last update. */
|
||||
export const getExpectedSyncPlayPosition = (): number | null => {
|
||||
if (playAnchor) {
|
||||
return (
|
||||
playAnchor.ticks +
|
||||
(playAnchor.playing
|
||||
? Math.max(0, Date.now() - playAnchor.at) * 10_000
|
||||
: 0)
|
||||
);
|
||||
}
|
||||
const store = useSyncPlayStore.getState();
|
||||
const queue = store.queue;
|
||||
if (!queue) return null;
|
||||
const base = queue.StartPositionTicks ?? 0;
|
||||
if (!queue.IsPlaying || !store.queueReceivedAt) return base;
|
||||
return base + Math.max(0, Date.now() - store.queueReceivedAt) * 10_000;
|
||||
};
|
||||
|
||||
/**
|
||||
* True while the group is holding a freshly set queue: every client should
|
||||
* park at the queue position, paused, and report ready. This is the one case
|
||||
* where the server tolerates only a 500 ms position error, so the client must
|
||||
* not keep playing and re-report drifting positions.
|
||||
*/
|
||||
export const isSyncPlayWaitingForStart = () => {
|
||||
const store = useSyncPlayStore.getState();
|
||||
return (
|
||||
Boolean(store.group) &&
|
||||
store.group?.State === "Waiting" &&
|
||||
!playAnchor?.playing
|
||||
);
|
||||
};
|
||||
|
||||
/** Item the whole group is currently playing, if a queue is set. */
|
||||
export const getCurrentGroupItemId = (): string | undefined =>
|
||||
currentQueueItem(useSyncPlayStore.getState().queue)?.ItemId ?? undefined;
|
||||
|
||||
/**
|
||||
* Group commands and drift correction may only touch the group's own media.
|
||||
* Otherwise starting music on a client that follows a group video seeks the
|
||||
* music to the video's position (the track jumps to its end and loops).
|
||||
*/
|
||||
const localMatchesGroupItem = (local = getLocalPlayback()): boolean => {
|
||||
const groupItemId = getCurrentGroupItemId();
|
||||
return Boolean(
|
||||
groupItemId && local.kind !== "none" && local.itemId === groupItemId,
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Park this client at the group position while the group waits for everyone.
|
||||
* Guards the pause/seek locally so the player events do not echo a Pause or
|
||||
* Seek request back to the server and flip the group state.
|
||||
* Returns true once the client is actually parked.
|
||||
*/
|
||||
export const parkLocalPlaybackForSync = (
|
||||
positionTicks: number | null,
|
||||
): boolean => {
|
||||
guardRemote(1800);
|
||||
const local = getLocalPlayback();
|
||||
if (!local.paused) {
|
||||
pauseLocalPlayback();
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
positionTicks != null &&
|
||||
Math.abs(local.positionTicks - positionTicks) > 4_000_000
|
||||
) {
|
||||
seekLocalPlayback(positionTicks);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
export const refreshSyncPlayGroups = async (api: Api) => {
|
||||
const store = useSyncPlayStore.getState();
|
||||
try {
|
||||
const groups = (await syncApi(api).syncPlayGetGroups()).data ?? [];
|
||||
const groups = ((await syncApi(api).syncPlayGetGroups()).data ?? []).filter(
|
||||
isBlinkGroup,
|
||||
);
|
||||
store.setGroups(groups);
|
||||
} catch (error) {
|
||||
console.warn("Could not load SyncPlay groups", error);
|
||||
@@ -64,6 +170,19 @@ export const refreshSyncPlayGroup = async (api: Api) => {
|
||||
.data;
|
||||
if (fresh) useSyncPlayStore.getState().setGroup(fresh);
|
||||
} catch (error) {
|
||||
const status = (error as { response?: { status?: number } })?.response
|
||||
?.status;
|
||||
if (status === 404) {
|
||||
// The host closed the group while this client was away. Clear the
|
||||
// stale group so the auto-join loop can pick up a new one.
|
||||
const store = useSyncPlayStore.getState();
|
||||
store.reset();
|
||||
store.setOpen(false);
|
||||
lastAutoStart = { itemId: "", at: 0 };
|
||||
applyingRemoteUntil = 0;
|
||||
resetSyncPlayTimeline();
|
||||
return;
|
||||
}
|
||||
console.warn("Could not refresh SyncPlay group", error);
|
||||
}
|
||||
};
|
||||
@@ -81,9 +200,13 @@ export const createSyncPlayGroup = async (api: Api, name: string) => {
|
||||
store.setLoading(true);
|
||||
store.setError(null);
|
||||
try {
|
||||
const visibleName = name.trim() || "Смотреть вместе";
|
||||
const groupName = visibleName.startsWith(BLINK_GROUP_PREFIX)
|
||||
? visibleName
|
||||
: `${BLINK_GROUP_PREFIX} ${visibleName}`;
|
||||
const group = (
|
||||
await syncApi(api).syncPlayCreateGroup({
|
||||
newGroupRequestDto: { GroupName: name.trim() || "Смотреть вместе" },
|
||||
newGroupRequestDto: { GroupName: groupName },
|
||||
})
|
||||
).data;
|
||||
if (group) {
|
||||
@@ -97,7 +220,7 @@ export const createSyncPlayGroup = async (api: Api, name: string) => {
|
||||
return group;
|
||||
} catch (error) {
|
||||
console.error("Could not create SyncPlay group", error);
|
||||
store.setError("Не удалось создать группу");
|
||||
store.setError("Не удалось создать группу Blink");
|
||||
return undefined;
|
||||
} finally {
|
||||
store.setLoading(false);
|
||||
@@ -109,20 +232,19 @@ export const joinSyncPlayGroup = async (api: Api, groupId: string) => {
|
||||
store.setLoading(true);
|
||||
store.setError(null);
|
||||
try {
|
||||
const group = (await syncApi(api).syncPlayGetGroup({ id: groupId })).data;
|
||||
if (!group || !isBlinkGroup(group)) {
|
||||
store.setError("Можно входить только в группы Blink");
|
||||
return;
|
||||
}
|
||||
await syncApi(api).syncPlayJoinGroup({
|
||||
joinGroupRequestDto: { GroupId: groupId },
|
||||
});
|
||||
try {
|
||||
const group = (await syncApi(api).syncPlayGetGroup({ id: groupId })).data;
|
||||
if (group) store.setGroup(group);
|
||||
} catch {
|
||||
const known = store.groups.find((g) => g.GroupId === groupId);
|
||||
if (known) store.setGroup(known);
|
||||
}
|
||||
store.setGroup(group);
|
||||
await refreshSyncPlayGroups(api);
|
||||
} catch (error) {
|
||||
console.error("Could not join SyncPlay group", error);
|
||||
store.setError("Не удалось войти в группу");
|
||||
store.setError("Не удалось войти в группу Blink");
|
||||
} finally {
|
||||
store.setLoading(false);
|
||||
}
|
||||
@@ -138,9 +260,70 @@ export const leaveSyncPlayGroup = async (api: Api) => {
|
||||
} finally {
|
||||
store.setLoading(false);
|
||||
store.reset();
|
||||
store.setAutoJoin(false);
|
||||
store.setOpen(false);
|
||||
lastAutoStart = { itemId: "", at: 0 };
|
||||
applyingRemoteUntil = 0;
|
||||
resetSyncPlayTimeline();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create or join the shared Blink auto-group. Other Blink clients join it
|
||||
* automatically while their auto-join setting is enabled.
|
||||
*/
|
||||
export const ensureBlinkAutoGroup = async (
|
||||
api: Api,
|
||||
options: { shareQueue?: boolean } = {},
|
||||
) => {
|
||||
const store = useSyncPlayStore.getState();
|
||||
const shareQueueIfAny = async () => {
|
||||
const queue = useQueue.getState();
|
||||
if ((queue.tracks ?? []).length === 0) return;
|
||||
// Other Blink clients poll for the auto-group. Give them a moment to
|
||||
// join before the queue starts, so everyone starts at the same instant
|
||||
// instead of one device joining mid-playback and pausing the group.
|
||||
const others = getOnlineBlinkSessionCount(api.deviceInfo.id) ?? 0;
|
||||
if (others > 0) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 3000));
|
||||
}
|
||||
await startSyncPlayQueue(api);
|
||||
};
|
||||
if (store.group) {
|
||||
if (options.shareQueue) await shareQueueIfAny();
|
||||
return store.group;
|
||||
}
|
||||
|
||||
store.setLoading(true);
|
||||
store.setError(null);
|
||||
try {
|
||||
const groups = (await syncApi(api).syncPlayGetGroups()).data ?? [];
|
||||
const existing = groups.find(isBlinkAutoGroup);
|
||||
let group = existing;
|
||||
if (existing?.GroupId) {
|
||||
await syncApi(api).syncPlayJoinGroup({
|
||||
joinGroupRequestDto: { GroupId: existing.GroupId },
|
||||
});
|
||||
group =
|
||||
(await syncApi(api).syncPlayGetGroup({ id: existing.GroupId })).data ??
|
||||
existing;
|
||||
} else {
|
||||
group = (
|
||||
await syncApi(api).syncPlayCreateGroup({
|
||||
newGroupRequestDto: { GroupName: BLINK_AUTO_GROUP_NAME },
|
||||
})
|
||||
).data;
|
||||
}
|
||||
if (group) store.setGroup(group);
|
||||
await refreshSyncPlayGroups(api);
|
||||
if (options.shareQueue) await shareQueueIfAny();
|
||||
return group;
|
||||
} catch (error) {
|
||||
console.error("Could not start the Blink auto-group", error);
|
||||
store.setError("Не удалось собрать Blink-устройства");
|
||||
return undefined;
|
||||
} finally {
|
||||
store.setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -165,12 +348,6 @@ export const startSyncPlayQueue = async (api: Api) => {
|
||||
StartPositionTicks: position.positionTicks,
|
||||
},
|
||||
});
|
||||
// A lone host should not be stuck on "waiting for everyone".
|
||||
if ((store.group?.Participants?.length ?? 0) <= 1) {
|
||||
window.setTimeout(() => {
|
||||
void resumeSyncPlayGroup(api);
|
||||
}, 900);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Could not start SyncPlay queue", error);
|
||||
store.setError("Не удалось запустить очередь группы");
|
||||
@@ -197,11 +374,6 @@ export const watchSyncPlayQueueHere = async (api: Api, userId: string) => {
|
||||
if (result.kind !== "none") {
|
||||
store.setPendingNavigation(result.kind);
|
||||
if (queue && !queue.IsPlaying) pauseLocalPlayback();
|
||||
if ((store.group?.Participants?.length ?? 0) <= 1) {
|
||||
window.setTimeout(() => {
|
||||
void resumeSyncPlayGroup(api);
|
||||
}, 900);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Could not start the group queue here", error);
|
||||
@@ -219,16 +391,38 @@ export const pauseSyncPlayGroup = async (api: Api) => {
|
||||
}
|
||||
};
|
||||
|
||||
/** Called by the controller to join the shared Blink auto-group when present. */
|
||||
export const joinBlinkAutoGroupIfAvailable = async (api: Api) => {
|
||||
if (useSyncPlayStore.getState().group) return false;
|
||||
try {
|
||||
const groups = (await syncApi(api).syncPlayGetGroups()).data ?? [];
|
||||
const auto = groups.find(isBlinkAutoGroup);
|
||||
if (!auto?.GroupId) return false;
|
||||
await joinSyncPlayGroup(api, auto.GroupId);
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.warn("Could not auto-join the Blink group", error);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export const pingSyncPlayGroup = async (api: Api) => {
|
||||
if (pingInFlight) return;
|
||||
pingInFlight = true;
|
||||
const started = performance.now();
|
||||
try {
|
||||
await syncApi(api).syncPlayPing({
|
||||
// This is the measured latency in milliseconds, not a timestamp.
|
||||
// The server clamps it to 10s; a huge value would delay every
|
||||
// scheduled pause/unpause, so report a conservative local value.
|
||||
pingRequestDto: { Ping: 50 },
|
||||
// This is the measured round-trip latency, not the clock. The server
|
||||
// clamps it to 10s and uses it to schedule pause/unpause commands.
|
||||
pingRequestDto: { Ping: Math.round(pingEstimateMs) },
|
||||
});
|
||||
const rtt = Math.min(10_000, Math.max(1, performance.now() - started));
|
||||
pingEstimateMs = Math.round(pingEstimateMs * 0.65 + rtt * 0.35);
|
||||
useSyncPlayStore.getState().setPingMs(Math.round(pingEstimateMs));
|
||||
} catch (error) {
|
||||
console.warn("Could not ping SyncPlay group", error);
|
||||
} finally {
|
||||
pingInFlight = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -290,9 +484,6 @@ const applyQueueUpdate = async (
|
||||
if (Math.abs(local.positionTicks - position) > DRIFT_TOLERANCE_TICKS) {
|
||||
seekLocalPlayback(position);
|
||||
}
|
||||
// A new group queue starts in Waiting until every device reports that
|
||||
// it is ready. The host already has the item loaded.
|
||||
reportSyncPlayReady(api, local.positionTicks, queue.IsPlaying ?? false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -315,7 +506,12 @@ const applyQueueUpdate = async (
|
||||
});
|
||||
if (result.kind !== "none") {
|
||||
store.setPendingNavigation(result.kind);
|
||||
if (!queue.IsPlaying) pauseLocalPlayback();
|
||||
if (!queue.IsPlaying) {
|
||||
// The player may mount later; keep its initial pause from
|
||||
// echoing back as a Pause request that would cancel the start.
|
||||
guardRemote(5000);
|
||||
pauseLocalPlayback();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Could not follow the SyncPlay queue", error);
|
||||
@@ -335,7 +531,15 @@ export const handleSyncPlayGroupUpdate = async (
|
||||
break;
|
||||
case "PlayQueue":
|
||||
if (update.Data) {
|
||||
// A new queue resets the group timeline. Commit and seek
|
||||
// commands for it carry their own position from now on.
|
||||
resetSyncPlayTimeline();
|
||||
store.setQueue(update.Data);
|
||||
// A client joining after the queue was set receives the queue
|
||||
// update before it has seen the Waiting state. Refresh it so the
|
||||
// ready heartbeat starts immediately instead of waiting for the
|
||||
// server's group-wait timeout.
|
||||
void refreshSyncPlayGroup(api);
|
||||
await applyQueueUpdate(api, userId, update.Data);
|
||||
}
|
||||
break;
|
||||
@@ -343,11 +547,11 @@ export const handleSyncPlayGroupUpdate = async (
|
||||
const group = store.group;
|
||||
if (group && update.Data?.State) {
|
||||
store.setGroup({ ...group, State: update.Data.State });
|
||||
groupStateChangedAt = Date.now();
|
||||
}
|
||||
if (update.Data?.State === "Paused") {
|
||||
guardRemote();
|
||||
pauseLocalPlayback();
|
||||
}
|
||||
// Playback itself is driven by the scheduled Pause/Unpause/Seek
|
||||
// commands: they carry the server timestamp and position. Acting on
|
||||
// the state update too would resume clients at different instants.
|
||||
break;
|
||||
}
|
||||
case "UserJoined":
|
||||
@@ -362,6 +566,7 @@ export const handleSyncPlayGroupUpdate = async (
|
||||
store.setOpen(false);
|
||||
lastAutoStart = { itemId: "", at: 0 };
|
||||
applyingRemoteUntil = 0;
|
||||
resetSyncPlayTimeline();
|
||||
break;
|
||||
case "LibraryAccessDenied":
|
||||
useSyncPlayStore.getState().setError("Нет доступа к библиотеке группы");
|
||||
@@ -372,8 +577,55 @@ export const handleSyncPlayGroupUpdate = async (
|
||||
export const handleSyncPlayCommand = (command: SendCommand) => {
|
||||
const group = useSyncPlayStore.getState().group;
|
||||
if (!group) return;
|
||||
const when = command.When ? Date.parse(command.When) : Number.NaN;
|
||||
const anchorAt = Number.isFinite(when) ? when : Date.now();
|
||||
const ticks = command.PositionTicks ?? getExpectedSyncPlayPosition() ?? 0;
|
||||
|
||||
// The server schedules each command with its own clock and position. Keep
|
||||
// that as the group timeline; extrapolating from a stale queue update is
|
||||
// what made clients drift after an unpause.
|
||||
switch (command.Command) {
|
||||
case SendCommandType.Unpause:
|
||||
playAnchor = { ticks, at: anchorAt, playing: true };
|
||||
scheduledUnpauseAt = anchorAt;
|
||||
break;
|
||||
case SendCommandType.Pause:
|
||||
playAnchor = { ticks, at: anchorAt, playing: false };
|
||||
scheduledUnpauseAt = 0;
|
||||
break;
|
||||
case SendCommandType.Seek:
|
||||
// A seek puts the group back into Waiting: playback stays parked at
|
||||
// the seek position until every client reports ready. Extrapolating
|
||||
// here makes the server chase a moving target forever.
|
||||
playAnchor = { ticks, at: anchorAt, playing: false };
|
||||
scheduledUnpauseAt = 0;
|
||||
break;
|
||||
case SendCommandType.Stop:
|
||||
playAnchor = null;
|
||||
scheduledUnpauseAt = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
const apply = () => {
|
||||
guardRemote(1500);
|
||||
const target = getExpectedSyncPlayPosition();
|
||||
const local = getLocalPlayback();
|
||||
const groupItemId = getCurrentGroupItemId();
|
||||
// A command belongs to the group's current media. Never seek or pause
|
||||
// unrelated local audio/video (for example music started while a group
|
||||
// video is playing) — that caused tracks to jump to their end and loop.
|
||||
if (!groupItemId) return;
|
||||
if (local.kind === "none" || local.itemId !== groupItemId) return;
|
||||
// Commands carry the position the group should be at. Align before
|
||||
// applying the action so a missed or late command does not leave this
|
||||
// client seconds away from the others.
|
||||
if (
|
||||
target != null &&
|
||||
command.Command !== SendCommandType.Stop &&
|
||||
Math.abs(local.positionTicks - target) > 3_000_000
|
||||
) {
|
||||
seekLocalPlayback(target);
|
||||
}
|
||||
switch (command.Command) {
|
||||
case SendCommandType.Pause:
|
||||
case SendCommandType.Stop:
|
||||
@@ -383,13 +635,13 @@ export const handleSyncPlayCommand = (command: SendCommand) => {
|
||||
resumeLocalPlayback();
|
||||
break;
|
||||
case SendCommandType.Seek:
|
||||
if (command.PositionTicks != null) {
|
||||
seekLocalPlayback(command.PositionTicks);
|
||||
}
|
||||
// Already aligned above from the command's own position. The
|
||||
// group is waiting for everyone at the new position, so hold
|
||||
// this client paused until the server unpauses the group.
|
||||
if (!getLocalPlayback().paused) pauseLocalPlayback();
|
||||
break;
|
||||
}
|
||||
};
|
||||
const when = command.When ? Date.parse(command.When) : Number.NaN;
|
||||
const delay = Number.isFinite(when)
|
||||
? Math.min(10_000, Math.max(0, when - Date.now()))
|
||||
: 0;
|
||||
@@ -397,8 +649,97 @@ export const handleSyncPlayCommand = (command: SendCommand) => {
|
||||
else apply();
|
||||
};
|
||||
|
||||
/**
|
||||
* Reconcile local playback with the group state after a missed unpause (for
|
||||
* example while the player was still loading). Runs on a short timer from the
|
||||
* controller; guarded commands do not echo back to the group.
|
||||
*/
|
||||
export const enforceSyncPlayLocalState = () => {
|
||||
const group = useSyncPlayStore.getState().group;
|
||||
if (!group) return;
|
||||
const local = getLocalPlayback();
|
||||
if (local.kind === "none") return;
|
||||
if (!localMatchesGroupItem(local)) return;
|
||||
const expected = getExpectedSyncPlayPosition();
|
||||
|
||||
if (group.State === "Playing" && local.ready) {
|
||||
// Respect the server's scheduled unpause instant. Resuming as soon as
|
||||
// the state update arrives starts each client at its own moment.
|
||||
const unpauseDue =
|
||||
scheduledUnpauseAt === 0 || Date.now() >= scheduledUnpauseAt + 1000;
|
||||
if (local.paused && unpauseDue) {
|
||||
guardRemote(1600);
|
||||
resumeLocalPlayback();
|
||||
}
|
||||
if (
|
||||
!local.paused &&
|
||||
expected != null &&
|
||||
Math.abs(local.positionTicks - expected) > 7_000_000
|
||||
) {
|
||||
guardRemote(1600);
|
||||
seekLocalPlayback(expected);
|
||||
}
|
||||
} else if (
|
||||
group.State === "Paused" &&
|
||||
!local.paused &&
|
||||
Date.now() - groupStateChangedAt > 1200
|
||||
) {
|
||||
guardRemote(1600);
|
||||
pauseLocalPlayback();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A client that deliberately plays local media while the group watches a
|
||||
* different item must not hold the group on every pause. Tell the server to
|
||||
* ignore this session's buffering state until it returns to the group item.
|
||||
*/
|
||||
export const syncPlayIgnoreWaitIfNeeded = (api: Api | undefined) => {
|
||||
if (!api) return;
|
||||
const group = useSyncPlayStore.getState().group;
|
||||
if (!group) {
|
||||
ignoreWaitSent = null;
|
||||
return;
|
||||
}
|
||||
const groupItemId = getCurrentGroupItemId();
|
||||
const local = getLocalPlayback();
|
||||
if (!groupItemId) return;
|
||||
|
||||
let shouldIgnore: boolean;
|
||||
if (local.kind !== "none" && local.itemId === groupItemId) {
|
||||
lastGroupItemLocalAt = Date.now();
|
||||
shouldIgnore = false;
|
||||
} else if (local.kind !== "none") {
|
||||
// The user deliberately started different media on this client.
|
||||
shouldIgnore = true;
|
||||
} else {
|
||||
// The player was closed while the group kept watching. Do not leave
|
||||
// the group, but do not hold everyone while this client browses.
|
||||
if (!lastGroupItemLocalAt || Date.now() - lastGroupItemLocalAt < 3000) {
|
||||
return;
|
||||
}
|
||||
shouldIgnore = true;
|
||||
}
|
||||
|
||||
if (ignoreWaitSent === shouldIgnore) return;
|
||||
ignoreWaitSent = shouldIgnore;
|
||||
syncApi(api)
|
||||
.syncPlaySetIgnoreWait({
|
||||
ignoreWaitRequestDto: { IgnoreWait: shouldIgnore },
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn("Could not update SyncPlay ignore-wait", error);
|
||||
ignoreWaitSent = null;
|
||||
});
|
||||
};
|
||||
|
||||
export const reportSyncPlayPause = (api: Api | undefined) => {
|
||||
if (!api || !inSyncPlayGroup() || isApplyingSyncPlayRemote()) return;
|
||||
if (isLocalMediaSwitching()) return;
|
||||
// While the group waits for everyone, a local pause is part of parking,
|
||||
// not a user request: turning it into a Pause would cancel the start.
|
||||
if (useSyncPlayStore.getState().group?.State === "Waiting") return;
|
||||
if (!localMatchesGroupItem()) return;
|
||||
const now = Date.now();
|
||||
if (
|
||||
lastPauseReport.paused &&
|
||||
@@ -412,6 +753,11 @@ export const reportSyncPlayPause = (api: Api | undefined) => {
|
||||
|
||||
export const reportSyncPlayResume = (api: Api | undefined) => {
|
||||
if (!api || !inSyncPlayGroup() || isApplyingSyncPlayRemote()) return;
|
||||
if (isLocalMediaSwitching()) return;
|
||||
// Pressing play while the group is still parking forces the server to
|
||||
// skip the wait and desynchronises everyone.
|
||||
if (useSyncPlayStore.getState().group?.State === "Waiting") return;
|
||||
if (!localMatchesGroupItem()) return;
|
||||
const now = Date.now();
|
||||
if (
|
||||
!lastPauseReport.paused &&
|
||||
@@ -428,6 +774,11 @@ export const reportSyncPlaySeek = (
|
||||
positionTicks: number,
|
||||
) => {
|
||||
if (!api || !inSyncPlayGroup() || isApplyingSyncPlayRemote()) return;
|
||||
if (isLocalMediaSwitching()) return;
|
||||
// Initial seeks and parking while the group waits are local, not a user
|
||||
// request to move the whole group.
|
||||
if (useSyncPlayStore.getState().group?.State === "Waiting") return;
|
||||
if (!localMatchesGroupItem()) return;
|
||||
const now = Date.now();
|
||||
if (
|
||||
now - lastSeekReport.at < SEEK_REPORT_INTERVAL_MS ||
|
||||
@@ -445,6 +796,7 @@ export const reportSyncPlayReady = (
|
||||
isPlaying: boolean,
|
||||
) => {
|
||||
if (!api || !inSyncPlayGroup()) return;
|
||||
if (!localMatchesGroupItem()) return;
|
||||
const queue = useSyncPlayStore.getState().queue;
|
||||
const item = currentQueueItem(queue);
|
||||
if (!item?.PlaylistItemId) return;
|
||||
@@ -461,13 +813,6 @@ export const reportSyncPlayReady = (
|
||||
window.setTimeout(() => {
|
||||
void refreshSyncPlayGroup(api);
|
||||
}, 800);
|
||||
// A solo host can begin immediately; with more devices the server
|
||||
// waits for everyone, then sends the unpause command.
|
||||
const participants =
|
||||
useSyncPlayStore.getState().group?.Participants?.length ?? 0;
|
||||
if (participants <= 1) {
|
||||
void resumeSyncPlayGroup(api);
|
||||
}
|
||||
})
|
||||
.catch((error) => console.warn("SyncPlay ready failed", error));
|
||||
};
|
||||
@@ -479,6 +824,15 @@ export const reportSyncPlayBuffering = (
|
||||
isPlaying: boolean,
|
||||
) => {
|
||||
if (!api || !inSyncPlayGroup()) return;
|
||||
if (isLocalMediaSwitching()) return;
|
||||
// While the group holds a fresh queue, every client is intentionally
|
||||
// parked. A paused player still emits waiting events, and reporting them
|
||||
// marks the client as buffering forever, so the group can never start.
|
||||
if (isSyncPlayWaitingForStart()) return;
|
||||
// A paused client is not buffering toward playback; reporting a wait
|
||||
// would mark it buffering and hold the group.
|
||||
if (getLocalPlayback().paused) return;
|
||||
if (!localMatchesGroupItem()) return;
|
||||
const queue = useSyncPlayStore.getState().queue;
|
||||
const item = currentQueueItem(queue);
|
||||
if (!item?.PlaylistItemId) return;
|
||||
|
||||
@@ -50,10 +50,11 @@ export type PlayOnSessionOptions = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Start playback on another Jellyfin session and make sure it begins at the
|
||||
* requested position. Some clients accept the Play command but ignore
|
||||
* StartPositionTicks, so verify the reported position and send a Seek when
|
||||
* they started from the beginning.
|
||||
* Start playback on another Jellyfin session and wait until the target
|
||||
* actually reports the item. Some clients accept the Play command but never
|
||||
* start (or start much later), so the source must not stop its playback until
|
||||
* the target is confirmed. The Play command is retried once; if the target
|
||||
* reports a wrong position, a correcting Seek is sent.
|
||||
*/
|
||||
export const playOnSession = async (
|
||||
api: Api,
|
||||
@@ -65,36 +66,62 @@ export const playOnSession = async (
|
||||
|
||||
const sessionApi = getSessionApi(api);
|
||||
const startPositionTicks = Math.max(0, options.startPositionTicks ?? 0);
|
||||
const startIndex = Math.min(
|
||||
Math.max(0, options.startIndex ?? 0),
|
||||
options.itemIds.length - 1,
|
||||
);
|
||||
const expectedItemId = options.itemIds[startIndex];
|
||||
|
||||
const readTarget = async () => {
|
||||
try {
|
||||
return (await sessionApi.getSessions()).data.find(
|
||||
(session) => session.Id === sessionId,
|
||||
);
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
const waitForItem = async (timeoutMs: number) => {
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
while (Date.now() < deadline) {
|
||||
await sleep(500);
|
||||
const target = await readTarget();
|
||||
if (target?.NowPlayingItem?.Id === expectedItemId) return target;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
let target: SessionInfoDto | undefined;
|
||||
let sentAt = Date.now();
|
||||
for (let attempt = 0; attempt < 2 && !target; attempt += 1) {
|
||||
if (attempt > 0) {
|
||||
const beforeRetry = await readTarget();
|
||||
if (beforeRetry?.NowPlayingItem?.Id === expectedItemId) {
|
||||
target = beforeRetry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
sentAt = Date.now();
|
||||
await sessionApi.play({
|
||||
sessionId,
|
||||
playCommand: "PlayNow",
|
||||
itemIds: options.itemIds,
|
||||
startIndex: options.startIndex ?? 0,
|
||||
startIndex,
|
||||
startPositionTicks,
|
||||
mediaSourceId: options.mediaSourceId,
|
||||
});
|
||||
target = await waitForItem(attempt === 0 ? 6000 : 4000);
|
||||
}
|
||||
|
||||
if (startPositionTicks <= 0) return;
|
||||
|
||||
// Give the target a moment to load, then correct it if it ignored the
|
||||
// start position. Tolerance is generous: buffering can take a few seconds.
|
||||
for (const delay of [900, 1600, 2600]) {
|
||||
await sleep(delay);
|
||||
let target: SessionInfoDto | undefined;
|
||||
try {
|
||||
target = (await sessionApi.getSessions()).data.find(
|
||||
(session) => session.Id === sessionId,
|
||||
);
|
||||
} catch (error) {
|
||||
console.warn("Could not read the target session position", error);
|
||||
continue;
|
||||
if (!target) {
|
||||
throw new Error("Устройство не начало воспроизведение");
|
||||
}
|
||||
if (!target?.NowPlayingItem) continue;
|
||||
|
||||
const paused = target.PlayState?.IsPaused ?? false;
|
||||
const expected =
|
||||
startPositionTicks + (paused ? 0 : delay * (TICKS_PER_SECOND / 1000));
|
||||
startPositionTicks +
|
||||
(paused ? 0 : (Date.now() - sentAt) * (TICKS_PER_SECOND / 1000));
|
||||
const actual = target.PlayState?.PositionTicks ?? 0;
|
||||
if (Math.abs(actual - expected) <= 8 * TICKS_PER_SECOND) return;
|
||||
|
||||
@@ -108,7 +135,6 @@ export const playOnSession = async (
|
||||
} catch (error) {
|
||||
console.warn("Could not seek the target session", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -170,7 +196,10 @@ export const transferSessionToLocal = async (
|
||||
}
|
||||
|
||||
let kind: "audio" | "video" = "video";
|
||||
if (item.Type === BaseItemKind.Audio || item.Type === BaseItemKind.AudioBook) {
|
||||
if (
|
||||
item.Type === BaseItemKind.Audio ||
|
||||
item.Type === BaseItemKind.AudioBook
|
||||
) {
|
||||
kind = "audio";
|
||||
const url = generateAudioStreamUrl(
|
||||
item.Id,
|
||||
|
||||
@@ -7,6 +7,10 @@ import { useStoreWithEqualityFn } from "zustand/traditional";
|
||||
import { version as appVer } from "../../../package.json";
|
||||
import { getDefaultServer, getServer } from "../storage/servers";
|
||||
import { getUser } from "../storage/user";
|
||||
import {
|
||||
getDeviceDisplayName,
|
||||
getOrCreateDeviceId,
|
||||
} from "../deviceIdentity";
|
||||
|
||||
// Initial custom axios client to use tauri's http module
|
||||
import axios from "axios";
|
||||
@@ -29,11 +33,8 @@ export const axiosClient = axios.create({
|
||||
timeout: 60000,
|
||||
});
|
||||
|
||||
const deviceId = localStorage.getItem("deviceId") || crypto.randomUUID();
|
||||
|
||||
if (!localStorage.getItem("deviceId")) {
|
||||
localStorage.setItem("deviceId", deviceId);
|
||||
}
|
||||
const deviceId = getOrCreateDeviceId();
|
||||
const deviceName = getDeviceDisplayName(deviceId);
|
||||
|
||||
export const jellyfin = new Jellyfin({
|
||||
clientInfo: {
|
||||
@@ -41,7 +42,7 @@ export const jellyfin = new Jellyfin({
|
||||
version: appVer,
|
||||
},
|
||||
deviceInfo: {
|
||||
name: "Blink",
|
||||
name: deviceName,
|
||||
id: deviceId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import type React from "react";
|
||||
import { shallow } from "zustand/shallow";
|
||||
import { createWithEqualityFn } from "zustand/traditional";
|
||||
import { markLocalMediaSwitch } from "../methods/mediaSwitch";
|
||||
import playbackProfile from "../playback-profiles";
|
||||
import {
|
||||
getPlayerMuted,
|
||||
@@ -59,6 +60,7 @@ export const playAudio = (
|
||||
playlistItemId?: string | undefined,
|
||||
startTimeTicks = 0,
|
||||
): void => {
|
||||
markLocalMediaSwitch();
|
||||
// Only one medium at a time: starting music stops video playback.
|
||||
if (typeof document !== "undefined") {
|
||||
const video = (document
|
||||
@@ -80,6 +82,10 @@ export const playAudio = (
|
||||
item,
|
||||
playlistItemId,
|
||||
startTimeTicks,
|
||||
player: {
|
||||
...useAudioPlayback.getState().player,
|
||||
playing: true,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -143,6 +149,10 @@ export const setProgress = (ticks: number) => {
|
||||
updatePlayer({ currentTick: ticks });
|
||||
};
|
||||
|
||||
export const setAudioPlaying = (playing: boolean) => {
|
||||
updatePlayer({ playing });
|
||||
};
|
||||
|
||||
export const setVolume = (volume: number) => {
|
||||
updatePlayer({ volume });
|
||||
setPlayerVolume("audio", volume);
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
type HeaderStoreType = {
|
||||
pageTitle: string | null;
|
||||
setPageTitle: (title: string | null) => void;
|
||||
};
|
||||
|
||||
const useHeaderStore = create<HeaderStoreType>((set) => ({
|
||||
pageTitle: null,
|
||||
setPageTitle: (title: string | null) => set(() => ({ pageTitle: title })),
|
||||
}));
|
||||
|
||||
export default useHeaderStore;
|
||||
@@ -20,6 +20,7 @@ import { createWithEqualityFn } from "zustand/traditional";
|
||||
import { secToTicks, ticksToSec } from "../date/time";
|
||||
import getSubtitle from "../methods/getSubtitles";
|
||||
import { addSegmentsFromChapters } from "../methods/mediaSegments";
|
||||
import { markLocalMediaSwitch } from "../methods/mediaSwitch";
|
||||
import playbackProfile from "../playback-profiles";
|
||||
import {
|
||||
getPlayerMuted,
|
||||
@@ -29,7 +30,11 @@ import {
|
||||
} from "../storage/player";
|
||||
import type audioPlaybackInfo from "../types/audioPlaybackInfo";
|
||||
import type subtitlePlaybackInfo from "../types/subtitlePlaybackInfo";
|
||||
import { generateAudioStreamUrl, playAudio, stopPlayback } from "./audioPlayback";
|
||||
import {
|
||||
generateAudioStreamUrl,
|
||||
playAudio,
|
||||
stopPlayback,
|
||||
} from "./audioPlayback";
|
||||
import useQueue, { setQueue } from "./queue";
|
||||
|
||||
type PlaybackStoreState = {
|
||||
@@ -732,6 +737,7 @@ export const initializePlayback = async (args: {
|
||||
} = args;
|
||||
|
||||
// Only one medium at a time: starting a video stops music playback.
|
||||
markLocalMediaSwitch();
|
||||
stopPlayback();
|
||||
|
||||
if (!mediaSource.MediaSources?.[0]?.Id) {
|
||||
|
||||
@@ -9,8 +9,14 @@ type SyncPlayState = {
|
||||
group: GroupInfoDto | null;
|
||||
groups: GroupInfoDto[];
|
||||
queue: PlayQueueUpdate | null;
|
||||
/** Local receipt time of the last group queue update. */
|
||||
queueReceivedAt: number | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
/** Join the Blink auto-group automatically when it is running. */
|
||||
autoJoin: boolean;
|
||||
/** Last measured SyncPlay ping, used by the group status card. */
|
||||
pingMs: number | null;
|
||||
/** Navigation requested by a remote group start. */
|
||||
pendingNavigation: "video" | "audio" | null;
|
||||
setOpen: (open: boolean) => void;
|
||||
@@ -19,17 +25,33 @@ type SyncPlayState = {
|
||||
setQueue: (queue: PlayQueueUpdate | null) => void;
|
||||
setLoading: (loading: boolean) => void;
|
||||
setError: (error: string | null) => void;
|
||||
setAutoJoin: (autoJoin: boolean) => void;
|
||||
setPingMs: (pingMs: number | null) => void;
|
||||
setPendingNavigation: (kind: "video" | "audio" | null) => void;
|
||||
reset: () => void;
|
||||
};
|
||||
|
||||
const AUTO_JOIN_KEY = "blink.syncPlayAutoJoin";
|
||||
|
||||
const readAutoJoin = () => {
|
||||
try {
|
||||
const stored = localStorage.getItem(AUTO_JOIN_KEY);
|
||||
return stored === null ? true : stored === "true";
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
open: false,
|
||||
group: null as GroupInfoDto | null,
|
||||
groups: [] as GroupInfoDto[],
|
||||
queue: null as PlayQueueUpdate | null,
|
||||
queueReceivedAt: null as number | null,
|
||||
loading: false,
|
||||
error: null as string | null,
|
||||
autoJoin: readAutoJoin(),
|
||||
pingMs: null as number | null,
|
||||
pendingNavigation: null as "video" | "audio" | null,
|
||||
};
|
||||
|
||||
@@ -38,14 +60,28 @@ export const useSyncPlayStore = create<SyncPlayState>((set) => ({
|
||||
setOpen: (open) => set({ open }),
|
||||
setGroup: (group) => set({ group }),
|
||||
setGroups: (groups) => set({ groups }),
|
||||
setQueue: (queue) => set({ queue }),
|
||||
setQueue: (queue) =>
|
||||
set({
|
||||
queue,
|
||||
queueReceivedAt: queue ? Date.now() : null,
|
||||
}),
|
||||
setLoading: (loading) => set({ loading }),
|
||||
setError: (error) => set({ error }),
|
||||
setAutoJoin: (autoJoin) => {
|
||||
try {
|
||||
localStorage.setItem(AUTO_JOIN_KEY, String(autoJoin));
|
||||
} catch {
|
||||
// Storage can be unavailable; the in-memory setting still applies.
|
||||
}
|
||||
set({ autoJoin });
|
||||
},
|
||||
setPingMs: (pingMs) => set({ pingMs }),
|
||||
setPendingNavigation: (pendingNavigation) => set({ pendingNavigation }),
|
||||
reset: () =>
|
||||
set((state) => ({
|
||||
...initialState,
|
||||
open: state.open,
|
||||
autoJoin: state.autoJoin,
|
||||
})),
|
||||
}));
|
||||
|
||||
|
||||
Reference in new issue
Block a user