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
+5399
-3413
No files matched your search
@@ -45,3 +45,6 @@ generateBanner
|
|||||||
|
|
||||||
# TypeScript incremental build cache
|
# TypeScript incremental build cache
|
||||||
*.tsbuildinfo
|
*.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 React from "react";
|
||||||
import QuickConnectButton from "../buttons/quickConnectButton";
|
import QuickConnectButton from "../buttons/quickConnectButton";
|
||||||
|
|
||||||
|
import "./backOnly.scss";
|
||||||
|
|
||||||
export default function AppBarBackOnly() {
|
export default function AppBarBackOnly() {
|
||||||
const { history } = useRouter();
|
const { history } = useRouter();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -26,7 +28,7 @@ export default function AppBarBackOnly() {
|
|||||||
<IconButton
|
<IconButton
|
||||||
size="large"
|
size="large"
|
||||||
edge="start"
|
edge="start"
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
color="white"
|
color="white"
|
||||||
aria-label="Назад"
|
aria-label="Назад"
|
||||||
disabled={history.length <= 1}
|
disabled={history.length <= 1}
|
||||||
@@ -48,4 +50,4 @@ export default function AppBarBackOnly() {
|
|||||||
</Toolbar>
|
</Toolbar>
|
||||||
</AppBar>
|
</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 = {
|
type CastButtonProps = {
|
||||||
item?: BaseItemDto | null;
|
item?: BaseItemDto | null;
|
||||||
transfer?: Omit<RemoteTransfer, "item">;
|
transfer?: RemoteTransfer;
|
||||||
/** Computed on click so playback position/queue are current. */
|
/** Computed on click so playback position/queue are current. */
|
||||||
getTransfer?: () => Omit<RemoteTransfer, "item">;
|
getTransfer?: () => RemoteTransfer | null;
|
||||||
size?: "small" | "medium" | "large";
|
size?: "small" | "medium" | "large";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -22,16 +22,28 @@ const CastButton = ({
|
|||||||
}: CastButtonProps) => {
|
}: CastButtonProps) => {
|
||||||
const openDialog = useRemoteControlStore((s) => s.openDialog);
|
const openDialog = useRemoteControlStore((s) => s.openDialog);
|
||||||
return (
|
return (
|
||||||
<Tooltip title={item ? "Воспроизвести на другом устройстве" : "Удалённое управление"}>
|
<Tooltip
|
||||||
|
title={
|
||||||
|
item
|
||||||
|
? "Передать текущее медиа на устройство"
|
||||||
|
: "Удалённое управление"
|
||||||
|
}
|
||||||
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
size={size}
|
size={size}
|
||||||
aria-label={item ? "Воспроизвести на другом устройстве" : "Удалённое управление"}
|
aria-label={
|
||||||
onClick={() =>
|
item
|
||||||
openDialog({
|
? "Передать текущее медиа на устройство"
|
||||||
...(getTransfer ? getTransfer() : transfer),
|
: "Удалённое управление"
|
||||||
item: item ?? null,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
onClick={() => {
|
||||||
|
const computed = getTransfer ? getTransfer() : transfer;
|
||||||
|
const resolvedItem = item ?? computed?.item ?? null;
|
||||||
|
openDialog({
|
||||||
|
...(computed ?? {}),
|
||||||
|
item: resolvedItem,
|
||||||
|
});
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">cast</span>
|
<span className="material-symbols-rounded">cast</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ const CardContent = ({
|
|||||||
opacity: 0.9,
|
opacity: 0.9,
|
||||||
fontSize: "0.875rem",
|
fontSize: "0.875rem",
|
||||||
fontWeight: 500,
|
fontWeight: 500,
|
||||||
|
lineHeight: 1.3,
|
||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
@@ -218,6 +219,7 @@ const CardContent = ({
|
|||||||
style={{
|
style={{
|
||||||
opacity: 0.6,
|
opacity: 0.6,
|
||||||
fontSize: "0.75rem",
|
fontSize: "0.75rem",
|
||||||
|
lineHeight: 1.3,
|
||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
textOverflow: "ellipsis",
|
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,
|
BaseItemKind,
|
||||||
type SessionInfoDto,
|
type SessionInfoDto,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
import { Box, Button, IconButton, Tooltip, Typography } from "@mui/material";
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
IconButton,
|
|
||||||
Paper,
|
|
||||||
Tooltip,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
import { motion } from "motion/react";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
import React, { useCallback, useMemo, useState } from "react";
|
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 getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { transferSessionToLocal } from "@/utils/methods/transferPlayback";
|
import { transferSessionToLocal } from "@/utils/methods/transferPlayback";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { usePlaybackStore } from "@/utils/store/playback";
|
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_STORAGE_KEY = "blink:follow-me-dismissed";
|
||||||
const DISMISS_TTL_MS = 30 * 60 * 1000;
|
const DISMISS_TTL_MS = 30 * 60 * 1000;
|
||||||
@@ -53,8 +51,7 @@ const formatTime = (ticks: number) => {
|
|||||||
: `${minutes}:${String(seconds).padStart(2, "0")}`;
|
: `${minutes}:${String(seconds).padStart(2, "0")}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deviceLabel = (session: SessionInfoDto) =>
|
const deviceLabel = (session: SessionInfoDto) => getBlinkDeviceName(session);
|
||||||
session.DeviceName || session.Client || "другое устройство";
|
|
||||||
|
|
||||||
const posterId = (item: BaseItemDto) =>
|
const posterId = (item: BaseItemDto) =>
|
||||||
item.ImageTags?.Primary ? item.Id : (item.SeriesId ?? item.Id);
|
item.ImageTags?.Primary ? item.Id : (item.SeriesId ?? item.Id);
|
||||||
@@ -74,32 +71,18 @@ const FollowMe = () => {
|
|||||||
Boolean(state.playbackStream && state.metadata.item?.Id),
|
Boolean(state.playbackStream && state.metadata.item?.Id),
|
||||||
);
|
);
|
||||||
const localAudioActive = useAudioPlayback((state) =>
|
const localAudioActive = useAudioPlayback((state) =>
|
||||||
Boolean(state.display && state.item?.Id),
|
Boolean(state.display && state.item?.Id && state.player.playing),
|
||||||
);
|
);
|
||||||
const localActive = localVideoActive || localAudioActive;
|
const localActive = localVideoActive || localAudioActive;
|
||||||
|
|
||||||
const realtimeSessions = useRealtimeStore((state) => state.sessions);
|
const blink = useBlinkSessions(!localActive);
|
||||||
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 [dismissed, setDismissed] = useState<DismissedMap>(readDismissed);
|
const [dismissed, setDismissed] = useState<DismissedMap>(readDismissed);
|
||||||
const [transferring, setTransferring] = useState(false);
|
const [transferring, setTransferring] = useState(false);
|
||||||
|
|
||||||
const candidate = useMemo(() => {
|
const candidate = useMemo(() => {
|
||||||
if (!api || !user?.Id || localActive) return undefined;
|
if (!api || !user?.Id || localActive) return undefined;
|
||||||
const sessions =
|
const options = blink.sessions.filter((session) => {
|
||||||
realtimeSessions.length > 0
|
|
||||||
? realtimeSessions
|
|
||||||
: (sessionsQuery.data ?? []);
|
|
||||||
const options = sessions.filter((session) => {
|
|
||||||
const item = session.NowPlayingItem;
|
const item = session.NowPlayingItem;
|
||||||
const lastCheckIn = session.LastPlaybackCheckIn
|
const lastCheckIn = session.LastPlaybackCheckIn
|
||||||
? Date.parse(session.LastPlaybackCheckIn)
|
? Date.parse(session.LastPlaybackCheckIn)
|
||||||
@@ -109,8 +92,6 @@ const FollowMe = () => {
|
|||||||
return (
|
return (
|
||||||
Boolean(session.Id && item?.Id) &&
|
Boolean(session.Id && item?.Id) &&
|
||||||
!stale &&
|
!stale &&
|
||||||
session.DeviceId !== api.deviceInfo.id &&
|
|
||||||
session.UserId === user.Id &&
|
|
||||||
item?.Type !== BaseItemKind.Photo &&
|
item?.Type !== BaseItemKind.Photo &&
|
||||||
(item?.Type === BaseItemKind.Audio ||
|
(item?.Type === BaseItemKind.Audio ||
|
||||||
item?.Type === BaseItemKind.AudioBook ||
|
item?.Type === BaseItemKind.AudioBook ||
|
||||||
@@ -137,14 +118,7 @@ const FollowMe = () => {
|
|||||||
const key = `${session.Id}:${item.Id}`;
|
const key = `${session.Id}:${item.Id}`;
|
||||||
if (dismissed[key]) return undefined;
|
if (dismissed[key]) return undefined;
|
||||||
return { session, item, position, key };
|
return { session, item, position, key };
|
||||||
}, [
|
}, [api, user?.Id, localActive, blink.sessions, dismissed]);
|
||||||
api,
|
|
||||||
user?.Id,
|
|
||||||
localActive,
|
|
||||||
realtimeSessions,
|
|
||||||
sessionsQuery.data,
|
|
||||||
dismissed,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const dismiss = useCallback((key: string) => {
|
const dismiss = useCallback((key: string) => {
|
||||||
setDismissed((current) => {
|
setDismissed((current) => {
|
||||||
@@ -191,24 +165,16 @@ const FollowMe = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper
|
<motion.div
|
||||||
elevation={10}
|
className="follow-me-card"
|
||||||
sx={{
|
style={
|
||||||
position: "fixed",
|
{ "--follow-accent": getCoverPalette(item).base } as React.CSSProperties
|
||||||
left: 24,
|
}
|
||||||
bottom: 24,
|
initial={{ opacity: 0, y: 18, scale: 0.97 }}
|
||||||
zIndex: 1300,
|
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||||
display: "flex",
|
exit={{ opacity: 0, y: 12, scale: 0.98 }}
|
||||||
gap: 1.5,
|
whileHover={{ y: -2 }}
|
||||||
alignItems: "stretch",
|
transition={{ type: "spring", stiffness: 380, damping: 32 }}
|
||||||
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)",
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
component="img"
|
component="img"
|
||||||
@@ -270,7 +236,7 @@ const FollowMe = () => {
|
|||||||
</span>
|
</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Paper>
|
</motion.div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import ShowMoreText from "@/components/showMoreText";
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import useHeaderStore from "@/utils/store/header";
|
|
||||||
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||||
|
|
||||||
import "./itemDetail.scss";
|
import "./itemDetail.scss";
|
||||||
@@ -85,19 +84,13 @@ const ItemDetailLayout = ({
|
|||||||
item.Type === BaseItemKind.Video ||
|
item.Type === BaseItemKind.Video ||
|
||||||
item.Type === BaseItemKind.Trailer;
|
item.Type === BaseItemKind.Trailer;
|
||||||
|
|
||||||
|
// Show the item's artwork as the ambient page backdrop.
|
||||||
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||||
const hash = backdropHash ?? getDefaultBackdropHash(item);
|
const hash = backdropHash ?? getDefaultBackdropHash(item);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setBackdrop(hash);
|
setBackdrop(hash);
|
||||||
}, [hash, setBackdrop]);
|
}, [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 (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
import {
|
import {
|
||||||
AppBar,
|
|
||||||
Button,
|
Button,
|
||||||
Chip,
|
Chip,
|
||||||
IconButton,
|
IconButton,
|
||||||
@@ -13,36 +12,27 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Typography,
|
Typography,
|
||||||
useScrollTrigger,
|
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
|
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
|
||||||
import { useSnackbar } from "notistack";
|
|
||||||
import { getRouteApi, useNavigate } from "@tanstack/react-router";
|
import { getRouteApi, useNavigate } from "@tanstack/react-router";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
import type { ChangeEvent } from "react";
|
import type { ChangeEvent } from "react";
|
||||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { AVAILABLE_VIEWS, SORT_BY_OPTIONS } from "@/utils/constants/library";
|
import { AVAILABLE_VIEWS, SORT_BY_OPTIONS } from "@/utils/constants/library";
|
||||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||||
import {
|
import { generateAudioStreamUrl, playAudio } from "@/utils/store/audioPlayback";
|
||||||
generateAudioStreamUrl,
|
|
||||||
playAudio,
|
|
||||||
} from "@/utils/store/audioPlayback";
|
|
||||||
import { setQueue } from "@/utils/store/queue";
|
|
||||||
// import removed: header reads name/count from Zustand slice
|
|
||||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||||
import useSearchStore from "@/utils/store/search";
|
import { setQueue } from "@/utils/store/queue";
|
||||||
import { NavigationDrawer } from "../appBar/navigationDrawer";
|
|
||||||
import BackButton from "../buttons/backButton";
|
|
||||||
import CastButton from "../buttons/castButton";
|
|
||||||
import { FiltersDialogTrigger } from "../filtersDialog";
|
import { FiltersDialogTrigger } from "../filtersDialog";
|
||||||
import { UserAvatarMenu } from "../userAvatarMenu";
|
|
||||||
import WindowControls from "../windowControls";
|
|
||||||
import "./libraryHeader.scss";
|
import "./libraryHeader.scss";
|
||||||
|
|
||||||
const route = getRouteApi("/_api/library/$id");
|
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 = () => {
|
export const LibraryHeader = () => {
|
||||||
const { id: currentLibraryId } = route.useParams();
|
const { id: currentLibraryId } = route.useParams();
|
||||||
const { api, user } = route.useRouteContext();
|
const { api, user } = route.useRouteContext();
|
||||||
@@ -51,7 +41,6 @@ export const LibraryHeader = () => {
|
|||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
const [shuffling, setShuffling] = useState(false);
|
const [shuffling, setShuffling] = useState(false);
|
||||||
|
|
||||||
// Zustand library state (selected via shallow comparator)
|
|
||||||
const {
|
const {
|
||||||
currentViewType,
|
currentViewType,
|
||||||
storeSortBy,
|
storeSortBy,
|
||||||
@@ -87,7 +76,6 @@ export const LibraryHeader = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!currentLibraryId) return;
|
if (!currentLibraryId) return;
|
||||||
// If the slice isn't initialized, these fields will be undefined
|
|
||||||
if (
|
if (
|
||||||
currentViewType === undefined &&
|
currentViewType === undefined &&
|
||||||
storeSortBy === undefined &&
|
storeSortBy === undefined &&
|
||||||
@@ -105,13 +93,10 @@ export const LibraryHeader = () => {
|
|||||||
storeSortAscending,
|
storeSortAscending,
|
||||||
initLibrary,
|
initLibrary,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const currentLibrary = useSuspenseQuery(
|
const currentLibrary = useSuspenseQuery(
|
||||||
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||||
);
|
);
|
||||||
const scrollTrigger = useScrollTrigger({
|
|
||||||
disableHysteresis: true,
|
|
||||||
threshold: 20,
|
|
||||||
});
|
|
||||||
|
|
||||||
const compatibleViews = useMemo(
|
const compatibleViews = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@@ -122,7 +107,7 @@ export const LibraryHeader = () => {
|
|||||||
),
|
),
|
||||||
[currentLibrary.data.CollectionType],
|
[currentLibrary.data.CollectionType],
|
||||||
);
|
);
|
||||||
// Values from store
|
|
||||||
const sortBy = (storeSortBy ?? ItemSortBy.Name) as string;
|
const sortBy = (storeSortBy ?? ItemSortBy.Name) as string;
|
||||||
const sortAscending = storeSortAscending ?? true;
|
const sortAscending = storeSortAscending ?? true;
|
||||||
const effectiveViewType = currentViewType as any;
|
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(
|
const prefetchItems = useCallback(
|
||||||
async (sortByValue: string, asc: boolean) => {
|
async (sortByValue: string, asc: boolean) => {
|
||||||
if (!api || !user?.Id || !currentLibraryId || !normalizedViewType) return;
|
if (!api || !user?.Id || !currentLibraryId || !normalizedViewType) return;
|
||||||
@@ -294,235 +274,140 @@ export const LibraryHeader = () => {
|
|||||||
} finally {
|
} finally {
|
||||||
setShuffling(false);
|
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 libraryName = libraryNameFromStore ?? currentLibrary.data.Name;
|
||||||
const totalCount = itemsTotalCount;
|
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 (
|
return (
|
||||||
<>
|
<div className="library-toolbar">
|
||||||
<AppBar
|
<div className="library-toolbar-heading">
|
||||||
data-tauri-drag-region
|
<Typography variant="h5" noWrap className="library-toolbar-title">
|
||||||
className={
|
{libraryName}
|
||||||
scrollTrigger
|
</Typography>
|
||||||
? "library-header scrolling flex flex-row"
|
{typeof totalCount === "number" && (
|
||||||
: "library-header flex flex-row"
|
<Chip
|
||||||
}
|
|
||||||
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">
|
|
||||||
{libraryName}
|
|
||||||
</Typography>
|
|
||||||
{typeof totalCount === "number" && (
|
|
||||||
<Chip label={totalCount} sx={{ px: 0.5, ml: 1 }} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<TextField
|
|
||||||
select
|
|
||||||
size="small"
|
size="small"
|
||||||
value={String(normalizedViewType)}
|
label={totalCount.toLocaleString()}
|
||||||
onChange={handleChangeViewType}
|
className="library-toolbar-count"
|
||||||
slotProps={{
|
/>
|
||||||
select: {
|
)}
|
||||||
MenuProps: {
|
</div>
|
||||||
slotProps: { paper: { className: "glass-menu-paper" } },
|
|
||||||
},
|
<div className="library-toolbar-controls">
|
||||||
|
<TextField
|
||||||
|
select
|
||||||
|
size="small"
|
||||||
|
value={String(normalizedViewType)}
|
||||||
|
onChange={handleChangeViewType}
|
||||||
|
slotProps={{
|
||||||
|
select: {
|
||||||
|
MenuProps: {
|
||||||
|
slotProps: { paper: { className: "glass-menu-paper" } },
|
||||||
},
|
},
|
||||||
}}
|
},
|
||||||
>
|
}}
|
||||||
<MenuItem disabled value="">
|
>
|
||||||
<Typography variant="overline" color="textSecondary">
|
<MenuItem disabled value="">
|
||||||
Вид
|
<Typography variant="overline" color="textSecondary">
|
||||||
</Typography>
|
Вид
|
||||||
|
</Typography>
|
||||||
|
</MenuItem>
|
||||||
|
{compatibleViews.map((v) => (
|
||||||
|
<MenuItem key={String(v.value)} value={String(v.value)}>
|
||||||
|
{v.title}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{compatibleViews.map((v) => (
|
))}
|
||||||
<MenuItem key={String(v.value)} value={String(v.value)}>
|
</TextField>
|
||||||
{v.title}
|
|
||||||
</MenuItem>
|
{isMusicSongs && (
|
||||||
))}
|
<Tooltip title="Перемешать все композиции">
|
||||||
</TextField>
|
<Button
|
||||||
{isMusicSongs && (
|
className="music-shuffle-button"
|
||||||
<Tooltip title="Перемешать все композиции">
|
variant="contained"
|
||||||
<Button
|
size="small"
|
||||||
className="music-shuffle-button"
|
onClick={shuffleAllTracks}
|
||||||
variant="contained"
|
disabled={shuffling}
|
||||||
size="small"
|
startIcon={
|
||||||
onClick={shuffleAllTracks}
|
<span className="material-symbols-rounded">shuffle</span>
|
||||||
disabled={shuffling}
|
}
|
||||||
startIcon={
|
sx={{
|
||||||
<span className="material-symbols-rounded">shuffle</span>
|
borderRadius: "999px",
|
||||||
}
|
textTransform: "none",
|
||||||
sx={{
|
whiteSpace: "nowrap",
|
||||||
borderRadius: "999px",
|
px: 2,
|
||||||
textTransform: "none",
|
|
||||||
whiteSpace: "nowrap",
|
|
||||||
px: 2,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span className="music-shuffle-label">
|
|
||||||
{shuffling ? "Перемешиваем…" : "Перемешать"}
|
|
||||||
</span>
|
|
||||||
</Button>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
<IconButton
|
|
||||||
onClick={handleSortAscendingToggle}
|
|
||||||
aria-label="Изменить порядок сортировки"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="material-symbols-rounded"
|
|
||||||
style={{
|
|
||||||
transform: sortAscending ? "rotateX(0deg)" : "rotateX(180deg)",
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
sort
|
<span className="music-shuffle-label">
|
||||||
</div>
|
{shuffling ? "Перемешиваем…" : "Перемешать"}
|
||||||
</IconButton>
|
</span>
|
||||||
<TextField
|
</Button>
|
||||||
select
|
</Tooltip>
|
||||||
size="small"
|
)}
|
||||||
value={normalizedSortBy}
|
|
||||||
onChange={handleChangeSortBy}
|
<IconButton
|
||||||
disabled={disableSortOption}
|
onClick={handleSortAscendingToggle}
|
||||||
slotProps={{
|
aria-label="Изменить порядок сортировки"
|
||||||
select: {
|
>
|
||||||
MenuProps: {
|
<span
|
||||||
slotProps: { paper: { className: "glass-menu-paper" } },
|
className="material-symbols-rounded"
|
||||||
},
|
style={{
|
||||||
},
|
transform: sortAscending ? "rotateX(0deg)" : "rotateX(180deg)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MenuItem disabled value="">
|
sort
|
||||||
<Typography variant="overline" color="textSecondary">
|
|
||||||
Сортировка
|
|
||||||
</Typography>
|
|
||||||
</MenuItem>
|
|
||||||
{SORT_BY_OPTIONS.map((option) => {
|
|
||||||
const isCompatible =
|
|
||||||
option.compatibleViewTypes?.includes(currentViewType as any) ||
|
|
||||||
option.compatibleCollectionTypes?.includes(
|
|
||||||
currentLibrary.data.CollectionType as any,
|
|
||||||
);
|
|
||||||
if (!isCompatible) return null;
|
|
||||||
const valueStr = Array.isArray(option.value)
|
|
||||||
? option.value.join(",")
|
|
||||||
: option.value;
|
|
||||||
return (
|
|
||||||
<MenuItem
|
|
||||||
key={
|
|
||||||
Array.isArray(option.value)
|
|
||||||
? option.value.join(",")
|
|
||||||
: option.value
|
|
||||||
}
|
|
||||||
value={valueStr}
|
|
||||||
onMouseEnter={() =>
|
|
||||||
prefetchItems(String(valueStr), sortAscending)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{option.title}
|
|
||||||
</MenuItem>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</TextField>
|
|
||||||
<FiltersDialogTrigger />
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className="library-header-actions flex flex-row"
|
|
||||||
style={{ gap: "0.6em" }}
|
|
||||||
>
|
|
||||||
<span className="library-header-cast">
|
|
||||||
<CastButton />
|
|
||||||
</span>
|
</span>
|
||||||
<IconButton
|
</IconButton>
|
||||||
onClick={toggleSearchDialog}
|
|
||||||
aria-label="Поиск"
|
<TextField
|
||||||
title="Поиск"
|
select
|
||||||
>
|
size="small"
|
||||||
<div className="material-symbols-rounded">search</div>
|
value={normalizedSortBy}
|
||||||
</IconButton>
|
onChange={handleChangeSortBy}
|
||||||
<IconButton
|
disabled={disableSortOption}
|
||||||
className="library-header-favorite"
|
slotProps={{
|
||||||
onClick={handleNavigateToFavorite}
|
select: {
|
||||||
aria-label="Избранное"
|
MenuProps: {
|
||||||
title="Избранное"
|
slotProps: { paper: { className: "glass-menu-paper" } },
|
||||||
>
|
},
|
||||||
<div className="material-symbols-rounded">favorite</div>
|
},
|
||||||
</IconButton>
|
}}
|
||||||
<UserAvatarMenu />
|
>
|
||||||
<WindowControls />
|
<MenuItem disabled value="">
|
||||||
</div>
|
<Typography variant="overline" color="textSecondary">
|
||||||
</AppBar>
|
Сортировка
|
||||||
<NavigationDrawer open={showDrawer} onClose={handleDrawerClose} />
|
</Typography>
|
||||||
</>
|
</MenuItem>
|
||||||
|
{SORT_BY_OPTIONS.map((option) => {
|
||||||
|
const isCompatible =
|
||||||
|
option.compatibleViewTypes?.includes(currentViewType as any) ||
|
||||||
|
option.compatibleCollectionTypes?.includes(
|
||||||
|
currentLibrary.data.CollectionType as any,
|
||||||
|
);
|
||||||
|
if (!isCompatible) return null;
|
||||||
|
const valueStr = Array.isArray(option.value)
|
||||||
|
? option.value.join(",")
|
||||||
|
: option.value;
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
key={
|
||||||
|
Array.isArray(option.value)
|
||||||
|
? option.value.join(",")
|
||||||
|
: option.value
|
||||||
|
}
|
||||||
|
value={valueStr}
|
||||||
|
onMouseEnter={() =>
|
||||||
|
prefetchItems(String(valueStr), sortAscending)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{option.title}
|
||||||
|
</MenuItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</TextField>
|
||||||
|
|
||||||
|
<FiltersDialogTrigger />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -1,57 +1,40 @@
|
|||||||
@media (max-width: 980px) {
|
.library-toolbar {
|
||||||
.library-header-cast,
|
display: flex;
|
||||||
.library-header-favorite {
|
align-items: center;
|
||||||
display: none !important;
|
justify-content: space-between;
|
||||||
}
|
flex-wrap: wrap;
|
||||||
|
gap: 0.75rem 1.5rem;
|
||||||
|
padding: 0 $page-margin;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
|
||||||
|
&-heading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.6rem;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.library-header {
|
|
||||||
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;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.music-shuffle-button {
|
.music-shuffle-button {
|
||||||
.material-symbols-rounded {
|
.material-symbols-rounded {
|
||||||
font-size: 1.15rem;
|
font-size: 1.15rem;
|
||||||
@@ -70,39 +53,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 700px) {
|
@media (max-width: 700px) {
|
||||||
.library-header {
|
.library-toolbar {
|
||||||
inset: calc(0.5em + var(--safe-top)) 0.5em auto 0.5em !important;
|
align-items: flex-start;
|
||||||
width: auto !important;
|
gap: 0.4rem;
|
||||||
flex-wrap: wrap;
|
padding: 0 1rem;
|
||||||
border-radius: 22px;
|
margin-bottom: 0.15rem;
|
||||||
padding: 0.3em 0.5em !important;
|
|
||||||
row-gap: 0.2em;
|
|
||||||
|
|
||||||
html.is-macos & {
|
&-heading {
|
||||||
left: 76px !important;
|
|
||||||
right: 0.5em !important;
|
|
||||||
width: auto !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
> .flex.flex-row:first-child {
|
|
||||||
[aria-label="Главная"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.library-header-center {
|
|
||||||
order: 3;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding-top: 0.35em;
|
}
|
||||||
border-top: 1px solid rgb(255 255 255 / 0.08);
|
|
||||||
gap: 0.4em !important;
|
|
||||||
|
|
||||||
.library-title-count {
|
&-title {
|
||||||
display: none;
|
font-size: 1.15rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-controls {
|
||||||
|
width: 100%;
|
||||||
|
gap: 0.35rem;
|
||||||
|
|
||||||
.MuiTextField-root {
|
.MuiTextField-root {
|
||||||
flex: 1 1 0;
|
flex: 1 1 8rem;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,17 +84,5 @@
|
|||||||
display: none;
|
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, {
|
import React, {
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
|
useLayoutEffect,
|
||||||
useMemo,
|
useMemo,
|
||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import "./libraryItemsGrid.scss";
|
import "./libraryItemsGrid.scss";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
|
||||||
import { AVAILABLE_VIEWS } from "@/utils/constants/library";
|
import { AVAILABLE_VIEWS } from "@/utils/constants/library";
|
||||||
|
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||||
import { getLibraryItemsQueryOptions } from "@/utils/queries/libraryItems";
|
import { getLibraryItemsQueryOptions } from "@/utils/queries/libraryItems";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
@@ -171,17 +172,34 @@ const LibraryItemsGrid = () => {
|
|||||||
}, [backdropItems, setBackdrop]);
|
}, [backdropItems, setBackdrop]);
|
||||||
// --- Virtualization setup ---
|
// --- Virtualization setup ---
|
||||||
const parentRef = useRef<HTMLDivElement | null>(null);
|
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);
|
const [scrollMargin, setScrollMargin] = useState<number>(0);
|
||||||
|
|
||||||
// Determine column count based on container width (simple heuristic).
|
// Determine column count based on container width (simple heuristic).
|
||||||
// Only width changes matter: observing height caused re-layout feedback while
|
// Only width changes matter: observing height caused re-layout feedback while
|
||||||
// the window was resized, and a transitioned header made rows jump.
|
// the window was resized, and a transitioned header made rows jump.
|
||||||
const [columns, setColumns] = useState(1);
|
const [columns, setColumns] = useState(() => estimateLayout().columns);
|
||||||
useEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const element = parentRef.current;
|
const element = parentRef.current;
|
||||||
if (!element) return;
|
if (!element) return;
|
||||||
let frame = 0;
|
|
||||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||||
let lastWidth = -1;
|
let lastWidth = -1;
|
||||||
|
|
||||||
@@ -190,14 +208,13 @@ const LibraryItemsGrid = () => {
|
|||||||
const width = element.clientWidth;
|
const width = element.clientWidth;
|
||||||
if (Math.abs(width - lastWidth) < 1) return;
|
if (Math.abs(width - lastWidth) < 1) return;
|
||||||
lastWidth = width;
|
lastWidth = width;
|
||||||
setContainerWidth(width);
|
|
||||||
const minCardWidth = width < 700 ? 140 : 180;
|
const minCardWidth = width < 700 ? 140 : 180;
|
||||||
setColumns(Math.max(1, Math.floor(width / minCardWidth)));
|
const nextColumns = Math.max(1, Math.floor(width / minCardWidth));
|
||||||
// Read offsetTop after the browser has applied the new columns.
|
setContainerWidth(width);
|
||||||
frame = requestAnimationFrame(() => {
|
setColumns(nextColumns);
|
||||||
frame = 0;
|
// Read the grid offset in the same layout pass. Its top does not depend
|
||||||
setScrollMargin(element.offsetTop);
|
// on the column count, so no animation frame is needed here.
|
||||||
});
|
setScrollMargin(element.offsetTop);
|
||||||
};
|
};
|
||||||
|
|
||||||
const schedule = () => {
|
const schedule = () => {
|
||||||
@@ -213,9 +230,8 @@ const LibraryItemsGrid = () => {
|
|||||||
return () => {
|
return () => {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
if (timer) clearTimeout(timer);
|
if (timer) clearTimeout(timer);
|
||||||
if (frame) cancelAnimationFrame(frame);
|
|
||||||
};
|
};
|
||||||
}, []);
|
}, [estimateLayout]);
|
||||||
|
|
||||||
const itemCount = items.data?.Items?.length ?? 0;
|
const itemCount = items.data?.Items?.length ?? 0;
|
||||||
// Compute number of virtual rows
|
// Compute number of virtual rows
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
// Overrides for virtualized library items layout to prevent horizontal overflow
|
// Overrides for virtualized library items layout to prevent horizontal overflow
|
||||||
.library-items-container.virtualized {
|
.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;
|
box-sizing: border-box;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: block !important; // override grid from route styles
|
display: block !important; // override grid from route styles
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { secToTicks } from "@/utils/date/time";
|
import { secToTicks } from "@/utils/date/time";
|
||||||
|
import { isBlinkSession } from "@/utils/methods/blinkSessions";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
import { useAudioPlayback } from "@/utils/store/audioPlayback";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
@@ -128,6 +129,7 @@ const PlaybackSync = () => {
|
|||||||
session.Id !== master.sessionId &&
|
session.Id !== master.sessionId &&
|
||||||
session.UserId === userId &&
|
session.UserId === userId &&
|
||||||
session.DeviceId !== api.deviceInfo.id &&
|
session.DeviceId !== api.deviceInfo.id &&
|
||||||
|
isBlinkSession(session) &&
|
||||||
session.NowPlayingItem?.Id === itemId,
|
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 IconButton from "@mui/material/IconButton";
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||||
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
import React, {
|
import React, { type SyntheticEvent, useEffect, useRef, useState } from "react";
|
||||||
type SyntheticEvent,
|
|
||||||
useEffect,
|
|
||||||
useRef,
|
|
||||||
useState,
|
|
||||||
} from "react";
|
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
import { secToTicks, ticksToSec } from "@/utils/date/time";
|
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, {
|
import getImageUrlsApi, {
|
||||||
getPlayerCoverUrl,
|
getPlayerCoverUrl,
|
||||||
} from "@/utils/methods/getImageUrlsApi";
|
} from "@/utils/methods/getImageUrlsApi";
|
||||||
import { rememberAudioPlayerReturn } from "@/utils/methods/audioPlayerReturn";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import {
|
import {
|
||||||
|
setAudioPlaying,
|
||||||
setAudioRef,
|
setAudioRef,
|
||||||
setIsMuted,
|
setIsMuted,
|
||||||
useAudioPlayback,
|
useAudioPlayback,
|
||||||
@@ -66,7 +70,11 @@ const AudioPlayer = () => {
|
|||||||
const openRemoteDialog = useRemoteControlStore((s) => s.openDialog);
|
const openRemoteDialog = useRemoteControlStore((s) => s.openDialog);
|
||||||
|
|
||||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
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) => [
|
useAudioPlayback((state) => [
|
||||||
state.url,
|
state.url,
|
||||||
state.display,
|
state.display,
|
||||||
@@ -74,11 +82,54 @@ const AudioPlayer = () => {
|
|||||||
state.player.volume,
|
state.player.volume,
|
||||||
state.player.isMuted,
|
state.player.isMuted,
|
||||||
state.startTimeTicks,
|
state.startTimeTicks,
|
||||||
|
state.player.playing,
|
||||||
]);
|
]);
|
||||||
const seekAppliedRef = useRef(false);
|
const seekAppliedRef = useRef(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
seekAppliedRef.current = false;
|
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) => [
|
const [tracks, currentTrack, repeatMode] = useQueue((state) => [
|
||||||
state.tracks,
|
state.tracks,
|
||||||
@@ -88,40 +139,15 @@ const AudioPlayer = () => {
|
|||||||
|
|
||||||
const [playing, setPlaying] = useState(false);
|
const [playing, setPlaying] = useState(false);
|
||||||
const [progress, setProgress] = useState(0);
|
const [progress, setProgress] = useState(0);
|
||||||
const remoteActiveRef = useRef(false);
|
|
||||||
|
|
||||||
const sessions = useQuery({
|
const blink = useBlinkSessions();
|
||||||
queryKey: ["remoteSessions"],
|
const remoteSessions = blink.sessions;
|
||||||
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 playingRemote = remoteSessions.find(
|
const playingRemote = remoteSessions.find(
|
||||||
(session: SessionInfoDto) => session.NowPlayingItem,
|
(session: SessionInfoDto) => session.NowPlayingItem,
|
||||||
);
|
);
|
||||||
// Local playback takes precedence; otherwise follow the active remote
|
// Local playback takes precedence; otherwise follow the active remote
|
||||||
// session (the bar is a compact remote as well).
|
// session (the bar is a compact remote as well).
|
||||||
const remote = !display ? playingRemote : undefined;
|
const remote = !display ? playingRemote : undefined;
|
||||||
remoteActiveRef.current = Boolean(remote);
|
|
||||||
|
|
||||||
const activeItem: BaseItemDto | undefined | null =
|
const activeItem: BaseItemDto | undefined | null =
|
||||||
remote?.NowPlayingItem ?? item;
|
remote?.NowPlayingItem ?? item;
|
||||||
@@ -129,9 +155,7 @@ const AudioPlayer = () => {
|
|||||||
? activeItem.ArtistItems
|
? activeItem.ArtistItems
|
||||||
: (activeItem?.AlbumArtists ?? []);
|
: (activeItem?.AlbumArtists ?? []);
|
||||||
const artistNames = artists.map((artist) => artist.Name).filter(Boolean);
|
const artistNames = artists.map((artist) => artist.Name).filter(Boolean);
|
||||||
const remoteDevice = remote
|
const remoteDevice = remote ? getBlinkDeviceName(remote) : undefined;
|
||||||
? remote.DeviceName || remote.Client || "другое устройство"
|
|
||||||
: undefined;
|
|
||||||
const subtitle = remote
|
const subtitle = remote
|
||||||
? artistNames.length > 0
|
? artistNames.length > 0
|
||||||
? `${artistNames.join(", ")} · ${remoteDevice}`
|
? `${artistNames.join(", ")} · ${remoteDevice}`
|
||||||
@@ -145,9 +169,7 @@ const AudioPlayer = () => {
|
|||||||
image.src = fullCoverUrl;
|
image.src = fullCoverUrl;
|
||||||
void image.decode?.().catch(() => undefined);
|
void image.decode?.().catch(() => undefined);
|
||||||
}, [fullCoverUrl]);
|
}, [fullCoverUrl]);
|
||||||
const isPlaying = remote
|
const isPlaying = remote ? !remote.PlayState?.IsPaused : playing;
|
||||||
? !remote.PlayState?.IsPaused
|
|
||||||
: playing;
|
|
||||||
const remoteRepeat = remote?.PlayState?.RepeatMode ?? "RepeatNone";
|
const remoteRepeat = remote?.PlayState?.RepeatMode ?? "RepeatNone";
|
||||||
const remoteShuffled = remote?.PlayState?.PlaybackOrder === "Shuffle";
|
const remoteShuffled = remote?.PlayState?.PlaybackOrder === "Shuffle";
|
||||||
const remoteVolume =
|
const remoteVolume =
|
||||||
@@ -200,6 +222,20 @@ const AudioPlayer = () => {
|
|||||||
}
|
}
|
||||||
}, [display, url, tracks?.[currentTrack]?.Id, isMuted, volume]);
|
}, [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(() => {
|
useEffect(() => {
|
||||||
if (audioRef.current) {
|
if (audioRef.current) {
|
||||||
audioRef.current.volume = isMuted ? 0 : volume;
|
audioRef.current.volume = isMuted ? 0 : volume;
|
||||||
@@ -285,16 +321,41 @@ const AudioPlayer = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleTimeUpdate = (e: SyntheticEvent<HTMLAudioElement>) => {
|
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 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) {
|
if (useQueue.getState().repeatMode === "one" && audioRef.current) {
|
||||||
audioRef.current.currentTime = 0;
|
audioRef.current.currentTime = 0;
|
||||||
audioRef.current.play();
|
audioLastPositionRef.current = 0;
|
||||||
|
void audioRef.current.play();
|
||||||
|
setAudioPlaying(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setPlaying(false);
|
|
||||||
const nextIndex = getNextTrackIndex();
|
const nextIndex = getNextTrackIndex();
|
||||||
if (nextIndex !== undefined && api && user?.Id) {
|
if (nextIndex !== undefined && api && user?.Id) {
|
||||||
playItemFromQueue(nextIndex, user.Id, api);
|
playItemFromQueue(nextIndex, user.Id, api);
|
||||||
@@ -323,17 +384,42 @@ const AudioPlayer = () => {
|
|||||||
|
|
||||||
const onPlay = () => {
|
const onPlay = () => {
|
||||||
setPlaying(true);
|
setPlaying(true);
|
||||||
|
setAudioPlaying(true);
|
||||||
updatePositionState();
|
updatePositionState();
|
||||||
if (navigator.mediaSession) {
|
if (navigator.mediaSession) {
|
||||||
navigator.mediaSession.playbackState = "playing";
|
navigator.mediaSession.playbackState = "playing";
|
||||||
}
|
}
|
||||||
|
if (api && item && audioSessionRef.current) {
|
||||||
|
reportAudioProgress(
|
||||||
|
api,
|
||||||
|
item,
|
||||||
|
audioSessionRef.current,
|
||||||
|
secToTicks(audioRef.current?.currentTime ?? 0),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const onPause = () => {
|
const onPause = () => {
|
||||||
setPlaying(false);
|
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();
|
updatePositionState();
|
||||||
if (navigator.mediaSession) {
|
if (navigator.mediaSession) {
|
||||||
navigator.mediaSession.playbackState = "paused";
|
navigator.mediaSession.playbackState = "paused";
|
||||||
}
|
}
|
||||||
|
if (api && item && audioSessionRef.current) {
|
||||||
|
reportAudioProgress(
|
||||||
|
api,
|
||||||
|
item,
|
||||||
|
audioSessionRef.current,
|
||||||
|
secToTicks(audioRef.current?.currentTime ?? 0),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const remoteCommand = async (
|
const remoteCommand = async (
|
||||||
@@ -348,7 +434,7 @@ const AudioPlayer = () => {
|
|||||||
seekPositionTicks,
|
seekPositionTicks,
|
||||||
controllingUserId: user?.Id,
|
controllingUserId: user?.Id,
|
||||||
});
|
});
|
||||||
await sessions.refetch();
|
await blink.refetch();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Команда не выполнена", error);
|
console.error("Команда не выполнена", error);
|
||||||
enqueueSnackbar("Команда не выполнена", { variant: "error" });
|
enqueueSnackbar("Команда не выполнена", { variant: "error" });
|
||||||
@@ -377,7 +463,7 @@ const AudioPlayer = () => {
|
|||||||
ControllingUserId: user?.Id,
|
ControllingUserId: user?.Id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await sessions.refetch();
|
await blink.refetch();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Remote general command failed", error);
|
console.error("Remote general command failed", error);
|
||||||
enqueueSnackbar("Команда не выполнена", { variant: "error" });
|
enqueueSnackbar("Команда не выполнена", { variant: "error" });
|
||||||
@@ -409,9 +495,7 @@ const AudioPlayer = () => {
|
|||||||
const handleMute = () => {
|
const handleMute = () => {
|
||||||
if (remote) {
|
if (remote) {
|
||||||
sendGeneral(
|
sendGeneral(
|
||||||
remoteMuted
|
remoteMuted ? GeneralCommandType.Unmute : GeneralCommandType.Mute,
|
||||||
? GeneralCommandType.Unmute
|
|
||||||
: GeneralCommandType.Mute,
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
handleMuteToggle();
|
handleMuteToggle();
|
||||||
@@ -423,7 +507,6 @@ const AudioPlayer = () => {
|
|||||||
|
|
||||||
const audioElement = display ? (
|
const audioElement = display ? (
|
||||||
<audio
|
<audio
|
||||||
autoPlay
|
|
||||||
src={url}
|
src={url}
|
||||||
ref={audioRef}
|
ref={audioRef}
|
||||||
key={item?.Id ?? "noItem"}
|
key={item?.Id ?? "noItem"}
|
||||||
@@ -470,160 +553,159 @@ const AudioPlayer = () => {
|
|||||||
}
|
}
|
||||||
className="audio-player"
|
className="audio-player"
|
||||||
>
|
>
|
||||||
<div className="media-bar-left">
|
<div className="media-bar-left">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="media-bar-cover"
|
className="media-bar-cover"
|
||||||
|
onClick={handleNavigate}
|
||||||
|
aria-label="Открыть плеер"
|
||||||
|
>
|
||||||
|
{coverUrl ? (
|
||||||
|
<img src={coverUrl} alt="" />
|
||||||
|
) : (
|
||||||
|
<span className="material-symbols-rounded">music_note</span>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
<div className="media-bar-info">
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
className="media-bar-title"
|
||||||
|
title={activeItem?.Name ?? undefined}
|
||||||
onClick={handleNavigate}
|
onClick={handleNavigate}
|
||||||
aria-label="Открыть плеер"
|
|
||||||
>
|
>
|
||||||
{coverUrl ? (
|
{activeItem?.Name ?? "Неизвестно"}
|
||||||
<img src={coverUrl} alt="" />
|
</Typography>
|
||||||
) : (
|
<Typography variant="caption" noWrap className="media-bar-subtitle">
|
||||||
<span className="material-symbols-rounded">music_note</span>
|
{subtitle || "Blink"}
|
||||||
)}
|
</Typography>
|
||||||
</button>
|
|
||||||
<div className="media-bar-info">
|
|
||||||
<Typography
|
|
||||||
variant="subtitle2"
|
|
||||||
className="media-bar-title"
|
|
||||||
title={activeItem?.Name ?? undefined}
|
|
||||||
onClick={handleNavigate}
|
|
||||||
>
|
|
||||||
{activeItem?.Name ?? "Неизвестно"}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="caption" noWrap className="media-bar-subtitle">
|
|
||||||
{subtitle || "Blink"}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="media-bar-transport">
|
<div className="media-bar-transport">
|
||||||
<Tooltip title="Предыдущий">
|
<Tooltip title="Предыдущий">
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={handlePrevious}
|
onClick={handlePrevious}
|
||||||
aria-label="Предыдущий"
|
aria-label="Предыдущий"
|
||||||
className="media-bar-step"
|
className="media-bar-step"
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">skip_previous</span>
|
<span className="material-symbols-rounded">skip_previous</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip title={isPlaying ? "Пауза" : "Слушать"}>
|
<Tooltip title={isPlaying ? "Пауза" : "Слушать"}>
|
||||||
<IconButton
|
<IconButton
|
||||||
className="media-bar-play"
|
className="media-bar-play"
|
||||||
aria-label={isPlaying ? "Пауза" : "Слушать"}
|
aria-label={isPlaying ? "Пауза" : "Слушать"}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
remote
|
remote
|
||||||
? remoteCommand(PlaystateCommand.PlayPause)
|
? remoteCommand(PlaystateCommand.PlayPause)
|
||||||
: handlePlayPause()
|
: handlePlayPause()
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">
|
<span className="material-symbols-rounded">
|
||||||
{isPlaying ? "pause" : "play_arrow"}
|
{isPlaying ? "pause" : "play_arrow"}
|
||||||
</span>
|
</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip title="Следующий">
|
<Tooltip title="Следующий">
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={handleNext}
|
onClick={handleNext}
|
||||||
aria-label="Следующий"
|
aria-label="Следующий"
|
||||||
className="media-bar-step"
|
className="media-bar-step"
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">skip_next</span>
|
<span className="material-symbols-rounded">skip_next</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="media-bar-progress">
|
<div className="media-bar-progress">
|
||||||
<PlayerProgress
|
<PlayerProgress
|
||||||
layout="bare"
|
layout="bare"
|
||||||
className="media-bar-slider"
|
className="media-bar-slider"
|
||||||
progress={displayProgress}
|
progress={displayProgress}
|
||||||
duration={displayDuration}
|
duration={displayDuration}
|
||||||
onSeekCommit={remote ? handleRemoteSeek : handleSeekCommit}
|
onSeekCommit={remote ? handleRemoteSeek : handleSeekCommit}
|
||||||
|
/>
|
||||||
|
<span className="media-bar-time">
|
||||||
|
{formatPlayerTime(displayProgress)} /{" "}
|
||||||
|
{formatPlayerTime(displayDuration)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="media-bar-right">
|
||||||
|
<span className="media-bar-like">
|
||||||
|
<LikeButton
|
||||||
|
itemId={activeItem?.Id ?? undefined}
|
||||||
|
itemName={activeItem?.Name}
|
||||||
|
isFavorite={activeItem?.UserData?.IsFavorite}
|
||||||
|
queryKey={["item", activeItem?.Id ?? ""]}
|
||||||
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
<span className="media-bar-time">
|
</span>
|
||||||
{formatPlayerTime(displayProgress)} /{" "}
|
<Tooltip title="Перемешать">
|
||||||
{formatPlayerTime(displayDuration)}
|
<IconButton
|
||||||
</span>
|
onClick={handleShuffle}
|
||||||
</div>
|
aria-label="Перемешать"
|
||||||
|
className={(remote ? remoteShuffled : false) ? "active" : ""}
|
||||||
<div className="media-bar-right">
|
>
|
||||||
<span className="media-bar-like">
|
<span className="material-symbols-rounded">shuffle</span>
|
||||||
<LikeButton
|
</IconButton>
|
||||||
itemId={activeItem?.Id ?? undefined}
|
</Tooltip>
|
||||||
itemName={activeItem?.Name}
|
<Tooltip
|
||||||
isFavorite={activeItem?.UserData?.IsFavorite}
|
title={
|
||||||
queryKey={["item", activeItem?.Id ?? ""]}
|
remote
|
||||||
userId={user?.Id}
|
? remoteRepeat === "RepeatNone"
|
||||||
/>
|
? "Повтор выкл."
|
||||||
</span>
|
: remoteRepeat === "RepeatAll"
|
||||||
<Tooltip title="Перемешать">
|
? "Повтор всех"
|
||||||
<IconButton
|
: "Повтор одного"
|
||||||
onClick={handleShuffle}
|
: repeatMode === "off"
|
||||||
aria-label="Перемешать"
|
? "Повтор выкл."
|
||||||
className={(remote ? remoteShuffled : false) ? "active" : ""}
|
: repeatMode === "all"
|
||||||
>
|
? "Повтор всех"
|
||||||
<span className="material-symbols-rounded">shuffle</span>
|
: "Повтор одного"
|
||||||
</IconButton>
|
}
|
||||||
</Tooltip>
|
>
|
||||||
<Tooltip
|
<IconButton
|
||||||
title={
|
onClick={handleRepeat}
|
||||||
remote
|
aria-label="Повтор"
|
||||||
? remoteRepeat === "RepeatNone"
|
className={
|
||||||
? "Повтор выкл."
|
(remote ? remoteRepeat !== "RepeatNone" : repeatMode !== "off")
|
||||||
: remoteRepeat === "RepeatAll"
|
? "active"
|
||||||
? "Повтор всех"
|
: ""
|
||||||
: "Повтор одного"
|
|
||||||
: repeatMode === "off"
|
|
||||||
? "Повтор выкл."
|
|
||||||
: repeatMode === "all"
|
|
||||||
? "Повтор всех"
|
|
||||||
: "Повтор одного"
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<IconButton
|
<span className="material-symbols-rounded">
|
||||||
onClick={handleRepeat}
|
{(remote ? remoteRepeat === "RepeatOne" : repeatMode === "one")
|
||||||
aria-label="Повтор"
|
? "repeat_one"
|
||||||
className={
|
: "repeat"}
|
||||||
(remote ? remoteRepeat !== "RepeatNone" : repeatMode !== "off")
|
</span>
|
||||||
? "active"
|
</IconButton>
|
||||||
: ""
|
</Tooltip>
|
||||||
}
|
<Tooltip
|
||||||
>
|
title={
|
||||||
<span className="material-symbols-rounded">
|
remote
|
||||||
{(remote ? remoteRepeat === "RepeatOne" : repeatMode === "one")
|
? remoteMuted
|
||||||
? "repeat_one"
|
? "Включить звук"
|
||||||
: "repeat"}
|
: "Выключить звук"
|
||||||
</span>
|
: isMuted
|
||||||
</IconButton>
|
? "Включить звук"
|
||||||
</Tooltip>
|
: "Выключить звук"
|
||||||
<Tooltip
|
}
|
||||||
title={
|
>
|
||||||
remote
|
<IconButton onClick={handleMute} aria-label="Звук">
|
||||||
? remoteMuted
|
<span className="material-symbols-rounded">
|
||||||
? "Включить звук"
|
{remote
|
||||||
: "Выключить звук"
|
? remoteMuted || remoteVolume === 0
|
||||||
: isMuted
|
? "volume_off"
|
||||||
? "Включить звук"
|
: "volume_up"
|
||||||
: "Выключить звук"
|
: isMuted || volume === 0
|
||||||
}
|
? "volume_off"
|
||||||
>
|
: "volume_up"}
|
||||||
<IconButton onClick={handleMute} aria-label="Звук">
|
</span>
|
||||||
<span className="material-symbols-rounded">
|
</IconButton>
|
||||||
{remote
|
</Tooltip>
|
||||||
? remoteMuted || remoteVolume === 0
|
</div>
|
||||||
? "volume_off"
|
</motion.div>
|
||||||
: "volume_up"
|
|
||||||
: isMuted || volume === 0
|
|
||||||
? "volume_off"
|
|
||||||
: "volume_up"}
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</motion.div>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,30 +1,23 @@
|
|||||||
import {
|
import type { Api } from "@jellyfin/sdk";
|
||||||
PlaystateCommand,
|
import type {
|
||||||
type SessionInfoDto,
|
BaseItemDto,
|
||||||
|
SessionInfoDto,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||||
import {
|
import { Dialog, DialogContent, DialogTitle, IconButton } from "@mui/material";
|
||||||
Button,
|
import { useMutation } from "@tanstack/react-query";
|
||||||
Chip,
|
|
||||||
CircularProgress,
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogTitle,
|
|
||||||
Divider,
|
|
||||||
IconButton,
|
|
||||||
LinearProgress,
|
|
||||||
List,
|
|
||||||
ListItem,
|
|
||||||
Tooltip,
|
|
||||||
Typography,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import {
|
||||||
|
getBlinkDeviceName,
|
||||||
|
useBlinkSessions,
|
||||||
|
} from "@/utils/methods/blinkSessions";
|
||||||
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import {
|
import {
|
||||||
playOnSession,
|
playOnSession,
|
||||||
queueStartingWith,
|
queueStartingWith,
|
||||||
|
transferSessionToLocal,
|
||||||
} from "@/utils/methods/transferPlayback";
|
} from "@/utils/methods/transferPlayback";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { stopPlayback } from "@/utils/store/audioPlayback";
|
import { stopPlayback } from "@/utils/store/audioPlayback";
|
||||||
@@ -32,64 +25,30 @@ import { useCentralStore } from "@/utils/store/central";
|
|||||||
import { usePlaybackStore } from "@/utils/store/playback";
|
import { usePlaybackStore } from "@/utils/store/playback";
|
||||||
import { clearQueue } from "@/utils/store/queue";
|
import { clearQueue } from "@/utils/store/queue";
|
||||||
import useRemoteControlStore from "@/utils/store/remoteControl";
|
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 itemImage = (api: Api | undefined, item?: BaseItemDto | null) => {
|
||||||
const total = Math.max(0, Math.round((ticks ?? 0) / TICKS_PER_SECOND));
|
if (!api || !item?.Id) return undefined;
|
||||||
const h = Math.floor(total / 3600);
|
const imageItemId = item.ImageTags?.Primary
|
||||||
const m = Math.floor((total % 3600) / 60);
|
? item.Id
|
||||||
const s = total % 60;
|
: (item.SeriesId ?? item.Id);
|
||||||
return h > 0
|
return getImageUrlsApi(api).getItemImageUrlById(imageItemId, "Primary", {
|
||||||
? `${h}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`
|
fillHeight: 144,
|
||||||
: `${m}:${String(s).padStart(2, "0")}`;
|
fillWidth: 96,
|
||||||
|
quality: 82,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const sessionLabel = (session: SessionInfoDto) =>
|
|
||||||
session.DeviceName || session.Client || session.DeviceId || "Неизвестное устройство";
|
|
||||||
|
|
||||||
const RemoteControlDialog = () => {
|
const RemoteControlDialog = () => {
|
||||||
const { open, transfer, closeDialog } = useRemoteControlStore();
|
const { open, transfer, closeDialog } = useRemoteControlStore();
|
||||||
const item = transfer?.item;
|
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const blink = useBlinkSessions(Boolean(open));
|
||||||
const sessions = useQuery({
|
const item = transfer?.item ?? null;
|
||||||
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 playOn = useMutation({
|
const playOn = useMutation({
|
||||||
mutationFn: async (session: SessionInfoDto) => {
|
mutationFn: async (session: SessionInfoDto) => {
|
||||||
@@ -103,20 +62,15 @@ const RemoteControlDialog = () => {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
onSuccess: async (_data, session) => {
|
onSuccess: async (_data, session) => {
|
||||||
enqueueSnackbar(
|
enqueueSnackbar(`Передано на ${getBlinkDeviceName(session)}`, {
|
||||||
transfer?.kind === "audio" || transfer?.kind === "video"
|
variant: "success",
|
||||||
? `Воспроизведение перенесено на ${sessionLabel(session)}`
|
});
|
||||||
: `Воспроизведение на ${sessionLabel(session)}`,
|
|
||||||
{ variant: "success" },
|
|
||||||
);
|
|
||||||
if (transfer?.kind === "audio") {
|
if (transfer?.kind === "audio") {
|
||||||
stopPlayback();
|
stopPlayback();
|
||||||
} else if (transfer?.kind === "video") {
|
} else if (transfer?.kind === "video") {
|
||||||
const playback = usePlaybackStore.getState();
|
const playback = usePlaybackStore.getState();
|
||||||
const transferredItemId = playback.metadata.item?.Id;
|
const transferredItemId = playback.metadata.item?.Id;
|
||||||
const stoppedPosition = playback.playerState.currentTime;
|
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
|
document
|
||||||
.querySelector("hls-video")
|
.querySelector("hls-video")
|
||||||
@@ -137,7 +91,10 @@ const RemoteControlDialog = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} 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
|
const takeHere = useMutation({
|
||||||
// even though they accept playstate commands, so do not hide them.
|
mutationFn: async (session: SessionInfoDto) => {
|
||||||
const remoteSessions = (sessions.data ?? []).filter(
|
if (!api || !user?.Id) return "none";
|
||||||
(session) =>
|
return transferSessionToLocal(api, user.Id, session);
|
||||||
session.Id &&
|
},
|
||||||
session.DeviceId !== api?.deviceInfo.id &&
|
onSuccess: async (kind, session) => {
|
||||||
session.UserId === user?.Id,
|
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 seek = (session: SessionInfoDto, offsetSeconds: number) => {
|
const previewUrl = itemImage(api, item);
|
||||||
const current = (session.PlayState?.PositionTicks ?? 0) / TICKS_PER_SECOND;
|
const activeSessions = blink.sessions;
|
||||||
const next = Math.max(0, current + offsetSeconds);
|
|
||||||
sendCommand.mutate({
|
|
||||||
session,
|
|
||||||
command: PlaystateCommand.Seek,
|
|
||||||
seekPositionTicks: Math.round(next * TICKS_PER_SECOND),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
open={open}
|
open={open}
|
||||||
onClose={closeDialog}
|
onClose={closeDialog}
|
||||||
fullWidth
|
fullWidth
|
||||||
maxWidth="sm"
|
maxWidth="md"
|
||||||
slotProps={{
|
slotProps={{
|
||||||
paper: {
|
paper: {
|
||||||
className: "glass-dialog-paper",
|
className: "glass-dialog-paper remote-control-dialog",
|
||||||
sx: { borderRadius: 3 },
|
sx: { borderRadius: "24px" },
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DialogTitle sx={{ display: "flex", alignItems: "center", gap: 1 }}>
|
<DialogTitle className="remote-control-title">
|
||||||
<span className="material-symbols-rounded">cast</span>
|
<div className="remote-control-heading">
|
||||||
<span style={{ flex: 1 }}>
|
<span className="material-symbols-rounded">cast</span>
|
||||||
{item ? `Воспроизвести «${item.Name}» на…` : "Удалённое управление"}
|
<div className="remote-control-heading-copy">
|
||||||
</span>
|
<span>{item ? "Передать медиа" : "Устройства Blink"}</span>
|
||||||
<IconButton onClick={closeDialog} aria-label="Закрыть">
|
<small>
|
||||||
<span className="material-symbols-rounded">close</span>
|
{activeSessions.length} Blink
|
||||||
</IconButton>
|
{activeSessions.length === 1 ? " устройство" : " устройств"}
|
||||||
</DialogTitle>
|
</small>
|
||||||
<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>
|
</div>
|
||||||
) : remoteSessions.length === 0 ? (
|
</div>
|
||||||
<Typography sx={{ opacity: 0.7, py: 2 }}>
|
<div className="remote-control-title-actions">
|
||||||
Нет доступных устройств. Откройте клиент Jellyfin (например, на ТВ)
|
<span className="remote-control-only-badge">Только Blink</span>
|
||||||
и разрешите удалённое управление.
|
<IconButton
|
||||||
</Typography>
|
onClick={() => blink.refetch()}
|
||||||
) : (
|
aria-label="Обновить устройства"
|
||||||
<List disablePadding>
|
title="Обновить устройства"
|
||||||
{remoteSessions.map((session) => {
|
>
|
||||||
const nowPlaying = session.NowPlayingItem;
|
<span className="material-symbols-rounded">refresh</span>
|
||||||
const playState = session.PlayState;
|
</IconButton>
|
||||||
const duration = nowPlaying?.RunTimeTicks ?? 0;
|
<IconButton onClick={closeDialog} aria-label="Закрыть">
|
||||||
const position = playState?.PositionTicks ?? 0;
|
<span className="material-symbols-rounded">close</span>
|
||||||
const supportsControl = true;
|
</IconButton>
|
||||||
return (
|
</div>
|
||||||
<React.Fragment key={session.Id}>
|
</DialogTitle>
|
||||||
<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 ? (
|
<DialogContent className="remote-control-content">
|
||||||
<>
|
{item && (
|
||||||
<Typography variant="body2" noWrap>
|
<div className="remote-control-current">
|
||||||
{nowPlaying.Name}
|
<div className="remote-control-current-poster">
|
||||||
{nowPlaying.Genres?.length ? (
|
{previewUrl ? (
|
||||||
<Chip
|
<img src={previewUrl} alt="" />
|
||||||
component="span"
|
) : (
|
||||||
size="small"
|
<span className="material-symbols-rounded">movie</span>
|
||||||
label={nowPlaying.Genres[0]}
|
)}
|
||||||
sx={{ ml: 1 }}
|
</div>
|
||||||
/>
|
<div className="remote-control-current-copy">
|
||||||
) : null}
|
<span>Сейчас на этом устройстве</span>
|
||||||
</Typography>
|
<strong>{item.SeriesName ?? item.Name ?? "Медиа"}</strong>
|
||||||
<LinearProgress
|
<small>
|
||||||
variant="determinate"
|
{typeof transfer?.positionTicks === "number"
|
||||||
value={
|
? `с ${Math.floor(transfer.positionTicks / 10_000_000 / 60)} мин`
|
||||||
duration > 0
|
: "Передача текущей позиции"}
|
||||||
? Math.min(100, (position / duration) * 100)
|
</small>
|
||||||
: 0
|
</div>
|
||||||
}
|
</div>
|
||||||
sx={{ borderRadius: 1 }}
|
)}
|
||||||
/>
|
|
||||||
<div
|
{blink.isLoading ? (
|
||||||
style={{
|
<div className="remote-control-loading">
|
||||||
display: "flex",
|
<span className="material-symbols-rounded animate-rotate">
|
||||||
alignItems: "center",
|
progress_activity
|
||||||
justifyContent: "space-between",
|
</span>
|
||||||
}}
|
<span>Ищем Blink-устройства…</span>
|
||||||
>
|
</div>
|
||||||
<Typography variant="caption" sx={{ opacity: 0.6 }}>
|
) : activeSessions.length === 0 ? (
|
||||||
{formatTime(position)} / {formatTime(duration)}
|
<div className="remote-control-empty">
|
||||||
{playState?.IsPaused ? " · пауза" : ""}
|
<span className="material-symbols-rounded">devices_other</span>
|
||||||
</Typography>
|
<h3>Других Blink-устройств нет</h3>
|
||||||
<div style={{ display: "flex" }}>
|
<p>
|
||||||
<Tooltip title="Назад на 10 с">
|
Запустите Blink на другом устройстве под этим пользователем. В
|
||||||
<span>
|
списке появятся только клиенты Blink — Jellyfin Web, телевизоры и
|
||||||
<IconButton
|
другие приложения сюда не попадают.
|
||||||
size="small"
|
</p>
|
||||||
disabled={!supportsControl || playState?.CanSeek === false}
|
</div>
|
||||||
onClick={() => seek(session, -10)}
|
) : (
|
||||||
>
|
<div className="remote-session-grid">
|
||||||
<span className="material-symbols-rounded">
|
{activeSessions.map((session) => (
|
||||||
replay_10
|
<SessionCard
|
||||||
</span>
|
key={session.Id}
|
||||||
</IconButton>
|
session={session}
|
||||||
</span>
|
api={api}
|
||||||
</Tooltip>
|
transfer={transfer}
|
||||||
<Tooltip title="Предыдущий">
|
onSend={item ? (target) => playOn.mutate(target) : undefined}
|
||||||
<span>
|
onTake={(target) => takeHere.mutate(target)}
|
||||||
<IconButton
|
onOpenRemote={(target) => {
|
||||||
size="small"
|
closeDialog();
|
||||||
disabled={!supportsControl}
|
navigate({
|
||||||
onClick={() =>
|
to: "/remote",
|
||||||
sendCommand.mutate({
|
search: { device: target.Id ?? "" },
|
||||||
session,
|
});
|
||||||
command: PlaystateCommand.PreviousTrack,
|
}}
|
||||||
})
|
sending={
|
||||||
}
|
playOn.isPending && playOn.variables?.Id === session.Id
|
||||||
>
|
}
|
||||||
<span className="material-symbols-rounded">
|
taking={
|
||||||
skip_previous
|
takeHere.isPending && takeHere.variables?.Id === session.Id
|
||||||
</span>
|
}
|
||||||
</IconButton>
|
/>
|
||||||
</span>
|
))}
|
||||||
</Tooltip>
|
</div>
|
||||||
<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>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Typography variant="caption" sx={{ opacity: 0.6 }}>
|
|
||||||
Свободно
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</ListItem>
|
|
||||||
<Divider />
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</List>
|
|
||||||
)}
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</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,37 +1,73 @@
|
|||||||
import { Skeleton } from "@mui/material";
|
import { Skeleton } from "@mui/material";
|
||||||
import React from "react";
|
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 (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
width: "100%",
|
|
||||||
overflow: "visible",
|
|
||||||
flexWrap: "wrap",
|
flexWrap: "wrap",
|
||||||
alignItems: "center",
|
gap,
|
||||||
justifyContent: "center",
|
width: "100%",
|
||||||
|
alignItems: "flex-start",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Array.from(new Array(18)).map((_, index) => (
|
{placeholders.map((placeholder) => (
|
||||||
<Skeleton
|
<div
|
||||||
key={index}
|
key={placeholder.id}
|
||||||
variant="rounded"
|
style={{ width: cardWidth, flex: "0 0 auto", minWidth: 0 }}
|
||||||
sx={{
|
>
|
||||||
flexBasis: 185,
|
<Skeleton
|
||||||
height: "auto",
|
variant="rounded"
|
||||||
aspectRatio: 0.6666,
|
sx={{
|
||||||
// background: "red",
|
width: "100%",
|
||||||
marginRight: "1.5em",
|
height: "auto",
|
||||||
marginBottom: "1.5em",
|
aspectRatio: square ? 1 : 0.6666,
|
||||||
flexShrink: 1,
|
borderRadius: "10px",
|
||||||
flexGrow: 0,
|
}}
|
||||||
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>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default LibraryItemsSkeleton;
|
export default LibraryItemsSkeleton;
|
||||||
@@ -64,7 +64,9 @@ const getCandidates = (): HTMLElement[] => {
|
|||||||
.filter((element) => element !== scope)
|
.filter((element) => element !== scope)
|
||||||
.filter((element) => !element.closest("[data-tv-ignore]"))
|
.filter((element) => !element.closest("[data-tv-ignore]"))
|
||||||
.filter(isVisible)
|
.filter(isVisible)
|
||||||
.filter((element) => element.tabIndex >= 0 || element.hasAttribute("tabindex"));
|
.filter(
|
||||||
|
(element) => element.tabIndex >= 0 || element.hasAttribute("tabindex"),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearTvFocus = () => {
|
const clearTvFocus = () => {
|
||||||
@@ -102,7 +104,7 @@ const moveFocus = (direction: Direction) => {
|
|||||||
const contentCandidates = candidates.filter(
|
const contentCandidates = candidates.filter(
|
||||||
(element) =>
|
(element) =>
|
||||||
!element.closest(
|
!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;
|
const pool = contentCandidates.length > 0 ? contentCandidates : candidates;
|
||||||
@@ -220,10 +222,14 @@ const SpatialNavigation = () => {
|
|||||||
const previousButtons = useRef<boolean[]>([]);
|
const previousButtons = useRef<boolean[]>([]);
|
||||||
|
|
||||||
const onKeyDown = useCallback((event: KeyboardEvent) => {
|
const onKeyDown = useCallback((event: KeyboardEvent) => {
|
||||||
if (event.defaultPrevented || event.altKey || event.metaKey || event.ctrlKey)
|
if (
|
||||||
|
event.defaultPrevented ||
|
||||||
|
event.altKey ||
|
||||||
|
event.metaKey ||
|
||||||
|
event.ctrlKey
|
||||||
|
)
|
||||||
return;
|
return;
|
||||||
const target =
|
const target = event.target instanceof HTMLElement ? event.target : null;
|
||||||
event.target instanceof HTMLElement ? event.target : null;
|
|
||||||
if (
|
if (
|
||||||
target?.closest(
|
target?.closest(
|
||||||
"input, textarea, select, [contenteditable='true'], [role='slider'], .MuiSlider-root",
|
"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 React, { useEffect } from "react";
|
||||||
import { getLocalPlayback } from "@/utils/methods/localPlayback";
|
import { getLocalPlayback } from "@/utils/methods/localPlayback";
|
||||||
import {
|
import {
|
||||||
|
enforceSyncPlayLocalState,
|
||||||
|
getCurrentGroupItemId,
|
||||||
|
getExpectedSyncPlayPosition,
|
||||||
|
isSyncPlayWaitingForStart,
|
||||||
|
joinBlinkAutoGroupIfAvailable,
|
||||||
|
parkLocalPlaybackForSync,
|
||||||
pingSyncPlayGroup,
|
pingSyncPlayGroup,
|
||||||
|
refreshSyncPlayGroup,
|
||||||
reportSyncPlayReady,
|
reportSyncPlayReady,
|
||||||
|
syncPlayIgnoreWaitIfNeeded,
|
||||||
} from "@/utils/methods/syncPlay";
|
} from "@/utils/methods/syncPlay";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
@@ -19,6 +27,7 @@ const SyncPlayController = () => {
|
|||||||
);
|
);
|
||||||
const group = useSyncPlayStore((state) => state.group);
|
const group = useSyncPlayStore((state) => state.group);
|
||||||
const queue = useSyncPlayStore((state) => state.queue);
|
const queue = useSyncPlayStore((state) => state.queue);
|
||||||
|
const autoJoin = useSyncPlayStore((state) => state.autoJoin);
|
||||||
const api = useApiInContext((state) => state.api);
|
const api = useApiInContext((state) => state.api);
|
||||||
const user = useCentralStore((state) => state.currentUser);
|
const user = useCentralStore((state) => state.currentUser);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -31,6 +40,55 @@ const SyncPlayController = () => {
|
|||||||
});
|
});
|
||||||
}, [pendingNavigation, setPendingNavigation, navigate]);
|
}, [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.
|
// SyncPlay uses pings to estimate latency and schedule unpause commands.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!api || !group?.GroupId) return;
|
if (!api || !group?.GroupId) return;
|
||||||
@@ -41,20 +99,28 @@ const SyncPlayController = () => {
|
|||||||
return () => window.clearInterval(timer);
|
return () => window.clearInterval(timer);
|
||||||
}, [api, group?.GroupId]);
|
}, [api, group?.GroupId]);
|
||||||
|
|
||||||
// While a group is waiting, keep telling the server this player is ready.
|
// While a group waits for a freshly set queue, park this client exactly at
|
||||||
// Some clients miss the one-shot Ready after a queue update; retrying is
|
// the queue position and report ready. The server only accepts a ready
|
||||||
// harmless and lets the server release the group as soon as it can.
|
// 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(() => {
|
useEffect(() => {
|
||||||
if (!api || !user?.Id || !group || group.State !== "Waiting") return;
|
if (!api || !group || group.State !== "Waiting") return;
|
||||||
if (!queue?.Playlist?.length) return;
|
if (!queue?.Playlist?.length) return;
|
||||||
const send = () => {
|
const send = () => {
|
||||||
const local = getLocalPlayback();
|
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);
|
reportSyncPlayReady(api, local.positionTicks, !local.paused);
|
||||||
};
|
};
|
||||||
send();
|
send();
|
||||||
const timer = window.setInterval(send, 2000);
|
const timer = window.setInterval(send, 1000);
|
||||||
return () => window.clearInterval(timer);
|
return () => window.clearInterval(timer);
|
||||||
}, [api, user?.Id, group?.GroupId, group?.State, queue]);
|
}, [api, group?.GroupId, group?.State, queue]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|||||||
+228
-108
@@ -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 { getSyncPlayApi } from "@jellyfin/sdk/lib/utils/api/sync-play-api";
|
||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
Box,
|
|
||||||
Button,
|
Button,
|
||||||
Chip,
|
Chip,
|
||||||
CircularProgress,
|
CircularProgress,
|
||||||
@@ -11,19 +10,30 @@ import {
|
|||||||
DialogContent,
|
DialogContent,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
Divider,
|
Divider,
|
||||||
List,
|
FormControlLabel,
|
||||||
ListItem,
|
|
||||||
ListItemText,
|
|
||||||
Stack,
|
Stack,
|
||||||
|
Switch,
|
||||||
TextField,
|
TextField,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { motion } from "motion/react";
|
||||||
import React, { useEffect, useMemo, useState } from "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 getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import {
|
import {
|
||||||
closeSyncPlayDialog,
|
closeSyncPlayDialog,
|
||||||
createSyncPlayGroup,
|
createSyncPlayGroup,
|
||||||
|
ensureBlinkAutoGroup,
|
||||||
joinSyncPlayGroup,
|
joinSyncPlayGroup,
|
||||||
leaveSyncPlayGroup,
|
leaveSyncPlayGroup,
|
||||||
pauseSyncPlayGroup,
|
pauseSyncPlayGroup,
|
||||||
@@ -37,6 +47,8 @@ import { useCentralStore } from "@/utils/store/central";
|
|||||||
import useQueue from "@/utils/store/queue";
|
import useQueue from "@/utils/store/queue";
|
||||||
import useSyncPlayStore from "@/utils/store/syncPlay";
|
import useSyncPlayStore from "@/utils/store/syncPlay";
|
||||||
|
|
||||||
|
import "./syncPlay.scss";
|
||||||
|
|
||||||
const stateLabel = (state?: string) => {
|
const stateLabel = (state?: string) => {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case "Waiting":
|
case "Waiting":
|
||||||
@@ -59,16 +71,23 @@ const SyncPlayDialog = () => {
|
|||||||
const queue = useSyncPlayStore((state) => state.queue);
|
const queue = useSyncPlayStore((state) => state.queue);
|
||||||
const loading = useSyncPlayStore((state) => state.loading);
|
const loading = useSyncPlayStore((state) => state.loading);
|
||||||
const error = useSyncPlayStore((state) => state.error);
|
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 localQueue = useQueue((state) => state.tracks ?? []);
|
||||||
const [groupName, setGroupName] = useState("");
|
const [groupName, setGroupName] = useState("");
|
||||||
const setGroups = useSyncPlayStore((state) => state.setGroups);
|
const setGroups = useSyncPlayStore((state) => state.setGroups);
|
||||||
const setGroup = useSyncPlayStore((state) => state.setGroup);
|
const setGroup = useSyncPlayStore((state) => state.setGroup);
|
||||||
|
const setAutoJoin = useSyncPlayStore((state) => state.setAutoJoin);
|
||||||
|
const blink = useBlinkSessions(open);
|
||||||
|
const selfName = getDeviceDisplayName(getOrCreateDeviceId());
|
||||||
|
|
||||||
const groupsQuery = useQuery({
|
const groupsQuery = useQuery({
|
||||||
queryKey: ["syncPlayGroups", open],
|
queryKey: ["syncPlayGroups", open],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api) return [];
|
if (!api) return [];
|
||||||
return (await getSyncPlayApi(api).syncPlayGetGroups()).data ?? [];
|
return (
|
||||||
|
(await getSyncPlayApi(api).syncPlayGetGroups()).data ?? []
|
||||||
|
).filter(isBlinkGroup);
|
||||||
},
|
},
|
||||||
enabled: open && Boolean(api),
|
enabled: open && Boolean(api),
|
||||||
refetchInterval: open && !group ? 3000 : false,
|
refetchInterval: open && !group ? 3000 : false,
|
||||||
@@ -135,7 +154,13 @@ const SyncPlayDialog = () => {
|
|||||||
if (created) setGroupName("");
|
if (created) setGroupName("");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAutoGroup = async (shareQueue: boolean) => {
|
||||||
|
if (!api) return;
|
||||||
|
await ensureBlinkAutoGroup(api, { shareQueue });
|
||||||
|
};
|
||||||
|
|
||||||
const handleClose = () => closeSyncPlayDialog();
|
const handleClose = () => closeSyncPlayDialog();
|
||||||
|
const onlineDevices = blink.sessions;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
@@ -144,90 +169,112 @@ const SyncPlayDialog = () => {
|
|||||||
fullWidth
|
fullWidth
|
||||||
maxWidth="sm"
|
maxWidth="sm"
|
||||||
slotProps={{
|
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">
|
||||||
<span className="material-symbols-rounded">groups</span>
|
<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>
|
</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent className="syncplay-content">
|
||||||
{error && (
|
{error && (
|
||||||
<Alert severity="warning" sx={{ mb: 2 }}>
|
<Alert severity="warning" sx={{ mb: 1.5, borderRadius: "14px" }}>
|
||||||
{error}
|
{error}
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{group ? (
|
{group ? (
|
||||||
<Stack spacing={2}>
|
<Stack spacing={1.5}>
|
||||||
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
|
<div className="syncplay-card syncplay-group-head">
|
||||||
<Typography variant="h6" sx={{ flex: 1 }} noWrap>
|
<div className="syncplay-group-copy">
|
||||||
{group.GroupName || "Группа SyncPlay"}
|
<span className="syncplay-eyebrow">Группа Blink</span>
|
||||||
</Typography>
|
<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
|
<Chip
|
||||||
size="small"
|
size="small"
|
||||||
label={stateLabel(group.State)}
|
label={stateLabel(group.State)}
|
||||||
color={group.State === "Playing" ? "success" : "default"}
|
color={group.State === "Playing" ? "success" : "default"}
|
||||||
variant={group.State === "Playing" ? "filled" : "outlined"}
|
variant={group.State === "Playing" ? "filled" : "outlined"}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</div>
|
||||||
<Typography variant="body2" sx={{ opacity: 0.65 }}>
|
|
||||||
{group.Participants?.length
|
<div className="syncplay-card">
|
||||||
? `${group.Participants.length} device${
|
<div className="syncplay-card-title">
|
||||||
group.Participants.length === 1 ? "" : "s"
|
<span className="material-symbols-rounded">devices</span>
|
||||||
} connected: ${group.Participants.join(", ")}`
|
<span>Blink-устройства</span>
|
||||||
: "Это первое устройство в группе."}
|
</div>
|
||||||
</Typography>
|
<div className="syncplay-device-chips">
|
||||||
<Divider />
|
<span className="syncplay-device-chip is-self">
|
||||||
<Box sx={{ display: "flex", gap: 2, alignItems: "center" }}>
|
<span className="syncplay-device-dot" />
|
||||||
|
{selfName} · это устройство
|
||||||
|
</span>
|
||||||
|
{onlineDevices.map((session) => (
|
||||||
|
<span
|
||||||
|
key={session.Id}
|
||||||
|
className="syncplay-device-chip"
|
||||||
|
title={getBlinkDeviceName(session)}
|
||||||
|
>
|
||||||
|
<span className="syncplay-device-dot" />
|
||||||
|
{getBlinkDeviceName(session)}
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
{onlineDevices.length === 0 && (
|
||||||
|
<span className="syncplay-muted">
|
||||||
|
Других Blink-устройств сейчас нет.
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<Typography variant="caption" className="syncplay-note">
|
||||||
|
Jellyfin считает участников по пользователям, поэтому список
|
||||||
|
устройств собран из сессий Blink.
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="syncplay-card syncplay-queue-card">
|
||||||
{imageUrl ? (
|
{imageUrl ? (
|
||||||
<Box
|
<img className="syncplay-queue-poster" src={imageUrl} alt="" />
|
||||||
component="img"
|
|
||||||
src={imageUrl}
|
|
||||||
alt=""
|
|
||||||
sx={{
|
|
||||||
width: 64,
|
|
||||||
height: 96,
|
|
||||||
objectFit: "cover",
|
|
||||||
borderRadius: "10px",
|
|
||||||
flex: "0 0 auto",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<Box
|
<div className="syncplay-queue-poster is-empty">
|
||||||
sx={{
|
|
||||||
width: 64,
|
|
||||||
height: 96,
|
|
||||||
borderRadius: "10px",
|
|
||||||
background: "rgba(255,255,255,0.07)",
|
|
||||||
display: "grid",
|
|
||||||
placeItems: "center",
|
|
||||||
flex: "0 0 auto",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">movie</span>
|
<span className="material-symbols-rounded">movie</span>
|
||||||
</Box>
|
</div>
|
||||||
)}
|
)}
|
||||||
<Box sx={{ minWidth: 0 }}>
|
<div className="syncplay-queue-copy">
|
||||||
<Typography variant="overline" sx={{ opacity: 0.6 }}>
|
<span className="syncplay-eyebrow">Очередь группы</span>
|
||||||
Очередь группы
|
<strong>
|
||||||
</Typography>
|
|
||||||
<Typography variant="subtitle1" noWrap>
|
|
||||||
{currentItem.data?.Name ??
|
{currentItem.data?.Name ??
|
||||||
(queueItemIds.length
|
(queueItemIds.length ? "Загрузка…" : "Очередь пока пуста")}
|
||||||
? "Загрузка…"
|
</strong>
|
||||||
: "Очередь пока пуста")}
|
<small>
|
||||||
</Typography>
|
|
||||||
<Typography variant="caption" sx={{ opacity: 0.65 }}>
|
|
||||||
{queueItemIds.length
|
{queueItemIds.length
|
||||||
? `${queueItemIds.length} item${
|
? `${queueItemIds.length} элементов · сейчас ${
|
||||||
queueItemIds.length === 1 ? "" : "s"
|
currentQueueIndex + 1
|
||||||
} · item ${currentQueueIndex + 1}`
|
}`
|
||||||
: "Запустите очередь на устройстве, которое будет ведущим."}
|
: "Запустите очередь на ведущем устройстве."}
|
||||||
</Typography>
|
</small>
|
||||||
</Box>
|
</div>
|
||||||
</Box>
|
</div>
|
||||||
<Divider />
|
|
||||||
<Box sx={{ display: "flex", gap: 1, flexWrap: "wrap" }}>
|
<div className="syncplay-actions">
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
disabled={loading || localQueue.length === 0 || !user?.Id}
|
disabled={loading || localQueue.length === 0 || !user?.Id}
|
||||||
@@ -260,7 +307,9 @@ const SyncPlayDialog = () => {
|
|||||||
: resumeSyncPlayGroup(api))
|
: resumeSyncPlayGroup(api))
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{group.State === "Playing" ? "Пауза у всех" : "Воспроизвести у всех"}
|
{group.State === "Playing"
|
||||||
|
? "Пауза у всех"
|
||||||
|
: "Воспроизвести у всех"}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
color="error"
|
color="error"
|
||||||
@@ -269,16 +318,85 @@ const SyncPlayDialog = () => {
|
|||||||
>
|
>
|
||||||
Покинуть группу
|
Покинуть группу
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</div>
|
||||||
{loading && <CircularProgress size={20} />}
|
{loading && <CircularProgress size={20} />}
|
||||||
</Stack>
|
</Stack>
|
||||||
) : (
|
) : (
|
||||||
<Stack spacing={2}>
|
<Stack spacing={1.5}>
|
||||||
<Typography variant="body2" sx={{ opacity: 0.75 }}>
|
<div className="syncplay-hero">
|
||||||
Создайте группу и запустите текущую очередь или войдите в
|
<div className="syncplay-hero-icon">
|
||||||
группу, созданную на другом устройстве. Все устройства следуют
|
<span className="material-symbols-rounded">bolt</span>
|
||||||
одному таймлайну.
|
</div>
|
||||||
</Typography>
|
<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}>
|
<Stack direction="row" spacing={1}>
|
||||||
<TextField
|
<TextField
|
||||||
size="small"
|
size="small"
|
||||||
@@ -295,51 +413,53 @@ const SyncPlayDialog = () => {
|
|||||||
variant="contained"
|
variant="contained"
|
||||||
disabled={loading || !api}
|
disabled={loading || !api}
|
||||||
onClick={handleCreate}
|
onClick={handleCreate}
|
||||||
sx={{ flex: "0 0 auto" }}
|
|
||||||
>
|
>
|
||||||
Создать
|
Создать
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Divider />
|
|
||||||
<Typography variant="overline" sx={{ opacity: 0.65 }}>
|
<Typography variant="overline" className="syncplay-list-label">
|
||||||
Доступные группы
|
Группы Blink
|
||||||
</Typography>
|
</Typography>
|
||||||
{groupsQuery.isPending ? (
|
{groupsQuery.isPending ? (
|
||||||
<CircularProgress size={20} />
|
<CircularProgress size={20} />
|
||||||
) : groups.length === 0 ? (
|
) : groups.length === 0 ? (
|
||||||
<Typography variant="body2" sx={{ opacity: 0.6 }}>
|
<Typography variant="body2" className="syncplay-muted">
|
||||||
Групп пока нет. Создайте выше.
|
Групп пока нет. Соберите автогруппу или создайте свою.
|
||||||
</Typography>
|
</Typography>
|
||||||
) : (
|
) : (
|
||||||
<List dense disablePadding>
|
<Stack spacing={0.7}>
|
||||||
{groups.map((entry) => (
|
{groups.map((entry) => (
|
||||||
<ListItem
|
<motion.div
|
||||||
key={entry.GroupId}
|
key={entry.GroupId}
|
||||||
divider
|
layout
|
||||||
secondaryAction={
|
initial={{ opacity: 0, y: 6 }}
|
||||||
<Button
|
animate={{ opacity: 1, y: 0 }}
|
||||||
size="small"
|
className="syncplay-group-row"
|
||||||
variant="outlined"
|
|
||||||
disabled={loading}
|
|
||||||
onClick={() => {
|
|
||||||
if (api && entry.GroupId) {
|
|
||||||
void joinSyncPlayGroup(api, entry.GroupId);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Войти
|
|
||||||
</Button>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<ListItemText
|
<div className="syncplay-group-row-copy">
|
||||||
primary={entry.GroupName || "Смотреть вместе"}
|
<strong>{getBlinkGroupLabel(entry)}</strong>
|
||||||
secondary={`${stateLabel(entry.State)} · ${
|
<small>
|
||||||
entry.Participants?.length ?? 0
|
{stateLabel(entry.State)} ·{" "}
|
||||||
} device${(entry.Participants?.length ?? 0) === 1 ? "" : "s"}`}
|
{entry.Participants?.length ?? 0} пользовател
|
||||||
/>
|
{(entry.Participants?.length ?? 0) === 1 ? "ь" : "я"}
|
||||||
</ListItem>
|
</small>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
disabled={loading}
|
||||||
|
onClick={() => {
|
||||||
|
if (api && entry.GroupId) {
|
||||||
|
void joinSyncPlayGroup(api, entry.GroupId);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Войти
|
||||||
|
</Button>
|
||||||
|
</motion.div>
|
||||||
))}
|
))}
|
||||||
</List>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
</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,
|
useMemo,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
|
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
||||||
import { delUser } from "@/utils/storage/user";
|
import { delUser } from "@/utils/storage/user";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { useQuickConnectApprovalStore } from "@/utils/store/quickConnectApproval";
|
import { useQuickConnectApprovalStore } from "@/utils/store/quickConnectApproval";
|
||||||
|
|
||||||
|
import "./userAvatarMenu.scss";
|
||||||
|
|
||||||
|
const isAndroidDevice = /Android/i.test(navigator.userAgent);
|
||||||
|
|
||||||
export const UserAvatarMenu = () => {
|
export const UserAvatarMenu = () => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const createApi = useApiInContext((s) => s.createApi);
|
const createApi = useApiInContext((s) => s.createApi);
|
||||||
@@ -70,18 +75,18 @@ export const UserAvatarMenu = () => {
|
|||||||
>
|
>
|
||||||
{!!user?.Id &&
|
{!!user?.Id &&
|
||||||
(user?.PrimaryImageTag === undefined ? (
|
(user?.PrimaryImageTag === undefined ? (
|
||||||
<Avatar className="appBar-avatar" alt={user?.Name ?? "image"}>
|
<Avatar className="user-avatar" alt={user?.Name ?? "image"}>
|
||||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
<span className="material-symbols-rounded user-avatar-icon">
|
||||||
account_circle
|
account_circle
|
||||||
</span>
|
</span>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
) : (
|
) : (
|
||||||
<Avatar
|
<Avatar
|
||||||
className="appBar-avatar"
|
className="user-avatar"
|
||||||
src={`${api?.basePath}/Users/${user?.Id}/Images/Primary`}
|
src={`${api?.basePath}/Users/${user?.Id}/Images/Primary`}
|
||||||
alt={user?.Name ?? "image"}
|
alt={user?.Name ?? "image"}
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
<span className="material-symbols-rounded user-avatar-icon">
|
||||||
account_circle
|
account_circle
|
||||||
</span>
|
</span>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
@@ -97,29 +102,51 @@ export const UserAvatarMenu = () => {
|
|||||||
>
|
>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleLogout();
|
openSyncPlayDialog();
|
||||||
handleMenuClose();
|
handleMenuClose();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<span className="material-symbols-rounded">logout</span>
|
<span className="material-symbols-rounded">groups</span>
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
Выйти
|
Смотреть вместе
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<Divider />
|
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
useQuickConnectApprovalStore
|
navigate({ to: "/remote" });
|
||||||
.getState()
|
|
||||||
.openQuickConnectApproval();
|
|
||||||
handleMenuClose();
|
handleMenuClose();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<span className="material-symbols-rounded">qr_code_2</span>
|
<span className="material-symbols-rounded">settings_remote</span>
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
Подтвердить вход на устройство
|
Пульт
|
||||||
</MenuItem>
|
</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
|
<MenuItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigate({ to: "/settings/preferences" });
|
navigate({ to: "/settings/preferences" });
|
||||||
@@ -142,6 +169,30 @@ export const UserAvatarMenu = () => {
|
|||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
О приложении
|
О приложении
|
||||||
</MenuItem>
|
</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>
|
</Menu>
|
||||||
</div>
|
</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 { useLocation } from "@tanstack/react-router";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { shouldShowAppBar } from "@/components/appBar/appBar";
|
import { shouldShowTitlebar } from "@/components/appTitlebar/routeVisibility";
|
||||||
import WindowControls from ".";
|
import WindowControls from ".";
|
||||||
|
|
||||||
import "./windowControls.scss";
|
import "./windowControls.scss";
|
||||||
@@ -9,28 +9,15 @@ const isMac = navigator.userAgent.includes("Macintosh");
|
|||||||
const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
|
const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frameless-window fallback for pages that do not draw the app header:
|
* Frameless-window fallback for pages without the global titlebar (login and
|
||||||
* a small drag strip plus the window buttons in the top-right corner.
|
* setup): 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.
|
|
||||||
*/
|
*/
|
||||||
const WindowChrome = () => {
|
const WindowChrome = () => {
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
if (isMac || isMobile) return null;
|
if (isMac || isMobile) return null;
|
||||||
// The global app header owns the window buttons on these routes.
|
if (shouldShowTitlebar(pathname)) return null;
|
||||||
if (shouldShowAppBar(pathname)) return null;
|
|
||||||
// The home page draws its own header inside the hero frame.
|
|
||||||
if (pathname === "/home") return null;
|
|
||||||
// The video/photo players have their own fullscreen UI.
|
// The video/photo players have their own fullscreen UI.
|
||||||
if (pathname.startsWith("/player")) return null;
|
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 (
|
return (
|
||||||
<div className="window-chrome">
|
<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 {
|
.window-resize-handles {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
/**
|
const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
|
||||||
* Height of the draggable titlebar hit area. Headers on every page fit inside
|
|
||||||
* it; interactive controls are filtered out below.
|
|
||||||
*/
|
|
||||||
const DRAG_ZONE = 64;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interactive elements inside the titlebar must keep receiving clicks
|
* Interactive elements inside the titlebar must keep receiving clicks
|
||||||
@@ -47,9 +43,12 @@ const INTERACTIVE_SELECTOR = [
|
|||||||
*/
|
*/
|
||||||
const WindowDrag = () => {
|
const WindowDrag = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (isMobile) return;
|
||||||
const onMouseDown = (event: MouseEvent) => {
|
const onMouseDown = (event: MouseEvent) => {
|
||||||
if (event.button !== 0 || event.buttons !== 1) return;
|
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 (document.fullscreenElement) return;
|
||||||
if (window.location.pathname.startsWith("/player")) return;
|
if (window.location.pathname.startsWith("/player")) return;
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,12 @@ const init = async () => {
|
|||||||
document.documentElement.classList.add("is-linux");
|
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
|
// Layout transitions during a live window resize cause visible wobble
|
||||||
// (headers, cards, MUI components). Disable them until resizing settles.
|
// (headers, cards, MUI components). Disable them until resizing settles.
|
||||||
let resizeTimer: ReturnType<typeof setTimeout> | undefined;
|
let resizeTimer: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { ThemeProvider } from "@mui/material/styles";
|
|||||||
import { createRootRouteWithContext, Outlet } from "@tanstack/react-router";
|
import { createRootRouteWithContext, Outlet } from "@tanstack/react-router";
|
||||||
import { SnackbarProvider } from "notistack";
|
import { SnackbarProvider } from "notistack";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { AppBar } from "@/components/appBar/appBar";
|
import { AppTitlebar } from "@/components/appTitlebar";
|
||||||
import MobilePreview from "@/components/mobilePreview";
|
import MobilePreview from "@/components/mobilePreview";
|
||||||
// import NProgress from "@/components/nProgress";
|
// import NProgress from "@/components/nProgress";
|
||||||
import AudioPlayer from "@/components/playback/audioPlayer";
|
import AudioPlayer from "@/components/playback/audioPlayer";
|
||||||
@@ -25,22 +25,22 @@ import Backdrop from "@/components/backdrop";
|
|||||||
import DeepLinkHandler from "@/components/deepLinks";
|
import DeepLinkHandler from "@/components/deepLinks";
|
||||||
import FollowMe from "@/components/followMe";
|
import FollowMe from "@/components/followMe";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import QuickConnectApprovalDialog from "@/components/quickConnectApproval";
|
|
||||||
import ShareDialog from "@/components/share";
|
|
||||||
import OverlayScrollbar from "@/components/overlayScrollbar";
|
import OverlayScrollbar from "@/components/overlayScrollbar";
|
||||||
import PlaybackSync from "@/components/playback/PlaybackSync";
|
import PlaybackSync from "@/components/playback/PlaybackSync";
|
||||||
|
import QuickConnectApprovalDialog from "@/components/quickConnectApproval";
|
||||||
import RealtimeBridge from "@/components/realtime";
|
import RealtimeBridge from "@/components/realtime";
|
||||||
import SplashHider from "@/components/splash";
|
|
||||||
import RemoteControlDialog from "@/components/remoteControl";
|
import RemoteControlDialog from "@/components/remoteControl";
|
||||||
import RouterLoading from "@/components/routerLoading";
|
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 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 Updater from "@/components/updater";
|
||||||
|
import WindowResizeHandles from "@/components/windowControls/resizeHandles";
|
||||||
import WindowChrome from "@/components/windowControls/windowChrome";
|
import WindowChrome from "@/components/windowControls/windowChrome";
|
||||||
import WindowDrag from "@/components/windowControls/windowDrag";
|
import WindowDrag from "@/components/windowControls/windowDrag";
|
||||||
import WindowResizeHandles from "@/components/windowControls/resizeHandles";
|
|
||||||
|
|
||||||
type ApiContext = {
|
type ApiContext = {
|
||||||
api: Api | undefined;
|
api: Api | undefined;
|
||||||
@@ -72,7 +72,7 @@ export const Route = createRootRouteWithContext<ApiContext>()({
|
|||||||
<ShareDialog />
|
<ShareDialog />
|
||||||
<QuickConnectApprovalDialog />
|
<QuickConnectApprovalDialog />
|
||||||
<DeepLinkHandler />
|
<DeepLinkHandler />
|
||||||
<AppBar />
|
<AppTitlebar />
|
||||||
<MobilePreview />
|
<MobilePreview />
|
||||||
<WindowChrome />
|
<WindowChrome />
|
||||||
<WindowDrag />
|
<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-cinema {
|
||||||
--home-trending-space: 200px;
|
--home-trending-space: 200px;
|
||||||
|
|
||||||
@@ -22,107 +23,6 @@ body.has-player-bar .home-cinema {
|
|||||||
background: #08090d;
|
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 {
|
.home-sections {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -244,14 +144,9 @@ body.has-player-bar .home-sections {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 900px) {
|
@media (max-width: 900px) {
|
||||||
.home-header {
|
.cinema-trending {
|
||||||
.home-nav-link {
|
padding-left: 1rem;
|
||||||
display: none;
|
padding-right: 1rem;
|
||||||
}
|
|
||||||
|
|
||||||
&-logo {
|
|
||||||
font-size: 1.6rem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,30 +161,6 @@ body.has-player-bar .home-sections {
|
|||||||
border-radius: 0;
|
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 {
|
.cinema-trending {
|
||||||
padding-left: 1rem;
|
padding-left: 1rem;
|
||||||
padding-right: 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;
|
|
||||||
+181
-190
@@ -28,7 +28,6 @@ import { getLatestItemsQueryOptions } from "@/utils/queries/items";
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import HomeHeader from "./homeHeader";
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/home/")({
|
export const Route = createFileRoute("/_api/home/")({
|
||||||
component: Home,
|
component: Home,
|
||||||
@@ -62,9 +61,7 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
|||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
const latestMedia = useQuery(
|
const latestMedia = useQuery(getLatestItemsQueryOptions(api, user.Id));
|
||||||
getLatestItemsQueryOptions(api, user.Id),
|
|
||||||
);
|
|
||||||
|
|
||||||
const resumeItemsVideo = useQuery({
|
const resumeItemsVideo = useQuery({
|
||||||
queryKey: ["home", "resume", "video"],
|
queryKey: ["home", "resume", "video"],
|
||||||
@@ -172,12 +169,6 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
|||||||
[heroItems, setBackdropForItem],
|
[heroItems, setBackdropForItem],
|
||||||
);
|
);
|
||||||
|
|
||||||
const scrollToNewAndPopular = useCallback(() => {
|
|
||||||
document
|
|
||||||
.getElementById("home-sections")
|
|
||||||
?.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!libraries.data || !latestMedia.data) return;
|
if (!libraries.data || !latestMedia.data) return;
|
||||||
performance.mark("blink:home-ready");
|
performance.mark("blink:home-ready");
|
||||||
@@ -188,10 +179,6 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
|||||||
return (
|
return (
|
||||||
<main className="home-cinema">
|
<main className="home-cinema">
|
||||||
<div className="home-frame">
|
<div className="home-frame">
|
||||||
<HomeHeader
|
|
||||||
libraries={libraries.data?.Items ?? []}
|
|
||||||
onNewAndPopular={scrollToNewAndPopular}
|
|
||||||
/>
|
|
||||||
<section
|
<section
|
||||||
className="home-skeleton"
|
className="home-skeleton"
|
||||||
aria-busy="true"
|
aria-busy="true"
|
||||||
@@ -220,11 +207,6 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
|||||||
return (
|
return (
|
||||||
<main className="home-cinema">
|
<main className="home-cinema">
|
||||||
<div className="home-frame">
|
<div className="home-frame">
|
||||||
<HomeHeader
|
|
||||||
libraries={libraries.data?.Items ?? []}
|
|
||||||
onNewAndPopular={scrollToNewAndPopular}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ErrorBoundary FallbackComponent={ErrorNotice}>
|
<ErrorBoundary FallbackComponent={ErrorNotice}>
|
||||||
{heroItems.length > 0 && (
|
{heroItems.length > 0 && (
|
||||||
<Carousel content={heroItems} onChange={handleOnChangeCarousel} />
|
<Carousel content={heroItems} onChange={handleOnChangeCarousel} />
|
||||||
@@ -232,178 +214,187 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
|||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
|
|
||||||
<div className="home-sections" id="home-sections">
|
<div className="home-sections" id="home-sections">
|
||||||
<ErrorBoundary
|
<ErrorBoundary
|
||||||
fallback={
|
fallback={
|
||||||
<div className="error">
|
<div className="error">
|
||||||
<Typography>Ошибка карусели</Typography>
|
<Typography>Ошибка карусели</Typography>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<CardScroller displayCards={4} title="Библиотеки">
|
<CardScroller displayCards={4} title="Библиотеки">
|
||||||
{libraries.data?.Items?.map((item) => {
|
{libraries.data?.Items?.map((item) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
cardTitle={item.Name}
|
cardTitle={item.Name}
|
||||||
imageType="Primary"
|
imageType="Primary"
|
||||||
cardType="thumb"
|
cardType="thumb"
|
||||||
disableOverlay
|
disableOverlay
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (item.Id) {
|
if (item.Id) {
|
||||||
navigate({ to: "/library/$id", params: { id: item.Id } });
|
navigate({
|
||||||
}
|
to: "/library/$id",
|
||||||
}}
|
params: { id: item.Id },
|
||||||
overrideIcon={item.CollectionType}
|
});
|
||||||
/>
|
}
|
||||||
);
|
}}
|
||||||
})}
|
overrideIcon={item.CollectionType}
|
||||||
</CardScroller>
|
/>
|
||||||
</ErrorBoundary>
|
);
|
||||||
<ErrorBoundary
|
})}
|
||||||
fallback={
|
</CardScroller>
|
||||||
<div className="error">
|
</ErrorBoundary>
|
||||||
<Typography>Ошибка библиотек</Typography>
|
<ErrorBoundary
|
||||||
</div>
|
fallback={
|
||||||
}
|
<div className="error">
|
||||||
>
|
<Typography>Ошибка библиотек</Typography>
|
||||||
{upNextItems.isSuccess &&
|
</div>
|
||||||
(upNextItems.data?.TotalRecordCount ?? 0) > 0 && (
|
}
|
||||||
<CardScroller displayCards={4} title="Далее">
|
>
|
||||||
{upNextItems.data?.Items?.map((item) => {
|
{upNextItems.isSuccess &&
|
||||||
return (
|
(upNextItems.data?.TotalRecordCount ?? 0) > 0 && (
|
||||||
<Card
|
<CardScroller displayCards={4} title="Далее">
|
||||||
key={item.Id}
|
{upNextItems.data?.Items?.map((item) => {
|
||||||
item={item}
|
return (
|
||||||
cardTitle={
|
<Card
|
||||||
item.Type === BaseItemKind.Episode
|
key={item.Id}
|
||||||
? item.SeriesName
|
item={item}
|
||||||
: item.Name
|
cardTitle={
|
||||||
}
|
item.Type === BaseItemKind.Episode
|
||||||
imageType={
|
? item.SeriesName
|
||||||
item.Type === BaseItemKind.Episode
|
: item.Name
|
||||||
? "Primary"
|
}
|
||||||
: item.ImageTags?.Thumb
|
imageType={
|
||||||
? "Thumb"
|
item.Type === BaseItemKind.Episode
|
||||||
: "Backdrop"
|
? "Primary"
|
||||||
}
|
: item.ImageTags?.Thumb
|
||||||
cardCaption={
|
? "Thumb"
|
||||||
item.Type === BaseItemKind.Episode
|
: "Backdrop"
|
||||||
? item.ParentIndexNumber === 0
|
}
|
||||||
? `${item.SeasonName} - ${item.Name}`
|
cardCaption={
|
||||||
: item.IndexNumberEnd
|
item.Type === BaseItemKind.Episode
|
||||||
? `${item.IndexNumber}-${item.IndexNumberEnd}. ${item.Name}`
|
? item.ParentIndexNumber === 0
|
||||||
: `${item.IndexNumber}. ${item.Name}`
|
? `${item.SeasonName} - ${item.Name}`
|
||||||
: item.Type === BaseItemKind.Series
|
: item.IndexNumberEnd
|
||||||
? `${item.ProductionYear} - ${
|
? `${item.IndexNumber}-${item.IndexNumberEnd}. ${item.Name}`
|
||||||
item.EndDate
|
: `${item.IndexNumber}. ${item.Name}`
|
||||||
? new Date(item.EndDate).toLocaleString("ru-RU", {
|
: item.Type === BaseItemKind.Series
|
||||||
year: "numeric",
|
? `${item.ProductionYear} - ${
|
||||||
})
|
item.EndDate
|
||||||
: "н.в."
|
? new Date(item.EndDate).toLocaleString(
|
||||||
}`
|
"ru-RU",
|
||||||
: item.ProductionYear
|
{
|
||||||
}
|
year: "numeric",
|
||||||
cardType="thumb"
|
},
|
||||||
queryKey={["home", "upNext"]}
|
)
|
||||||
userId={user?.Id}
|
: "н.в."
|
||||||
/>
|
}`
|
||||||
);
|
: item.ProductionYear
|
||||||
|
}
|
||||||
|
cardType="thumb"
|
||||||
|
queryKey={["home", "upNext"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
</ErrorBoundary>
|
||||||
|
<ErrorBoundary
|
||||||
|
fallback={
|
||||||
|
<div className="error">
|
||||||
|
<Typography>Ошибка продолжения просмотра</Typography>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{resumeItemsVideo.isSuccess &&
|
||||||
|
!resumeItemsVideo.data?.TotalRecordCount ? (
|
||||||
|
<></>
|
||||||
|
) : (
|
||||||
|
<CardScroller displayCards={4} title="Продолжить просмотр">
|
||||||
|
{resumeItemsVideo.data?.Items?.map((item) => {
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
key={item.Id}
|
||||||
|
item={item}
|
||||||
|
cardTitle={
|
||||||
|
item.Type === BaseItemKind.Episode
|
||||||
|
? item.SeriesName
|
||||||
|
: item.Name
|
||||||
|
}
|
||||||
|
imageType={
|
||||||
|
item.Type === BaseItemKind.Episode
|
||||||
|
? "Primary"
|
||||||
|
: item.ImageTags?.Thumb
|
||||||
|
? "Thumb"
|
||||||
|
: "Backdrop"
|
||||||
|
}
|
||||||
|
cardCaption={
|
||||||
|
item.Type === BaseItemKind.Episode
|
||||||
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||||
|
: item.Type === BaseItemKind.Series
|
||||||
|
? `${item.ProductionYear} - ${
|
||||||
|
item.EndDate
|
||||||
|
? new Date(item.EndDate).toLocaleString(
|
||||||
|
"ru-RU",
|
||||||
|
{
|
||||||
|
year: "numeric",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: "н.в."
|
||||||
|
}`
|
||||||
|
: item.ProductionYear
|
||||||
|
}
|
||||||
|
cardType="thumb"
|
||||||
|
queryKey={["home", "resume", "video"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
</ErrorBoundary>
|
||||||
|
<ErrorBoundary
|
||||||
|
fallback={
|
||||||
|
<div className="error">
|
||||||
|
<Typography>Ошибка продолжения прослушивания</Typography>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{resumeItemsAudio.isSuccess &&
|
||||||
|
!resumeItemsAudio.data?.TotalRecordCount ? (
|
||||||
|
<></>
|
||||||
|
) : (
|
||||||
|
<CardScroller displayCards={4} title="Продолжить прослушивание">
|
||||||
|
{resumeItemsAudio.data?.Items?.map((item) => {
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
key={item.Id}
|
||||||
|
item={item}
|
||||||
|
cardTitle={item.Name}
|
||||||
|
imageType="Primary"
|
||||||
|
cardCaption={item.ProductionYear}
|
||||||
|
cardType="thumb"
|
||||||
|
queryKey={["home", "resume", "audio"]}
|
||||||
|
userId={user?.Id}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
</ErrorBoundary>
|
||||||
|
<ErrorBoundary
|
||||||
|
fallback={
|
||||||
|
<div className="error">
|
||||||
|
<Typography>Ошибка новых материалов</Typography>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{latestMediaLibs?.map((lib) => {
|
||||||
|
return <LatestMediaSection key={lib.Id} latestMediaLib={lib} />;
|
||||||
})}
|
})}
|
||||||
</CardScroller>
|
</ErrorBoundary>
|
||||||
)}
|
|
||||||
</ErrorBoundary>
|
|
||||||
<ErrorBoundary
|
|
||||||
fallback={
|
|
||||||
<div className="error">
|
|
||||||
<Typography>Ошибка продолжения просмотра</Typography>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{resumeItemsVideo.isSuccess &&
|
|
||||||
!resumeItemsVideo.data?.TotalRecordCount ? (
|
|
||||||
<></>
|
|
||||||
) : (
|
|
||||||
<CardScroller displayCards={4} title="Продолжить просмотр">
|
|
||||||
{resumeItemsVideo.data?.Items?.map((item) => {
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
key={item.Id}
|
|
||||||
item={item}
|
|
||||||
cardTitle={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? item.SeriesName
|
|
||||||
: item.Name
|
|
||||||
}
|
|
||||||
imageType={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? "Primary"
|
|
||||||
: item.ImageTags?.Thumb
|
|
||||||
? "Thumb"
|
|
||||||
: "Backdrop"
|
|
||||||
}
|
|
||||||
cardCaption={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
|
||||||
: item.Type === BaseItemKind.Series
|
|
||||||
? `${item.ProductionYear} - ${
|
|
||||||
item.EndDate
|
|
||||||
? new Date(item.EndDate).toLocaleString("ru-RU", {
|
|
||||||
year: "numeric",
|
|
||||||
})
|
|
||||||
: "н.в."
|
|
||||||
}`
|
|
||||||
: item.ProductionYear
|
|
||||||
}
|
|
||||||
cardType="thumb"
|
|
||||||
queryKey={["home", "resume", "video"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CardScroller>
|
|
||||||
)}
|
|
||||||
</ErrorBoundary>
|
|
||||||
<ErrorBoundary
|
|
||||||
fallback={
|
|
||||||
<div className="error">
|
|
||||||
<Typography>Ошибка продолжения прослушивания</Typography>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{resumeItemsAudio.isSuccess &&
|
|
||||||
!resumeItemsAudio.data?.TotalRecordCount ? (
|
|
||||||
<></>
|
|
||||||
) : (
|
|
||||||
<CardScroller displayCards={4} title="Продолжить прослушивание">
|
|
||||||
{resumeItemsAudio.data?.Items?.map((item) => {
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
key={item.Id}
|
|
||||||
item={item}
|
|
||||||
cardTitle={item.Name}
|
|
||||||
imageType="Primary"
|
|
||||||
cardCaption={item.ProductionYear}
|
|
||||||
cardType="thumb"
|
|
||||||
queryKey={["home", "resume", "audio"]}
|
|
||||||
userId={user?.Id}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</CardScroller>
|
|
||||||
)}
|
|
||||||
</ErrorBoundary>
|
|
||||||
<ErrorBoundary
|
|
||||||
fallback={
|
|
||||||
<div className="error">
|
|
||||||
<Typography>Ошибка новых материалов</Typography>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{latestMediaLibs?.map((lib) => {
|
|
||||||
return <LatestMediaSection key={lib.Id} latestMediaLib={lib} />;
|
|
||||||
})}
|
|
||||||
</ErrorBoundary>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { BaseItemKind, ItemSortBy } from "@jellyfin/sdk/lib/generated-client";
|
import { BaseItemKind, ItemSortBy } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||||
import React, { Suspense, useEffect } from "react";
|
import React, { Suspense } from "react";
|
||||||
import { ErrorBoundary } from "react-error-boundary";
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
import "./library.scss";
|
import "./library.scss";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
@@ -13,7 +13,6 @@ import { getDefaultSortByForCollectionType } from "@/utils/constants/library";
|
|||||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import useHeaderStore from "@/utils/store/header";
|
|
||||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||||
|
|
||||||
// type SortByObject = { title: string; value: string };
|
// type SortByObject = { title: string; value: string };
|
||||||
@@ -66,16 +65,14 @@ function Library() {
|
|||||||
getLibraryQueryOptions(api, user?.Id, id),
|
getLibraryQueryOptions(api, user?.Id, id),
|
||||||
);
|
);
|
||||||
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||||
const { libraryName: storeLibraryName, currentViewType } =
|
const { currentViewType } = useLibraryStateStore(
|
||||||
useLibraryStateStore(
|
useShallow((s) => {
|
||||||
useShallow((s) => {
|
const sl = s.libraries[id || ""];
|
||||||
const sl = s.libraries[id || ""];
|
return {
|
||||||
return {
|
currentViewType: sl?.currentViewType,
|
||||||
libraryName: sl?.libraryName,
|
} as const;
|
||||||
currentViewType: sl?.currentViewType,
|
}),
|
||||||
} as const;
|
);
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!id || !currentLib.data) return;
|
if (!id || !currentLib.data) return;
|
||||||
@@ -83,18 +80,6 @@ function Library() {
|
|||||||
updateLibrary(id, { libraryName: currentLib.data.Name ?? undefined });
|
updateLibrary(id, { libraryName: currentLib.data.Name ?? undefined });
|
||||||
}, [id, updateLibrary, currentLib.data]);
|
}, [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) {
|
/* if (!id) {
|
||||||
// show loading if any route param is missing
|
// show loading if any route param is missing
|
||||||
return <LoadingIndicator />;
|
return <LoadingIndicator />;
|
||||||
@@ -122,7 +107,20 @@ function Library() {
|
|||||||
</div>
|
</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">
|
<div className="library-items">
|
||||||
<LibraryItemsGrid />
|
<LibraryItemsGrid />
|
||||||
</div>
|
</div>
|
||||||
@@ -134,7 +132,7 @@ function Library() {
|
|||||||
currentLib.data.CollectionType === "music"
|
currentLib.data.CollectionType === "music"
|
||||||
? "max(14px, calc((100vw - 1180px) / 2 + 18px))"
|
? "max(14px, calc((100vw - 1180px) / 2 + 18px))"
|
||||||
: 14,
|
: 14,
|
||||||
top: 80,
|
top: "calc(var(--app-titlebar-height) + 96px)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<AlphaSelector />
|
<AlphaSelector />
|
||||||
@@ -144,4 +142,4 @@ function Library() {
|
|||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -215,13 +215,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.alpha-selector {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 700px) {
|
@media (max-width: 700px) {
|
||||||
.library.padded-top {
|
.library.padded-top {
|
||||||
padding-top: 0 !important;
|
padding-top: calc(var(--app-titlebar-height) + 0.75rem) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.library-items {
|
.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;
|
padding-bottom: calc(7.5em + var(--safe-bottom)) !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
max-width: 1180px;
|
max-width: 1180px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: clamp(3.4em, 6vw, 4.6em) clamp(1.5em, 4vw, 3.5em) 7em;
|
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 {
|
.music-hero {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ import "./videoPlayer.scss";
|
|||||||
|
|
||||||
import { RepeatMode } from "@jellyfin/sdk/lib/generated-client";
|
import { RepeatMode } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
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 JASSUB from "jassub";
|
||||||
import wasmUrl from "jassub/dist/wasm/jassub-worker.wasm?url"; // non-SIMD fallback
|
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
|
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 UpNextFlyout from "@/components/playback/videoPlayer/upNextFlyout";
|
||||||
import VolumeChangeOverlay from "@/components/playback/videoPlayer/VolumeChangeOverlay";
|
import VolumeChangeOverlay from "@/components/playback/videoPlayer/VolumeChangeOverlay";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
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 {
|
import {
|
||||||
inSyncPlayGroup,
|
inSyncPlayGroup,
|
||||||
nextSyncPlayItem,
|
nextSyncPlayItem,
|
||||||
@@ -44,9 +40,17 @@ import {
|
|||||||
reportSyncPlayResume,
|
reportSyncPlayResume,
|
||||||
reportSyncPlaySeek,
|
reportSyncPlaySeek,
|
||||||
} from "@/utils/methods/syncPlay";
|
} 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 { useCentralStore } from "@/utils/store/central";
|
||||||
import useQueue, { clearQueue } from "@/utils/store/queue";
|
import useQueue, { clearQueue } from "@/utils/store/queue";
|
||||||
import type subtitlePlaybackInfo from "@/utils/types/subtitlePlaybackInfo";
|
import type subtitlePlaybackInfo from "@/utils/types/subtitlePlaybackInfo";
|
||||||
|
import type { VideoFitMode } from "@/utils/types/videoFitMode";
|
||||||
import font from "./Noto-Sans-Indosphere.ttf?url";
|
import font from "./Noto-Sans-Indosphere.ttf?url";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,6 +104,7 @@ export function VideoPlayer() {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { history } = useRouter();
|
const { history } = useRouter();
|
||||||
const player = useRef<HTMLVideoElement | null>(null);
|
const player = useRef<HTMLVideoElement | null>(null);
|
||||||
|
const exitingPlayerRef = useRef(false);
|
||||||
/** Re-apply the transfer/resume position until the HLS player stabilises. */
|
/** Re-apply the transfer/resume position until the HLS player stabilises. */
|
||||||
const startSeekRef = useRef<{ target: number; expiresAt: number } | null>(
|
const startSeekRef = useRef<{ target: number; expiresAt: number } | null>(
|
||||||
null,
|
null,
|
||||||
@@ -204,11 +209,7 @@ export function VideoPlayer() {
|
|||||||
const cycleFitMode = useCallback(() => {
|
const cycleFitMode = useCallback(() => {
|
||||||
setFitMode((current) => {
|
setFitMode((current) => {
|
||||||
const next =
|
const next =
|
||||||
current === "fit"
|
current === "fit" ? "fill" : current === "fill" ? "stretch" : "fit";
|
||||||
? "fill"
|
|
||||||
: current === "fill"
|
|
||||||
? "stretch"
|
|
||||||
: "fit";
|
|
||||||
void setVideoFitMode(next);
|
void setVideoFitMode(next);
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
@@ -312,24 +313,24 @@ export function VideoPlayer() {
|
|||||||
) {
|
) {
|
||||||
if (typeof MediaMetadata !== "undefined") {
|
if (typeof MediaMetadata !== "undefined") {
|
||||||
navigator.mediaSession.metadata = new MediaMetadata({
|
navigator.mediaSession.metadata = new MediaMetadata({
|
||||||
title: isEpisode
|
title: isEpisode
|
||||||
? `${itemName} - ${episodeTitle}`
|
? `${itemName} - ${episodeTitle}`
|
||||||
: (itemName ?? "Blink"),
|
: (itemName ?? "Blink"),
|
||||||
album: isEpisode ? (itemName ?? "Blink") : undefined,
|
album: isEpisode ? (itemName ?? "Blink") : undefined,
|
||||||
artwork: [
|
artwork: [
|
||||||
{
|
{
|
||||||
src: getImageUrlsApi(api).getItemImageUrlById(
|
src: getImageUrlsApi(api).getItemImageUrlById(
|
||||||
itemId ?? "",
|
itemId ?? "",
|
||||||
"Primary",
|
"Primary",
|
||||||
{
|
{
|
||||||
quality: 80,
|
quality: 80,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
sizes: "512x512",
|
sizes: "512x512",
|
||||||
type: "image/png",
|
type: "image/png",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
navigator.mediaSession.setActionHandler("play", () => {
|
navigator.mediaSession.setActionHandler("play", () => {
|
||||||
toggleIsPlaying();
|
toggleIsPlaying();
|
||||||
@@ -393,15 +394,24 @@ export function VideoPlayer() {
|
|||||||
VolumeLevel: Math.floor(volume * 100),
|
VolumeLevel: Math.floor(volume * 100),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const player = getVideoElement();
|
||||||
reportSyncPlayReady(
|
reportSyncPlayReady(
|
||||||
api,
|
api,
|
||||||
secToTicks(getVideoElement()?.currentTime ?? 0),
|
secToTicks(player?.currentTime ?? 0),
|
||||||
true,
|
Boolean(player && !player.paused),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const lastReportTimeRef = useRef<number>(0);
|
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 handleTimeUpdate = useCallback(async () => {
|
||||||
const videoElement = getVideoElement();
|
const videoElement = getVideoElement();
|
||||||
@@ -491,7 +501,9 @@ export function VideoPlayer() {
|
|||||||
VolumeLevel: Math.floor(volume * 100),
|
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,
|
setCurrentTime,
|
||||||
api,
|
api,
|
||||||
@@ -505,6 +517,7 @@ export function VideoPlayer() {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const handleExitPlayer = useCallback(async () => {
|
const handleExitPlayer = useCallback(async () => {
|
||||||
|
exitingPlayerRef.current = true;
|
||||||
appWindow.getCurrent().setFullscreen(false);
|
appWindow.getCurrent().setFullscreen(false);
|
||||||
|
|
||||||
history.back();
|
history.back();
|
||||||
@@ -531,61 +544,64 @@ export function VideoPlayer() {
|
|||||||
clearQueue();
|
clearQueue();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleKeyPress = useCallback((event: KeyboardEvent) => {
|
const handleKeyPress = useCallback(
|
||||||
const videoElement = getVideoElement();
|
(event: KeyboardEvent) => {
|
||||||
if (videoElement) {
|
const videoElement = getVideoElement();
|
||||||
event.preventDefault();
|
if (videoElement) {
|
||||||
const currentTime = videoElement.currentTime ?? 0;
|
event.preventDefault();
|
||||||
|
const currentTime = videoElement.currentTime ?? 0;
|
||||||
|
|
||||||
const seekTo = (time: number) => {
|
const seekTo = (time: number) => {
|
||||||
startSeekRef.current = null;
|
startSeekRef.current = null;
|
||||||
videoElement.currentTime = time;
|
videoElement.currentTime = time;
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case "ArrowRight":
|
case "ArrowRight":
|
||||||
seekTo(currentTime + 10);
|
seekTo(currentTime + 10);
|
||||||
break;
|
break;
|
||||||
case "ArrowLeft":
|
case "ArrowLeft":
|
||||||
seekTo(currentTime - 10);
|
seekTo(currentTime - 10);
|
||||||
break;
|
break;
|
||||||
case "F8":
|
case "F8":
|
||||||
case " ":
|
case " ":
|
||||||
toggleIsPlaying();
|
toggleIsPlaying();
|
||||||
break;
|
break;
|
||||||
case "ArrowUp":
|
case "ArrowUp":
|
||||||
// setVolume((state) => (state <= 0.9 ? state + 0.1 : state));
|
// setVolume((state) => (state <= 0.9 ? state + 0.1 : state));
|
||||||
break;
|
break;
|
||||||
case "ArrowDown":
|
case "ArrowDown":
|
||||||
// setVolume((state) => (state >= 0.1 ? state - 0.1 : state));
|
// setVolume((state) => (state >= 0.1 ? state - 0.1 : state));
|
||||||
break;
|
break;
|
||||||
case "F":
|
case "F":
|
||||||
case "f":
|
case "f":
|
||||||
toggleIsPlayerFullscreen();
|
toggleIsPlayerFullscreen();
|
||||||
break;
|
break;
|
||||||
case "P":
|
case "P":
|
||||||
case "p":
|
case "p":
|
||||||
// setIsPIP((state) => !state);
|
// setIsPIP((state) => !state);
|
||||||
break;
|
break;
|
||||||
case "M":
|
case "M":
|
||||||
case "m":
|
case "m":
|
||||||
toggleIsPlayerMuted();
|
toggleIsPlayerMuted();
|
||||||
break;
|
break;
|
||||||
case "Z":
|
case "Z":
|
||||||
case "z":
|
case "z":
|
||||||
cycleFitMode();
|
cycleFitMode();
|
||||||
break;
|
break;
|
||||||
case "F7":
|
case "F7":
|
||||||
playItemFromQueue("previous", user?.Id, api);
|
playItemFromQueue("previous", user?.Id, api);
|
||||||
break;
|
break;
|
||||||
case "F9":
|
case "F9":
|
||||||
playItemFromQueue("next", user?.Id, api);
|
playItemFromQueue("next", user?.Id, api);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}, [cycleFitMode]);
|
[cycleFitMode],
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// attach the event listener
|
// attach the event listener
|
||||||
@@ -718,22 +734,35 @@ export function VideoPlayer() {
|
|||||||
|
|
||||||
const handleOnBuffer = useCallback(() => {
|
const handleOnBuffer = useCallback(() => {
|
||||||
setIsBuffering(true);
|
setIsBuffering(true);
|
||||||
reportSyncPlayBuffering(
|
// 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);
|
||||||
|
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,
|
api,
|
||||||
true,
|
|
||||||
secToTicks(getVideoElement()?.currentTime ?? 0),
|
secToTicks(getVideoElement()?.currentTime ?? 0),
|
||||||
isPlayerPlaying,
|
isPlayerPlaying,
|
||||||
);
|
);
|
||||||
}, [setIsBuffering, api, isPlayerPlaying]);
|
}, [setIsBuffering, api, isPlayerPlaying]);
|
||||||
const handleOnBufferEnd = useCallback(() => {
|
|
||||||
setIsBuffering(false);
|
|
||||||
reportSyncPlayBuffering(
|
|
||||||
api,
|
|
||||||
false,
|
|
||||||
secToTicks(getVideoElement()?.currentTime ?? 0),
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
}, [setIsBuffering, api]);
|
|
||||||
|
|
||||||
const handleError = useCallback((e: any) => {
|
const handleError = useCallback((e: any) => {
|
||||||
console.error("Video playback error:", e);
|
console.error("Video playback error:", e);
|
||||||
|
|||||||
+115
-74
@@ -14,8 +14,10 @@
|
|||||||
--remote-surface-hover: rgb(255 255 255 / 0.14);
|
--remote-surface-hover: rgb(255 255 255 / 0.14);
|
||||||
--remote-border: rgb(255 255 255 / 0.1);
|
--remote-border: rgb(255 255 255 / 0.1);
|
||||||
|
|
||||||
position: fixed;
|
position: relative;
|
||||||
inset: 0;
|
height: 100vh;
|
||||||
|
padding-top: var(--app-titlebar-height);
|
||||||
|
box-sizing: border-box;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -29,62 +31,6 @@
|
|||||||
sans-serif;
|
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 {
|
.remote-chevron {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
font-size: 1.15rem !important;
|
font-size: 1.15rem !important;
|
||||||
@@ -109,6 +55,9 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.remote-devices-title {
|
.remote-devices-title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5em;
|
||||||
margin: 0 0 0.5em 0.45em;
|
margin: 0 0 0.5em 0.45em;
|
||||||
font-size: 0.72rem;
|
font-size: 0.72rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -117,14 +66,29 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
|
|||||||
color: rgb(255 255 255 / 0.5);
|
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 {
|
.remote-device-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.25em;
|
gap: 0.55em;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
list-style: none;
|
scrollbar-width: thin;
|
||||||
|
scrollbar-color: rgb(255 255 255 / 0.16) transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remote-device {
|
.remote-device {
|
||||||
@@ -282,6 +246,95 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
|
|||||||
backdrop-filter: blur(12px);
|
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 {
|
.remote-overview {
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
-webkit-line-clamp: 4;
|
-webkit-line-clamp: 4;
|
||||||
@@ -515,10 +568,6 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
|
|||||||
/* ------------------------------------------------------------ adapt */
|
/* ------------------------------------------------------------ adapt */
|
||||||
|
|
||||||
@media (max-height: 780px) {
|
@media (max-height: 780px) {
|
||||||
.remote-topbar {
|
|
||||||
height: 52px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.remote-title {
|
.remote-title {
|
||||||
font-size: clamp(1.6rem, 2.6vw, 2.3rem);
|
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;
|
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 {
|
.remote-body {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -649,7 +689,8 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
|
|||||||
|
|
||||||
.remote-transport {
|
.remote-transport {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 0.55rem;
|
flex-wrap: wrap;
|
||||||
|
gap: 0.45rem;
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+378
-221
@@ -9,23 +9,43 @@ import Menu from "@mui/material/Menu";
|
|||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
import Slider from "@mui/material/Slider";
|
import Slider from "@mui/material/Slider";
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
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 { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import CachedImage from "@/components/cachedImage";
|
import CachedImage from "@/components/cachedImage";
|
||||||
import { UserAvatarMenu } from "@/components/userAvatarMenu";
|
import SessionCard from "@/components/remoteControl/sessionCard";
|
||||||
import WindowControls from "@/components/windowControls";
|
|
||||||
import { getRuntimeCompact } from "@/utils/date/time";
|
import { getRuntimeCompact } from "@/utils/date/time";
|
||||||
|
import {
|
||||||
|
getBlinkDeviceName,
|
||||||
|
useBlinkSessions,
|
||||||
|
} from "@/utils/methods/blinkSessions";
|
||||||
import { getCoverPalette } from "@/utils/methods/coverColor";
|
import { getCoverPalette } from "@/utils/methods/coverColor";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
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 { useApiInContext } from "@/utils/store/api";
|
||||||
|
import { stopPlayback } from "@/utils/store/audioPlayback";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
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";
|
import "./remote.scss";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/remote")({
|
export const Route = createFileRoute("/_api/remote")({
|
||||||
component: RemotePage,
|
component: RemotePage,
|
||||||
|
validateSearch: (search: Record<string, unknown>): { device?: string } => ({
|
||||||
|
device: typeof search.device === "string" ? search.device : undefined,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const TICKS_PER_SECOND = 10_000_000;
|
const TICKS_PER_SECOND = 10_000_000;
|
||||||
@@ -40,11 +60,7 @@ const formatTime = (ticks: number | null | undefined) => {
|
|||||||
: `${m}:${String(s).padStart(2, "0")}`;
|
: `${m}:${String(s).padStart(2, "0")}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const sessionLabel = (session: SessionInfoDto) =>
|
const sessionLabel = (session: SessionInfoDto) => getBlinkDeviceName(session);
|
||||||
session.DeviceName ||
|
|
||||||
session.Client ||
|
|
||||||
session.DeviceId ||
|
|
||||||
"Неизвестное устройство";
|
|
||||||
|
|
||||||
const channelLabel = (channels?: number | null) => {
|
const channelLabel = (channels?: number | null) => {
|
||||||
if (!channels) return null;
|
if (!channels) return null;
|
||||||
@@ -55,30 +71,33 @@ const channelLabel = (channels?: number | null) => {
|
|||||||
return `${channels} ch`;
|
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() {
|
function RemotePage() {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
const { device: requestedDevice } = Route.useSearch();
|
||||||
const navigate = useNavigate();
|
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>(
|
const [subtitleAnchor, setSubtitleAnchor] = useState<HTMLElement | null>(
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
|
const [audioAnchor, setAudioAnchor] = useState<HTMLElement | null>(null);
|
||||||
const [subtitleIndex, setSubtitleIndex] = useState<number>(-1);
|
const [subtitleIndex, setSubtitleIndex] = useState<number>(-1);
|
||||||
|
const [audioIndex, setAudioIndex] = useState<number>(-1);
|
||||||
const [volumeDraft, setVolumeDraft] = useState<number | null>(null);
|
const [volumeDraft, setVolumeDraft] = useState<number | null>(null);
|
||||||
const [displayPosition, setDisplayPosition] = useState(0);
|
const [displayPosition, setDisplayPosition] = useState(0);
|
||||||
const [isSeeking, setIsSeeking] = useState(false);
|
const [isSeeking, setIsSeeking] = useState(false);
|
||||||
const volumeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
const volumeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (requestedDevice) setSelectedId(requestedDevice);
|
||||||
|
}, [requestedDevice]);
|
||||||
|
|
||||||
const clearVolumeTimer = () => {
|
const clearVolumeTimer = () => {
|
||||||
if (volumeTimerRef.current) {
|
if (volumeTimerRef.current) {
|
||||||
clearTimeout(volumeTimerRef.current);
|
clearTimeout(volumeTimerRef.current);
|
||||||
@@ -88,28 +107,7 @@ function RemotePage() {
|
|||||||
|
|
||||||
useEffect(() => clearVolumeTimer, []);
|
useEffect(() => clearVolumeTimer, []);
|
||||||
|
|
||||||
const sessions = useQuery({
|
const remoteSessions = blink.sessions;
|
||||||
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 playing = remoteSessions.find((session) => session.NowPlayingItem);
|
const playing = remoteSessions.find((session) => session.NowPlayingItem);
|
||||||
const selected =
|
const selected =
|
||||||
@@ -120,6 +118,7 @@ function RemotePage() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setVolumeDraft(null);
|
setVolumeDraft(null);
|
||||||
setSubtitleIndex(-1);
|
setSubtitleIndex(-1);
|
||||||
|
setAudioIndex(-1);
|
||||||
clearVolumeTimer();
|
clearVolumeTimer();
|
||||||
}, [selected?.Id]);
|
}, [selected?.Id]);
|
||||||
|
|
||||||
@@ -147,7 +146,7 @@ function RemotePage() {
|
|||||||
seekPositionTicks,
|
seekPositionTicks,
|
||||||
controllingUserId: user?.Id,
|
controllingUserId: user?.Id,
|
||||||
});
|
});
|
||||||
await sessions.refetch();
|
await blink.refetch();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Remote command failed", error);
|
console.error("Remote command failed", error);
|
||||||
}
|
}
|
||||||
@@ -168,12 +167,101 @@ function RemotePage() {
|
|||||||
ControllingUserId: user?.Id,
|
ControllingUserId: user?.Id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await sessions.refetch();
|
await blink.refetch();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Remote general command failed", 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 nowPlaying = selected?.NowPlayingItem;
|
||||||
const playState = selected?.PlayState;
|
const playState = selected?.PlayState;
|
||||||
const isPaused = playState?.IsPaused ?? true;
|
const isPaused = playState?.IsPaused ?? true;
|
||||||
@@ -242,9 +330,16 @@ function RemotePage() {
|
|||||||
const audioStream = nowPlaying?.MediaStreams?.find(
|
const audioStream = nowPlaying?.MediaStreams?.find(
|
||||||
(stream) => stream.Type === "Audio",
|
(stream) => stream.Type === "Audio",
|
||||||
);
|
);
|
||||||
|
const audioStreams =
|
||||||
|
nowPlaying?.MediaStreams?.filter((stream) => stream.Type === "Audio") ?? [];
|
||||||
const subtitleStreams =
|
const subtitleStreams =
|
||||||
nowPlaying?.MediaStreams?.filter((stream) => stream.Type === "Subtitle") ??
|
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 = [
|
const chips = [
|
||||||
nowPlaying?.OfficialRating,
|
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) => {
|
const transport = (name: PlaystateCommand) => {
|
||||||
if (!selected) return;
|
if (!selected) return;
|
||||||
void command(selected, name);
|
void command(selected, name);
|
||||||
@@ -294,198 +398,212 @@ function RemotePage() {
|
|||||||
} as React.CSSProperties
|
} as React.CSSProperties
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<header className="remote-topbar" data-tauri-drag-region>
|
{blink.isLoading ? (
|
||||||
<div className="remote-topbar-left">
|
<div className="remote-empty">
|
||||||
<IconButton
|
<span className="material-symbols-rounded animate-rotate">
|
||||||
aria-label="Главная"
|
progress_activity
|
||||||
title="Главная"
|
</span>
|
||||||
onClick={() => navigate({ to: "/home" })}
|
<h1>Ищем Blink-устройства</h1>
|
||||||
>
|
<p>Подключаемся к серверу и собираем список клиентов Blink.</p>
|
||||||
<span className="material-symbols-rounded">home</span>
|
|
||||||
</IconButton>
|
|
||||||
</div>
|
</div>
|
||||||
|
) : !selected ? (
|
||||||
<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 ? (
|
|
||||||
<div className="remote-empty">
|
<div className="remote-empty">
|
||||||
<span className="material-symbols-rounded">settings_remote</span>
|
<span className="material-symbols-rounded">settings_remote</span>
|
||||||
<h1>Нет доступных устройств</h1>
|
<h1>Нет Blink-устройств</h1>
|
||||||
<p>
|
<p>
|
||||||
Откройте клиент Jellyfin (телевизор, браузер, телефон) под этой
|
Запустите Blink на другом устройстве под этой учётной записью. В
|
||||||
учётной записью, и он появится здесь.
|
пульте показываются только клиенты Blink — Jellyfin Web, телевизоры
|
||||||
|
и другие приложения не попадают в этот список.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div className="remote-body">
|
<div className="remote-body">
|
||||||
<aside className="remote-devices" aria-label="Устройства">
|
<aside className="remote-devices" aria-label="Blink-устройства">
|
||||||
<div className="remote-devices-title">Устройства</div>
|
<div className="remote-devices-title">
|
||||||
<ul className="remote-device-list">
|
Устройства Blink
|
||||||
{remoteSessions.map((session) => {
|
<span className="remote-devices-count">
|
||||||
const isActive = session.Id === selected?.Id;
|
{remoteSessions.length}
|
||||||
const sessionItem = session.NowPlayingItem;
|
</span>
|
||||||
return (
|
</div>
|
||||||
<li key={session.Id}>
|
<div className="remote-device-list">
|
||||||
<button
|
{remoteSessions.map((session) => (
|
||||||
type="button"
|
<SessionCard
|
||||||
className={`remote-device${isActive ? " is-active" : ""}`}
|
key={session.Id}
|
||||||
onClick={() => setSelectedId(session.Id ?? null)}
|
session={session}
|
||||||
>
|
api={api}
|
||||||
<span className="material-symbols-rounded remote-device-icon">
|
compact
|
||||||
{sessionKind(session)}
|
selected={session.Id === selected?.Id}
|
||||||
</span>
|
onSelect={(target) => setSelectedId(target.Id ?? null)}
|
||||||
<span className="remote-device-info">
|
/>
|
||||||
<span className="remote-device-name">
|
))}
|
||||||
{sessionLabel(session)}
|
</div>
|
||||||
</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" : ""
|
|
||||||
}`}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</ul>
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<main className="remote-hero">
|
<main className="remote-hero">
|
||||||
<div className="remote-poster">
|
<div className="remote-poster">
|
||||||
<div className="remote-poster-frame">
|
<div className="remote-poster-frame">
|
||||||
{coverUrl ? (
|
{coverUrl ? (
|
||||||
<CachedImage src={coverUrl} alt={title ?? "Постер"} />
|
<CachedImage src={coverUrl} alt={title ?? "Постер"} />
|
||||||
) : (
|
) : (
|
||||||
<span className="material-symbols-rounded">live_tv</span>
|
<span className="material-symbols-rounded">live_tv</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<section className="remote-details">
|
|
||||||
<h1 className="remote-title">
|
|
||||||
{title ?? sessionLabel(selected)}
|
|
||||||
</h1>
|
|
||||||
{subtitle && <h2 className="remote-subtitle">{subtitle}</h2>}
|
|
||||||
|
|
||||||
{chips.length > 0 && (
|
|
||||||
<div className="remote-chips">
|
|
||||||
{chips.map((chip) => (
|
|
||||||
<span key={chip} className="remote-chip">
|
|
||||||
{chip}
|
|
||||||
</span>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
|
|
||||||
{nowPlaying?.Overview && (
|
|
||||||
<p className="remote-overview">{nowPlaying.Overview}</p>
|
|
||||||
)}
|
|
||||||
{!nowPlaying && (
|
|
||||||
<p className="remote-overview">
|
|
||||||
Устройство свободно. Запустите воспроизведение на нём, и
|
|
||||||
здесь появятся название, постер и управление.
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="remote-transport">
|
|
||||||
<Tooltip title="Назад">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="remote-round"
|
|
||||||
onClick={() => transport(PlaystateCommand.Rewind)}
|
|
||||||
disabled={!nowPlaying}
|
|
||||||
aria-label="Назад"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
fast_rewind
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Предыдущий">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="remote-round"
|
|
||||||
onClick={() =>
|
|
||||||
transport(PlaystateCommand.PreviousTrack)
|
|
||||||
}
|
|
||||||
disabled={!nowPlaying}
|
|
||||||
aria-label="Предыдущий"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
skip_previous
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="remote-round remote-round-primary"
|
|
||||||
onClick={() => transport(PlaystateCommand.PlayPause)}
|
|
||||||
disabled={!nowPlaying}
|
|
||||||
aria-label={isPaused ? "Играть" : "Пауза"}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
{isPaused ? "play_arrow" : "pause"}
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
<Tooltip title="Следующий">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="remote-round"
|
|
||||||
onClick={() => transport(PlaystateCommand.NextTrack)}
|
|
||||||
disabled={!nowPlaying}
|
|
||||||
aria-label="Следующий"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
skip_next
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip title="Вперёд">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="remote-round"
|
|
||||||
onClick={() => transport(PlaystateCommand.FastForward)}
|
|
||||||
disabled={!nowPlaying}
|
|
||||||
aria-label="Вперёд"
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">
|
|
||||||
fast_forward
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
|
||||||
</main>
|
<section className="remote-details">
|
||||||
|
<h1 className="remote-title">
|
||||||
|
{title ?? sessionLabel(selected)}
|
||||||
|
</h1>
|
||||||
|
{subtitle && <h2 className="remote-subtitle">{subtitle}</h2>}
|
||||||
|
|
||||||
|
{chips.length > 0 && (
|
||||||
|
<div className="remote-chips">
|
||||||
|
{chips.map((chip) => (
|
||||||
|
<span key={chip} className="remote-chip">
|
||||||
|
{chip}
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</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>
|
||||||
|
)}
|
||||||
|
{!nowPlaying && (
|
||||||
|
<p className="remote-overview">
|
||||||
|
Устройство свободно. Запустите воспроизведение на нём, и
|
||||||
|
здесь появятся название, постер и управление.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="remote-transport">
|
||||||
|
<Tooltip title="Назад">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="remote-round"
|
||||||
|
onClick={() => transport(PlaystateCommand.Rewind)}
|
||||||
|
disabled={!nowPlaying}
|
||||||
|
aria-label="Назад"
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
fast_rewind
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title="Предыдущий">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="remote-round"
|
||||||
|
onClick={() => transport(PlaystateCommand.PreviousTrack)}
|
||||||
|
disabled={!nowPlaying}
|
||||||
|
aria-label="Предыдущий"
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
skip_previous
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="remote-round remote-round-primary"
|
||||||
|
onClick={() => transport(PlaystateCommand.PlayPause)}
|
||||||
|
disabled={!nowPlaying}
|
||||||
|
aria-label={isPaused ? "Играть" : "Пауза"}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
{isPaused ? "play_arrow" : "pause"}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<Tooltip title="Следующий">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="remote-round"
|
||||||
|
onClick={() => transport(PlaystateCommand.NextTrack)}
|
||||||
|
disabled={!nowPlaying}
|
||||||
|
aria-label="Следующий"
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
skip_next
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title="Вперёд">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="remote-round"
|
||||||
|
onClick={() => transport(PlaystateCommand.FastForward)}
|
||||||
|
disabled={!nowPlaying}
|
||||||
|
aria-label="Вперёд"
|
||||||
|
>
|
||||||
|
<span className="material-symbols-rounded">
|
||||||
|
fast_forward
|
||||||
|
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="remote-timeline">
|
<div className="remote-timeline">
|
||||||
@@ -519,6 +637,19 @@ function RemotePage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer className="remote-bottombar">
|
<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
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="remote-bottom-item"
|
className="remote-bottom-item"
|
||||||
@@ -582,10 +713,36 @@ function RemotePage() {
|
|||||||
</button>
|
</button>
|
||||||
</footer>
|
</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
|
<Menu
|
||||||
anchorEl={subtitleAnchor}
|
anchorEl={subtitleAnchor}
|
||||||
open={Boolean(subtitleAnchor)}
|
open={Boolean(subtitleAnchor)}
|
||||||
onClose={() => setSubtitleAnchor(null)}
|
onClose={() => setSubtitleAnchor(null)}
|
||||||
|
slotProps={{ paper: { className: "glass-menu-paper" } }}
|
||||||
>
|
>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
selected={subtitleIndex === -1}
|
selected={subtitleIndex === -1}
|
||||||
|
|||||||
+130
-207
@@ -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 { getPersonApi } from "@jellyfin/sdk/lib/utils/api/person-api";
|
||||||
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
|
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
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 { Card } from "@/components/card/card";
|
||||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import "./search.scss";
|
import "./search.scss";
|
||||||
import {
|
import {
|
||||||
AppBar,
|
|
||||||
Box,
|
Box,
|
||||||
Chip,
|
Chip,
|
||||||
Fade,
|
Fade,
|
||||||
@@ -22,16 +21,11 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
type SelectChangeEvent,
|
type SelectChangeEvent,
|
||||||
Typography,
|
Typography,
|
||||||
useScrollTrigger,
|
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { createFileRoute, Outlet, useNavigate } from "@tanstack/react-router";
|
import { createFileRoute, Outlet, useNavigate } from "@tanstack/react-router";
|
||||||
import { useShallow } from "zustand/shallow";
|
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 useDebounce from "@/utils/hooks/useDebounce";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/search/")({
|
export const Route = createFileRoute("/_api/search/")({
|
||||||
@@ -46,7 +40,11 @@ const CATEGORIES = [
|
|||||||
{ label: "Сериалы", value: "Series", kind: BaseItemKind.Series },
|
{ label: "Сериалы", value: "Series", kind: BaseItemKind.Series },
|
||||||
{ label: "Серии", value: "Episode", kind: "Episode" },
|
{ label: "Серии", value: "Episode", kind: "Episode" },
|
||||||
{ label: "Музыка", value: "MusicAlbum", kind: BaseItemKind.MusicAlbum },
|
{ 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: "Person", kind: "Person" },
|
||||||
{ label: "Книги", value: "Book", kind: BaseItemKind.Book },
|
{ label: "Книги", value: "Book", kind: BaseItemKind.Book },
|
||||||
];
|
];
|
||||||
@@ -100,7 +98,7 @@ function SearchPage() {
|
|||||||
className={`search-page-bg ${debouncedSearchTerm ? "active" : ""}`}
|
className={`search-page-bg ${debouncedSearchTerm ? "active" : ""}`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SearchAppBar
|
<SearchToolbar
|
||||||
searchTerm={searchTerm}
|
searchTerm={searchTerm}
|
||||||
setSearchTerm={setSearchTerm}
|
setSearchTerm={setSearchTerm}
|
||||||
selectedCategories={selectedCategories}
|
selectedCategories={selectedCategories}
|
||||||
@@ -147,7 +145,7 @@ function SearchPage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SearchAppBarProps {
|
interface SearchToolbarProps {
|
||||||
searchTerm: string;
|
searchTerm: string;
|
||||||
setSearchTerm: (term: string) => void;
|
setSearchTerm: (term: string) => void;
|
||||||
selectedCategories: string[];
|
selectedCategories: string[];
|
||||||
@@ -155,216 +153,141 @@ interface SearchAppBarProps {
|
|||||||
handleClearCategories: () => void;
|
handleClearCategories: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SearchAppBar({
|
function SearchToolbar({
|
||||||
searchTerm,
|
searchTerm,
|
||||||
setSearchTerm,
|
setSearchTerm,
|
||||||
selectedCategories,
|
selectedCategories,
|
||||||
handleCategoryChange,
|
handleCategoryChange,
|
||||||
handleClearCategories,
|
handleClearCategories,
|
||||||
}: SearchAppBarProps) {
|
}: SearchToolbarProps) {
|
||||||
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);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="search-toolbar">
|
||||||
<AppBar
|
<Box className="search-input-container">
|
||||||
className={
|
<span className="material-symbols-rounded search-icon">search</span>
|
||||||
scrollTrigger
|
<InputBase
|
||||||
? "appBar search-header scrolling flex flex-row"
|
className="search-input"
|
||||||
: "appBar search-header flex flex-row"
|
placeholder="Поиск в библиотеке..."
|
||||||
}
|
fullWidth
|
||||||
style={appBarStyling}
|
autoFocus
|
||||||
elevation={0}
|
value={searchTerm}
|
||||||
color="transparent"
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
>
|
endAdornment={
|
||||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
searchTerm && (
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => setShowDrawer(true)}
|
size="small"
|
||||||
aria-label="Открыть меню"
|
onClick={() => setSearchTerm("")}
|
||||||
title="Открыть меню"
|
sx={{ color: "white" }}
|
||||||
>
|
>
|
||||||
<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" }}
|
|
||||||
>
|
|
||||||
<Box className="search-input-container">
|
|
||||||
<span className="material-symbols-rounded search-icon">search</span>
|
|
||||||
<InputBase
|
|
||||||
className="search-input"
|
|
||||||
placeholder="Поиск в библиотеке..."
|
|
||||||
fullWidth
|
|
||||||
autoFocus
|
|
||||||
value={searchTerm}
|
|
||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
|
||||||
endAdornment={
|
|
||||||
searchTerm && (
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
onClick={() => setSearchTerm("")}
|
|
||||||
sx={{ color: "white" }}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className="material-symbols-rounded"
|
|
||||||
style={{ fontSize: "1.2rem" }}
|
|
||||||
>
|
|
||||||
close
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
size="small"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormControl size="small" className="search-category-select">
|
|
||||||
<Select
|
|
||||||
multiple
|
|
||||||
displayEmpty
|
|
||||||
value={selectedCategories}
|
|
||||||
onChange={handleCategoryChange}
|
|
||||||
input={
|
|
||||||
<OutlinedInput
|
|
||||||
endAdornment={
|
|
||||||
selectedCategories.length > 0 && (
|
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
onMouseDown={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
}}
|
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
handleClearCategories();
|
|
||||||
}}
|
|
||||||
sx={{ p: 0.5 }}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className="material-symbols-rounded"
|
|
||||||
style={{ fontSize: "1rem" }}
|
|
||||||
>
|
|
||||||
close
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
IconComponent={(props) => (
|
|
||||||
<span
|
<span
|
||||||
{...props}
|
className="material-symbols-rounded"
|
||||||
className={`material-symbols-rounded ${props.className}`}
|
style={{ fontSize: "1.2rem" }}
|
||||||
>
|
>
|
||||||
expand_more
|
close
|
||||||
</span>
|
</span>
|
||||||
)}
|
</IconButton>
|
||||||
renderValue={(selected) => {
|
)
|
||||||
if (selected.length === 0)
|
}
|
||||||
return (
|
size="small"
|
||||||
<Typography
|
/>
|
||||||
variant="body2"
|
|
||||||
color="textSecondary"
|
<FormControl size="small" className="search-category-select">
|
||||||
sx={{ opacity: 0.7 }}
|
<Select
|
||||||
|
multiple
|
||||||
|
displayEmpty
|
||||||
|
value={selectedCategories}
|
||||||
|
onChange={handleCategoryChange}
|
||||||
|
input={
|
||||||
|
<OutlinedInput
|
||||||
|
endAdornment={
|
||||||
|
selectedCategories.length > 0 && (
|
||||||
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
onMouseDown={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
}}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
handleClearCategories();
|
||||||
|
}}
|
||||||
|
sx={{ p: 0.5 }}
|
||||||
>
|
>
|
||||||
Типы
|
<span
|
||||||
</Typography>
|
className="material-symbols-rounded"
|
||||||
);
|
style={{ fontSize: "1rem" }}
|
||||||
|
>
|
||||||
|
close
|
||||||
|
</span>
|
||||||
|
</IconButton>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
IconComponent={(props) => (
|
||||||
|
<span
|
||||||
|
{...props}
|
||||||
|
className={`material-symbols-rounded ${props.className}`}
|
||||||
|
>
|
||||||
|
expand_more
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
renderValue={(selected) => {
|
||||||
|
if (selected.length === 0)
|
||||||
return (
|
return (
|
||||||
<Box
|
<Typography
|
||||||
sx={{
|
variant="body2"
|
||||||
display: "flex",
|
color="textSecondary"
|
||||||
flexWrap: "nowrap",
|
sx={{ opacity: 0.7 }}
|
||||||
gap: 0.5,
|
|
||||||
overflow: "hidden",
|
|
||||||
maxWidth: "100%",
|
|
||||||
maskImage:
|
|
||||||
"linear-gradient(to right, black 85%, transparent 100%)",
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{selected.map((value) => {
|
Типы
|
||||||
const label =
|
</Typography>
|
||||||
CATEGORIES.find((c) => c.value === value)?.label ||
|
|
||||||
value;
|
|
||||||
return (
|
|
||||||
<Chip
|
|
||||||
key={value}
|
|
||||||
label={label}
|
|
||||||
size="small"
|
|
||||||
sx={{ height: 24 }}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Box>
|
|
||||||
);
|
);
|
||||||
}}
|
return (
|
||||||
MenuProps={{
|
<Box
|
||||||
slotProps: { paper: { className: "glass-menu-paper" } },
|
sx={{
|
||||||
disableScrollLock: true,
|
display: "flex",
|
||||||
}}
|
flexWrap: "nowrap",
|
||||||
size="small"
|
gap: 0.5,
|
||||||
>
|
overflow: "hidden",
|
||||||
<MenuItem disabled value="">
|
maxWidth: "100%",
|
||||||
<Typography variant="overline" color="textSecondary">
|
maskImage:
|
||||||
Фильтр по типу
|
"linear-gradient(to right, black 85%, transparent 100%)",
|
||||||
</Typography>
|
}}
|
||||||
|
>
|
||||||
|
{selected.map((value) => {
|
||||||
|
const label =
|
||||||
|
CATEGORIES.find((c) => c.value === value)?.label || value;
|
||||||
|
return (
|
||||||
|
<Chip
|
||||||
|
key={value}
|
||||||
|
label={label}
|
||||||
|
size="small"
|
||||||
|
sx={{ height: 24 }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
MenuProps={{
|
||||||
|
slotProps: { paper: { className: "glass-menu-paper" } },
|
||||||
|
disableScrollLock: true,
|
||||||
|
}}
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<MenuItem disabled value="">
|
||||||
|
<Typography variant="overline" color="textSecondary">
|
||||||
|
Фильтр по типу
|
||||||
|
</Typography>
|
||||||
|
</MenuItem>
|
||||||
|
{CATEGORIES.map((cat) => (
|
||||||
|
<MenuItem key={cat.value} value={cat.value}>
|
||||||
|
{cat.label}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{CATEGORIES.map((cat) => (
|
))}
|
||||||
<MenuItem key={cat.value} value={cat.value}>
|
</Select>
|
||||||
{cat.label}
|
</FormControl>
|
||||||
</MenuItem>
|
</Box>
|
||||||
))}
|
</div>
|
||||||
</Select>
|
|
||||||
</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)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+174
-234
@@ -1,248 +1,188 @@
|
|||||||
|
|
||||||
.search-page {
|
.search-page {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
// Glossy subtle background animation - fixed to viewport so it stays while scrolling
|
|
||||||
&-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%);
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0.8s ease;
|
|
||||||
pointer-events: none;
|
|
||||||
z-index: 0;
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
|
||||||
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
|
|
||||||
|
|
||||||
&:hover, &:focus-within {
|
|
||||||
background: rgba(255, 255, 255, 0.1);
|
|
||||||
border-color: rgba(255, 255, 255, 0.15);
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-category-select {
|
/* Glossy background that stays put while the results scroll. */
|
||||||
flex-shrink: 0;
|
&-bg {
|
||||||
max-width: 40%;
|
position: fixed;
|
||||||
|
top: -50%;
|
||||||
.MuiSelect-select {
|
left: -50%;
|
||||||
padding-right: 24px !important; // Make room for clear icon inside select if needed, though we put it in EndAdornment
|
right: -50%;
|
||||||
}
|
bottom: -50%;
|
||||||
}
|
background: radial-gradient(
|
||||||
}
|
circle at center,
|
||||||
|
rgba(var(--mui-palette-primary-mainChannel), 0.15) 0%,
|
||||||
.search-input {
|
transparent 60%
|
||||||
flex-grow: 1;
|
);
|
||||||
|
opacity: 0;
|
||||||
.MuiInputBase-input {
|
transition: opacity 0.8s ease;
|
||||||
font-size: 1rem;
|
pointer-events: none;
|
||||||
padding: 4px 8px;
|
z-index: 0;
|
||||||
color: white;
|
|
||||||
|
|
||||||
&::placeholder {
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-icon {
|
|
||||||
font-size: 1.2rem;
|
|
||||||
opacity: 0.7;
|
|
||||||
margin-right: 8px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-category-select {
|
|
||||||
flex-shrink: 0;
|
|
||||||
min-width: 120px;
|
|
||||||
margin-left: 8px;
|
|
||||||
|
|
||||||
.MuiOutlinedInput-root {
|
|
||||||
border-radius: 20px;
|
|
||||||
background-color: transparent ;
|
|
||||||
color: rgba(255, 255, 255, 0.9);
|
|
||||||
height: 36px;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
|
|
||||||
fieldset { border: none; }
|
|
||||||
|
|
||||||
// Keep the clear button clear of the absolutely positioned dropdown arrow
|
&.active {
|
||||||
&.MuiInputBase-adornedEnd {
|
opacity: 1;
|
||||||
padding-right: 32px;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&-content {
|
||||||
background-color: rgba(255, 255, 255, 0.05);
|
flex-grow: 1;
|
||||||
}
|
width: 100%;
|
||||||
}
|
align-self: center;
|
||||||
}
|
z-index: 1;
|
||||||
|
}
|
||||||
&-empty-state {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 60vh; // Take up vertical space to look nice
|
|
||||||
text-align: center;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
.icon-stack {
|
|
||||||
position: relative;
|
|
||||||
height: 120px;
|
|
||||||
width: 200px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
|
|
||||||
.icon-lg {
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
.icon-md {
|
|
||||||
font-size: 3.5rem;
|
|
||||||
position: absolute;
|
|
||||||
right: 30px;
|
|
||||||
top: 10px;
|
|
||||||
opacity: 0.4;
|
|
||||||
transform: rotate(15deg);
|
|
||||||
}
|
|
||||||
.icon-sm {
|
|
||||||
font-size: 3rem;
|
|
||||||
position: absolute;
|
|
||||||
left: 40px;
|
|
||||||
bottom: 10px;
|
|
||||||
opacity: 0.3;
|
|
||||||
transform: rotate(-10deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-no-results {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 4em;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
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;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus-within {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border-color: rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-category-select {
|
||||||
|
flex-shrink: 0;
|
||||||
|
max-width: 40%;
|
||||||
|
|
||||||
|
.MuiSelect-select {
|
||||||
|
padding-right: 24px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
flex-grow: 1;
|
||||||
|
|
||||||
|
.MuiInputBase-input {
|
||||||
|
font-size: 1rem;
|
||||||
|
padding: 4px 8px;
|
||||||
|
color: white;
|
||||||
|
|
||||||
|
&::placeholder {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-icon {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
opacity: 0.7;
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-category-select {
|
||||||
|
flex-shrink: 0;
|
||||||
|
min-width: 120px;
|
||||||
|
margin-left: 8px;
|
||||||
|
|
||||||
|
.MuiOutlinedInput-root {
|
||||||
|
border-radius: 20px;
|
||||||
|
background-color: transparent;
|
||||||
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
height: 36px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
fieldset {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.MuiInputBase-adornedEnd {
|
||||||
|
padding-right: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-empty-state {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 60vh;
|
||||||
|
text-align: center;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.icon-stack {
|
||||||
|
position: relative;
|
||||||
|
height: 120px;
|
||||||
|
width: 200px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
|
||||||
|
.icon-lg {
|
||||||
|
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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
.icon-md {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
position: absolute;
|
||||||
|
right: 30px;
|
||||||
|
top: 10px;
|
||||||
|
opacity: 0.4;
|
||||||
|
transform: rotate(15deg);
|
||||||
|
}
|
||||||
|
.icon-sm {
|
||||||
|
font-size: 3rem;
|
||||||
|
position: absolute;
|
||||||
|
left: 40px;
|
||||||
|
bottom: 10px;
|
||||||
|
opacity: 0.3;
|
||||||
|
transform: rotate(-10deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-no-results {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 4em;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 900px) {
|
@media (max-width: 900px) {
|
||||||
.search-page .search-header {
|
.search-toolbar {
|
||||||
inset: calc(0.5em + var(--safe-top)) 0.5em auto 0.5em !important;
|
padding-bottom: 1rem;
|
||||||
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-input-container {
|
|
||||||
height: 42px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-category-select {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
> .flex.flex-row:last-child [aria-label="Избранное"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-page-content {
|
.search-input-container {
|
||||||
padding: calc(8.4em + var(--safe-top)) 1rem calc(8rem + var(--safe-bottom));
|
height: 42px;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
.search-category-select {
|
||||||
@media (min-width: 701px) and (max-width: 900px) {
|
display: none;
|
||||||
.search-page .search-header {
|
|
||||||
.search-category-select {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
> .flex.flex-row:last-child [aria-label="Избранное"] {
|
|
||||||
display: inline-flex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,52 @@
|
|||||||
@use "../../styles/variables.scss" as *;
|
@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 {
|
.settings {
|
||||||
&-page {
|
&-page {
|
||||||
&-container {
|
&-container {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 16em 1fr;
|
grid-template-columns: 16em 1fr;
|
||||||
padding: 0;
|
padding: var(--app-titlebar-height) 0 0;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
box-sizing: border-box;
|
||||||
// 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 {
|
&-scrollY {
|
||||||
padding: 2em;
|
padding: 2em;
|
||||||
@@ -89,27 +120,6 @@
|
|||||||
border-radius: 999px;
|
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 {
|
&-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -198,10 +208,21 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media (max-width: 700px) {
|
@media (max-width: 700px) {
|
||||||
|
.settings-device-name-row {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
|
||||||
|
.MuiButton-root {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.settings-page-container {
|
.settings-page-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
padding-top: var(--app-titlebar-height);
|
||||||
|
box-sizing: border-box;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,28 +232,18 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.25em;
|
gap: 0.25em;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: calc(0.4rem + var(--safe-top)) 0.6rem 0.4rem;
|
padding: 0.4rem 0.6rem;
|
||||||
border-right: 0;
|
border-right: 0;
|
||||||
border-bottom: 1px solid rgb(255 255 255 / 0.06);
|
border-bottom: 1px solid rgb(255 255 255 / 0.06);
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
html.is-macos & {
|
|
||||||
padding-top: calc(0.4rem + var(--safe-top));
|
|
||||||
padding-left: 76px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-sidebar-header {
|
.settings-sidebar-header {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-sidebar-controls {
|
|
||||||
padding-bottom: 0;
|
|
||||||
gap: 0.15em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-sidebar-list {
|
.settings-sidebar-list {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -317,15 +328,6 @@
|
|||||||
padding-right: 2em !important;
|
padding-right: 2em !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-sidebar-controls {
|
|
||||||
display: flex;
|
|
||||||
flex: 0 0 auto;
|
|
||||||
|
|
||||||
[aria-label="Главная"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-page-scrollY {
|
.settings-page-scrollY {
|
||||||
padding: 0.75rem 1rem calc(7.5rem + var(--safe-bottom)) !important;
|
padding: 0.75rem 1rem calc(7.5rem + var(--safe-bottom)) !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,10 @@
|
|||||||
import {
|
import { createFileRoute, Outlet, useLocation } from "@tanstack/react-router";
|
||||||
createFileRoute,
|
import React, { useEffect } from "react";
|
||||||
Outlet,
|
|
||||||
useLocation,
|
|
||||||
useNavigate,
|
|
||||||
} from "@tanstack/react-router";
|
|
||||||
import React, { useCallback, useEffect } from "react";
|
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
|
|
||||||
import "./settings.scss";
|
import "./settings.scss";
|
||||||
import { IconButton, List, Typography } from "@mui/material";
|
import { List, Typography } from "@mui/material";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import BackButton from "@/components/buttons/backButton";
|
|
||||||
import ListItemLink from "@/components/listItemLink";
|
import ListItemLink from "@/components/listItemLink";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
@@ -26,11 +20,7 @@ function SettingsRoute() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setBackdrop("");
|
setBackdrop("");
|
||||||
});
|
});
|
||||||
const navigate = useNavigate();
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const handleNavigateHome = useCallback(() => {
|
|
||||||
navigate({ to: "/home" });
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const active = document.querySelector(
|
const active = document.querySelector(
|
||||||
@@ -39,23 +29,8 @@ function SettingsRoute() {
|
|||||||
active?.scrollIntoView({ block: "nearest", inline: "center" });
|
active?.scrollIntoView({ block: "nearest", inline: "center" });
|
||||||
}, [location.pathname]);
|
}, [location.pathname]);
|
||||||
return (
|
return (
|
||||||
<div className="settings-page-container" data-tauri-drag-region>
|
<div className="settings-page-container">
|
||||||
<div className="settings-sidebar">
|
<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">
|
<div className="settings-sidebar-header">
|
||||||
<img
|
<img
|
||||||
className="settings-sidebar-header-image"
|
className="settings-sidebar-header-image"
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import {
|
||||||
|
getDefaultDeviceName,
|
||||||
|
getDeviceDisplayName,
|
||||||
|
getOrCreateDeviceId,
|
||||||
|
setDeviceDisplayName,
|
||||||
|
} from "@/utils/deviceIdentity";
|
||||||
|
|
||||||
import "../settings.scss";
|
import "../settings.scss";
|
||||||
import { getLocalizationApi } from "@jellyfin/sdk/lib/utils/api/localization-api";
|
import { getLocalizationApi } from "@jellyfin/sdk/lib/utils/api/localization-api";
|
||||||
@@ -38,6 +44,19 @@ function RouteComponent() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
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({
|
const form = useForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
@@ -81,6 +100,27 @@ function RouteComponent() {
|
|||||||
return (
|
return (
|
||||||
<div className="settings-page-scrollY">
|
<div className="settings-page-scrollY">
|
||||||
<Typography variant="h4">Настройки</Typography>
|
<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.Pro */}
|
||||||
<form
|
<form
|
||||||
onSubmit={(e) => {
|
onSubmit={(e) => {
|
||||||
@@ -89,7 +129,9 @@ function RouteComponent() {
|
|||||||
form.handleSubmit();
|
form.handleSubmit();
|
||||||
}}
|
}}
|
||||||
onError={() =>
|
onError={() =>
|
||||||
enqueueSnackbar("Не удалось сохранить настройки", { variant: "error" })
|
enqueueSnackbar("Не удалось сохранить настройки", {
|
||||||
|
variant: "error",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
className="settings-form"
|
className="settings-form"
|
||||||
>
|
>
|
||||||
@@ -171,14 +213,15 @@ function RouteComponent() {
|
|||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Воспроизводить аудиодорожку по умолчанию независимо от языка
|
Воспроизводить аудиодорожку по умолчанию независимо от
|
||||||
|
языка
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
variant="caption"
|
variant="caption"
|
||||||
className="settings-option-info-caption"
|
className="settings-option-info-caption"
|
||||||
>
|
>
|
||||||
Воспроизводить аудиодорожку по умолчанию, даже если она
|
Воспроизводить аудиодорожку по умолчанию, даже если она не
|
||||||
не совпадает с предпочитаемым языком.
|
совпадает с предпочитаемым языком.
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-20
@@ -177,28 +177,26 @@ body {
|
|||||||
the content changes underneath them. */
|
the content changes underneath them. */
|
||||||
@supports (view-transition-name: none) {
|
@supports (view-transition-name: none) {
|
||||||
::view-transition-group(root) {
|
::view-transition-group(root) {
|
||||||
animation-duration: 300ms;
|
animation-duration: 320ms;
|
||||||
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
|
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
::view-transition-old(root),
|
::view-transition-old(root),
|
||||||
::view-transition-new(root) {
|
::view-transition-new(root) {
|
||||||
animation-fill-mode: both;
|
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;
|
mix-blend-mode: normal;
|
||||||
transform-origin: 50% 42%;
|
will-change: opacity;
|
||||||
will-change: opacity, transform, filter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::view-transition-old(root) {
|
::view-transition-old(root) {
|
||||||
animation-name: routeExit;
|
animation-name: routeExit;
|
||||||
animation-duration: 180ms;
|
animation-duration: 220ms;
|
||||||
animation-timing-function: cubic-bezier(0.4, 0, 1, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::view-transition-new(root) {
|
::view-transition-new(root) {
|
||||||
animation-name: routeEnter;
|
animation-name: routeEnter;
|
||||||
animation-duration: 300ms;
|
animation-duration: 320ms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,26 +211,18 @@ body {
|
|||||||
@keyframes routeExit {
|
@keyframes routeExit {
|
||||||
from {
|
from {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translateY(0) scale(1);
|
|
||||||
filter: blur(0);
|
|
||||||
}
|
}
|
||||||
to {
|
to {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(-5px) scale(0.995);
|
|
||||||
filter: blur(2px);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes routeEnter {
|
@keyframes routeEnter {
|
||||||
from {
|
from {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(14px) scale(1.003);
|
|
||||||
filter: blur(6px);
|
|
||||||
}
|
}
|
||||||
to {
|
to {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: translateY(0) scale(1);
|
|
||||||
filter: blur(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,9 +298,9 @@ h1 {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
padding: ($page-margin - 1.2em) $page-margin;
|
padding: calc(var(--app-titlebar-height) + 1.5rem) $page-margin 1.5rem;
|
||||||
&.padded-top {
|
&.padded-top {
|
||||||
padding-top: 4.4em;
|
padding-top: calc(var(--app-titlebar-height) + 1.5rem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,11 +492,13 @@ a {
|
|||||||
|
|
||||||
@media (max-width: 700px) {
|
@media (max-width: 700px) {
|
||||||
.scrollY {
|
.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 {
|
.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 { secToTicks, ticksToSec } from "@/utils/date/time";
|
||||||
import {
|
import {
|
||||||
|
setAudioPlaying,
|
||||||
setVolume as setAudioVolume,
|
setVolume as setAudioVolume,
|
||||||
setIsMuted,
|
setIsMuted,
|
||||||
stopPlayback,
|
stopPlayback,
|
||||||
@@ -12,6 +13,8 @@ export type LocalPlaybackSnapshot = {
|
|||||||
itemId: string | null;
|
itemId: string | null;
|
||||||
positionTicks: number;
|
positionTicks: number;
|
||||||
paused: boolean;
|
paused: boolean;
|
||||||
|
/** True once media is actually loaded enough to start in sync. */
|
||||||
|
ready: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getVideoElement = () =>
|
const getVideoElement = () =>
|
||||||
@@ -23,11 +26,23 @@ const getVideoElement = () =>
|
|||||||
export const getLocalPlayback = (): LocalPlaybackSnapshot => {
|
export const getLocalPlayback = (): LocalPlaybackSnapshot => {
|
||||||
const video = usePlaybackStore.getState();
|
const video = usePlaybackStore.getState();
|
||||||
if (video.playbackStream && video.metadata.item?.Id) {
|
if (video.playbackStream && video.metadata.item?.Id) {
|
||||||
|
const videoElement = getVideoElement();
|
||||||
return {
|
return {
|
||||||
kind: "video",
|
kind: "video",
|
||||||
itemId: video.metadata.item.Id,
|
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,
|
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)
|
? secToTicks(element.currentTime)
|
||||||
: audio.player.currentTick,
|
: audio.player.currentTick,
|
||||||
paused: element ? element.paused : !audio.player.playing,
|
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 = () => {
|
export const pauseLocalPlayback = () => {
|
||||||
@@ -54,6 +76,9 @@ export const pauseLocalPlayback = () => {
|
|||||||
video.setIsPlaying(false);
|
video.setIsPlaying(false);
|
||||||
}
|
}
|
||||||
useAudioPlayback.getState().player.ref?.current?.pause();
|
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 = () => {
|
export const resumeLocalPlayback = () => {
|
||||||
@@ -68,6 +93,7 @@ export const resumeLocalPlayback = () => {
|
|||||||
}
|
}
|
||||||
const audio = useAudioPlayback.getState();
|
const audio = useAudioPlayback.getState();
|
||||||
if (audio.display && audio.item?.Id) {
|
if (audio.display && audio.item?.Id) {
|
||||||
|
setAudioPlaying(true);
|
||||||
audio.player.ref?.current?.play().catch(() => undefined);
|
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,
|
SendCommandType,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getSyncPlayApi } from "@jellyfin/sdk/lib/utils/api/sync-play-api";
|
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 {
|
import {
|
||||||
getLocalPlayback,
|
getLocalPlayback,
|
||||||
pauseLocalPlayback,
|
pauseLocalPlayback,
|
||||||
resumeLocalPlayback,
|
resumeLocalPlayback,
|
||||||
seekLocalPlayback,
|
seekLocalPlayback,
|
||||||
} from "@/utils/methods/localPlayback";
|
} from "@/utils/methods/localPlayback";
|
||||||
|
import { isLocalMediaSwitching } from "@/utils/methods/mediaSwitch";
|
||||||
import { startPlaybackFromIds } from "@/utils/methods/startPlayback";
|
import { startPlaybackFromIds } from "@/utils/methods/startPlayback";
|
||||||
import useQueue from "@/utils/store/queue";
|
import useQueue from "@/utils/store/queue";
|
||||||
import useSyncPlayStore from "@/utils/store/syncPlay";
|
import useSyncPlayStore from "@/utils/store/syncPlay";
|
||||||
@@ -19,13 +27,35 @@ import useSyncPlayStore from "@/utils/store/syncPlay";
|
|||||||
const SEEK_REPORT_INTERVAL_MS = 300;
|
const SEEK_REPORT_INTERVAL_MS = 300;
|
||||||
const PAUSE_REPORT_INTERVAL_MS = 400;
|
const PAUSE_REPORT_INTERVAL_MS = 400;
|
||||||
const AUTO_START_GUARD_MS = 5000;
|
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 applyingRemoteUntil = 0;
|
||||||
let lastSeekReport = { at: 0, ticks: 0 };
|
let lastSeekReport = { at: 0, ticks: 0 };
|
||||||
let lastPauseReport = { at: 0, paused: false };
|
let lastPauseReport = { at: 0, paused: false };
|
||||||
let lastAutoStart = { itemId: "", at: 0 };
|
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 syncApi = (api: Api) => getSyncPlayApi(api);
|
||||||
|
|
||||||
const guardRemote = (ms = 1200) => {
|
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) => {
|
export const refreshSyncPlayGroups = async (api: Api) => {
|
||||||
const store = useSyncPlayStore.getState();
|
const store = useSyncPlayStore.getState();
|
||||||
try {
|
try {
|
||||||
const groups = (await syncApi(api).syncPlayGetGroups()).data ?? [];
|
const groups = ((await syncApi(api).syncPlayGetGroups()).data ?? []).filter(
|
||||||
|
isBlinkGroup,
|
||||||
|
);
|
||||||
store.setGroups(groups);
|
store.setGroups(groups);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn("Could not load SyncPlay groups", error);
|
console.warn("Could not load SyncPlay groups", error);
|
||||||
@@ -64,6 +170,19 @@ export const refreshSyncPlayGroup = async (api: Api) => {
|
|||||||
.data;
|
.data;
|
||||||
if (fresh) useSyncPlayStore.getState().setGroup(fresh);
|
if (fresh) useSyncPlayStore.getState().setGroup(fresh);
|
||||||
} catch (error) {
|
} 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);
|
console.warn("Could not refresh SyncPlay group", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -81,9 +200,13 @@ export const createSyncPlayGroup = async (api: Api, name: string) => {
|
|||||||
store.setLoading(true);
|
store.setLoading(true);
|
||||||
store.setError(null);
|
store.setError(null);
|
||||||
try {
|
try {
|
||||||
|
const visibleName = name.trim() || "Смотреть вместе";
|
||||||
|
const groupName = visibleName.startsWith(BLINK_GROUP_PREFIX)
|
||||||
|
? visibleName
|
||||||
|
: `${BLINK_GROUP_PREFIX} ${visibleName}`;
|
||||||
const group = (
|
const group = (
|
||||||
await syncApi(api).syncPlayCreateGroup({
|
await syncApi(api).syncPlayCreateGroup({
|
||||||
newGroupRequestDto: { GroupName: name.trim() || "Смотреть вместе" },
|
newGroupRequestDto: { GroupName: groupName },
|
||||||
})
|
})
|
||||||
).data;
|
).data;
|
||||||
if (group) {
|
if (group) {
|
||||||
@@ -97,7 +220,7 @@ export const createSyncPlayGroup = async (api: Api, name: string) => {
|
|||||||
return group;
|
return group;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Could not create SyncPlay group", error);
|
console.error("Could not create SyncPlay group", error);
|
||||||
store.setError("Не удалось создать группу");
|
store.setError("Не удалось создать группу Blink");
|
||||||
return undefined;
|
return undefined;
|
||||||
} finally {
|
} finally {
|
||||||
store.setLoading(false);
|
store.setLoading(false);
|
||||||
@@ -109,20 +232,19 @@ export const joinSyncPlayGroup = async (api: Api, groupId: string) => {
|
|||||||
store.setLoading(true);
|
store.setLoading(true);
|
||||||
store.setError(null);
|
store.setError(null);
|
||||||
try {
|
try {
|
||||||
|
const group = (await syncApi(api).syncPlayGetGroup({ id: groupId })).data;
|
||||||
|
if (!group || !isBlinkGroup(group)) {
|
||||||
|
store.setError("Можно входить только в группы Blink");
|
||||||
|
return;
|
||||||
|
}
|
||||||
await syncApi(api).syncPlayJoinGroup({
|
await syncApi(api).syncPlayJoinGroup({
|
||||||
joinGroupRequestDto: { GroupId: groupId },
|
joinGroupRequestDto: { GroupId: groupId },
|
||||||
});
|
});
|
||||||
try {
|
store.setGroup(group);
|
||||||
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);
|
|
||||||
}
|
|
||||||
await refreshSyncPlayGroups(api);
|
await refreshSyncPlayGroups(api);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Could not join SyncPlay group", error);
|
console.error("Could not join SyncPlay group", error);
|
||||||
store.setError("Не удалось войти в группу");
|
store.setError("Не удалось войти в группу Blink");
|
||||||
} finally {
|
} finally {
|
||||||
store.setLoading(false);
|
store.setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -138,9 +260,70 @@ export const leaveSyncPlayGroup = async (api: Api) => {
|
|||||||
} finally {
|
} finally {
|
||||||
store.setLoading(false);
|
store.setLoading(false);
|
||||||
store.reset();
|
store.reset();
|
||||||
|
store.setAutoJoin(false);
|
||||||
store.setOpen(false);
|
store.setOpen(false);
|
||||||
lastAutoStart = { itemId: "", at: 0 };
|
lastAutoStart = { itemId: "", at: 0 };
|
||||||
applyingRemoteUntil = 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,
|
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) {
|
} catch (error) {
|
||||||
console.error("Could not start SyncPlay queue", error);
|
console.error("Could not start SyncPlay queue", error);
|
||||||
store.setError("Не удалось запустить очередь группы");
|
store.setError("Не удалось запустить очередь группы");
|
||||||
@@ -197,11 +374,6 @@ export const watchSyncPlayQueueHere = async (api: Api, userId: string) => {
|
|||||||
if (result.kind !== "none") {
|
if (result.kind !== "none") {
|
||||||
store.setPendingNavigation(result.kind);
|
store.setPendingNavigation(result.kind);
|
||||||
if (queue && !queue.IsPlaying) pauseLocalPlayback();
|
if (queue && !queue.IsPlaying) pauseLocalPlayback();
|
||||||
if ((store.group?.Participants?.length ?? 0) <= 1) {
|
|
||||||
window.setTimeout(() => {
|
|
||||||
void resumeSyncPlayGroup(api);
|
|
||||||
}, 900);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Could not start the group queue here", 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) => {
|
export const pingSyncPlayGroup = async (api: Api) => {
|
||||||
|
if (pingInFlight) return;
|
||||||
|
pingInFlight = true;
|
||||||
|
const started = performance.now();
|
||||||
try {
|
try {
|
||||||
await syncApi(api).syncPlayPing({
|
await syncApi(api).syncPlayPing({
|
||||||
// This is the measured latency in milliseconds, not a timestamp.
|
// This is the measured round-trip latency, not the clock. The server
|
||||||
// The server clamps it to 10s; a huge value would delay every
|
// clamps it to 10s and uses it to schedule pause/unpause commands.
|
||||||
// scheduled pause/unpause, so report a conservative local value.
|
pingRequestDto: { Ping: Math.round(pingEstimateMs) },
|
||||||
pingRequestDto: { Ping: 50 },
|
|
||||||
});
|
});
|
||||||
|
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) {
|
} catch (error) {
|
||||||
console.warn("Could not ping SyncPlay group", 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) {
|
if (Math.abs(local.positionTicks - position) > DRIFT_TOLERANCE_TICKS) {
|
||||||
seekLocalPlayback(position);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +506,12 @@ const applyQueueUpdate = async (
|
|||||||
});
|
});
|
||||||
if (result.kind !== "none") {
|
if (result.kind !== "none") {
|
||||||
store.setPendingNavigation(result.kind);
|
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) {
|
} catch (error) {
|
||||||
console.error("Could not follow the SyncPlay queue", error);
|
console.error("Could not follow the SyncPlay queue", error);
|
||||||
@@ -335,7 +531,15 @@ export const handleSyncPlayGroupUpdate = async (
|
|||||||
break;
|
break;
|
||||||
case "PlayQueue":
|
case "PlayQueue":
|
||||||
if (update.Data) {
|
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);
|
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);
|
await applyQueueUpdate(api, userId, update.Data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -343,11 +547,11 @@ export const handleSyncPlayGroupUpdate = async (
|
|||||||
const group = store.group;
|
const group = store.group;
|
||||||
if (group && update.Data?.State) {
|
if (group && update.Data?.State) {
|
||||||
store.setGroup({ ...group, State: update.Data.State });
|
store.setGroup({ ...group, State: update.Data.State });
|
||||||
|
groupStateChangedAt = Date.now();
|
||||||
}
|
}
|
||||||
if (update.Data?.State === "Paused") {
|
// Playback itself is driven by the scheduled Pause/Unpause/Seek
|
||||||
guardRemote();
|
// commands: they carry the server timestamp and position. Acting on
|
||||||
pauseLocalPlayback();
|
// the state update too would resume clients at different instants.
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "UserJoined":
|
case "UserJoined":
|
||||||
@@ -362,6 +566,7 @@ export const handleSyncPlayGroupUpdate = async (
|
|||||||
store.setOpen(false);
|
store.setOpen(false);
|
||||||
lastAutoStart = { itemId: "", at: 0 };
|
lastAutoStart = { itemId: "", at: 0 };
|
||||||
applyingRemoteUntil = 0;
|
applyingRemoteUntil = 0;
|
||||||
|
resetSyncPlayTimeline();
|
||||||
break;
|
break;
|
||||||
case "LibraryAccessDenied":
|
case "LibraryAccessDenied":
|
||||||
useSyncPlayStore.getState().setError("Нет доступа к библиотеке группы");
|
useSyncPlayStore.getState().setError("Нет доступа к библиотеке группы");
|
||||||
@@ -372,8 +577,55 @@ export const handleSyncPlayGroupUpdate = async (
|
|||||||
export const handleSyncPlayCommand = (command: SendCommand) => {
|
export const handleSyncPlayCommand = (command: SendCommand) => {
|
||||||
const group = useSyncPlayStore.getState().group;
|
const group = useSyncPlayStore.getState().group;
|
||||||
if (!group) return;
|
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 = () => {
|
const apply = () => {
|
||||||
guardRemote(1500);
|
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) {
|
switch (command.Command) {
|
||||||
case SendCommandType.Pause:
|
case SendCommandType.Pause:
|
||||||
case SendCommandType.Stop:
|
case SendCommandType.Stop:
|
||||||
@@ -383,13 +635,13 @@ export const handleSyncPlayCommand = (command: SendCommand) => {
|
|||||||
resumeLocalPlayback();
|
resumeLocalPlayback();
|
||||||
break;
|
break;
|
||||||
case SendCommandType.Seek:
|
case SendCommandType.Seek:
|
||||||
if (command.PositionTicks != null) {
|
// Already aligned above from the command's own position. The
|
||||||
seekLocalPlayback(command.PositionTicks);
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const when = command.When ? Date.parse(command.When) : Number.NaN;
|
|
||||||
const delay = Number.isFinite(when)
|
const delay = Number.isFinite(when)
|
||||||
? Math.min(10_000, Math.max(0, when - Date.now()))
|
? Math.min(10_000, Math.max(0, when - Date.now()))
|
||||||
: 0;
|
: 0;
|
||||||
@@ -397,8 +649,97 @@ export const handleSyncPlayCommand = (command: SendCommand) => {
|
|||||||
else apply();
|
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) => {
|
export const reportSyncPlayPause = (api: Api | undefined) => {
|
||||||
if (!api || !inSyncPlayGroup() || isApplyingSyncPlayRemote()) return;
|
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();
|
const now = Date.now();
|
||||||
if (
|
if (
|
||||||
lastPauseReport.paused &&
|
lastPauseReport.paused &&
|
||||||
@@ -412,6 +753,11 @@ export const reportSyncPlayPause = (api: Api | undefined) => {
|
|||||||
|
|
||||||
export const reportSyncPlayResume = (api: Api | undefined) => {
|
export const reportSyncPlayResume = (api: Api | undefined) => {
|
||||||
if (!api || !inSyncPlayGroup() || isApplyingSyncPlayRemote()) return;
|
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();
|
const now = Date.now();
|
||||||
if (
|
if (
|
||||||
!lastPauseReport.paused &&
|
!lastPauseReport.paused &&
|
||||||
@@ -428,6 +774,11 @@ export const reportSyncPlaySeek = (
|
|||||||
positionTicks: number,
|
positionTicks: number,
|
||||||
) => {
|
) => {
|
||||||
if (!api || !inSyncPlayGroup() || isApplyingSyncPlayRemote()) return;
|
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();
|
const now = Date.now();
|
||||||
if (
|
if (
|
||||||
now - lastSeekReport.at < SEEK_REPORT_INTERVAL_MS ||
|
now - lastSeekReport.at < SEEK_REPORT_INTERVAL_MS ||
|
||||||
@@ -445,6 +796,7 @@ export const reportSyncPlayReady = (
|
|||||||
isPlaying: boolean,
|
isPlaying: boolean,
|
||||||
) => {
|
) => {
|
||||||
if (!api || !inSyncPlayGroup()) return;
|
if (!api || !inSyncPlayGroup()) return;
|
||||||
|
if (!localMatchesGroupItem()) return;
|
||||||
const queue = useSyncPlayStore.getState().queue;
|
const queue = useSyncPlayStore.getState().queue;
|
||||||
const item = currentQueueItem(queue);
|
const item = currentQueueItem(queue);
|
||||||
if (!item?.PlaylistItemId) return;
|
if (!item?.PlaylistItemId) return;
|
||||||
@@ -461,13 +813,6 @@ export const reportSyncPlayReady = (
|
|||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
void refreshSyncPlayGroup(api);
|
void refreshSyncPlayGroup(api);
|
||||||
}, 800);
|
}, 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));
|
.catch((error) => console.warn("SyncPlay ready failed", error));
|
||||||
};
|
};
|
||||||
@@ -479,6 +824,15 @@ export const reportSyncPlayBuffering = (
|
|||||||
isPlaying: boolean,
|
isPlaying: boolean,
|
||||||
) => {
|
) => {
|
||||||
if (!api || !inSyncPlayGroup()) return;
|
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 queue = useSyncPlayStore.getState().queue;
|
||||||
const item = currentQueueItem(queue);
|
const item = currentQueueItem(queue);
|
||||||
if (!item?.PlaylistItemId) return;
|
if (!item?.PlaylistItemId) return;
|
||||||
|
|||||||
@@ -50,10 +50,11 @@ export type PlayOnSessionOptions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start playback on another Jellyfin session and make sure it begins at the
|
* Start playback on another Jellyfin session and wait until the target
|
||||||
* requested position. Some clients accept the Play command but ignore
|
* actually reports the item. Some clients accept the Play command but never
|
||||||
* StartPositionTicks, so verify the reported position and send a Seek when
|
* start (or start much later), so the source must not stop its playback until
|
||||||
* they started from the beginning.
|
* 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 (
|
export const playOnSession = async (
|
||||||
api: Api,
|
api: Api,
|
||||||
@@ -65,49 +66,74 @@ export const playOnSession = async (
|
|||||||
|
|
||||||
const sessionApi = getSessionApi(api);
|
const sessionApi = getSessionApi(api);
|
||||||
const startPositionTicks = Math.max(0, options.startPositionTicks ?? 0);
|
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];
|
||||||
|
|
||||||
await sessionApi.play({
|
const readTarget = async () => {
|
||||||
sessionId,
|
|
||||||
playCommand: "PlayNow",
|
|
||||||
itemIds: options.itemIds,
|
|
||||||
startIndex: options.startIndex ?? 0,
|
|
||||||
startPositionTicks,
|
|
||||||
mediaSourceId: options.mediaSourceId,
|
|
||||||
});
|
|
||||||
|
|
||||||
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 {
|
try {
|
||||||
target = (await sessionApi.getSessions()).data.find(
|
return (await sessionApi.getSessions()).data.find(
|
||||||
(session) => session.Id === sessionId,
|
(session) => session.Id === sessionId,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch {
|
||||||
console.warn("Could not read the target session position", error);
|
return undefined;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if (!target?.NowPlayingItem) continue;
|
};
|
||||||
|
|
||||||
const paused = target.PlayState?.IsPaused ?? false;
|
const waitForItem = async (timeoutMs: number) => {
|
||||||
const expected =
|
const deadline = Date.now() + timeoutMs;
|
||||||
startPositionTicks + (paused ? 0 : delay * (TICKS_PER_SECOND / 1000));
|
while (Date.now() < deadline) {
|
||||||
const actual = target.PlayState?.PositionTicks ?? 0;
|
await sleep(500);
|
||||||
if (Math.abs(actual - expected) <= 8 * TICKS_PER_SECOND) return;
|
const target = await readTarget();
|
||||||
|
if (target?.NowPlayingItem?.Id === expectedItemId) return target;
|
||||||
try {
|
|
||||||
await sessionApi.sendPlaystateCommand({
|
|
||||||
sessionId,
|
|
||||||
command: PlaystateCommand.Seek,
|
|
||||||
seekPositionTicks: Math.round(expected),
|
|
||||||
controllingUserId: userId,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("Could not seek the target session", error);
|
|
||||||
}
|
}
|
||||||
|
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,
|
||||||
|
startPositionTicks,
|
||||||
|
mediaSourceId: options.mediaSourceId,
|
||||||
|
});
|
||||||
|
target = await waitForItem(attempt === 0 ? 6000 : 4000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target) {
|
||||||
|
throw new Error("Устройство не начало воспроизведение");
|
||||||
|
}
|
||||||
|
|
||||||
|
const paused = target.PlayState?.IsPaused ?? false;
|
||||||
|
const expected =
|
||||||
|
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;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await sessionApi.sendPlaystateCommand({
|
||||||
|
sessionId,
|
||||||
|
command: PlaystateCommand.Seek,
|
||||||
|
seekPositionTicks: Math.round(expected),
|
||||||
|
controllingUserId: userId,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("Could not seek the target session", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -170,7 +196,10 @@ export const transferSessionToLocal = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
let kind: "audio" | "video" = "video";
|
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";
|
kind = "audio";
|
||||||
const url = generateAudioStreamUrl(
|
const url = generateAudioStreamUrl(
|
||||||
item.Id,
|
item.Id,
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ import { useStoreWithEqualityFn } from "zustand/traditional";
|
|||||||
import { version as appVer } from "../../../package.json";
|
import { version as appVer } from "../../../package.json";
|
||||||
import { getDefaultServer, getServer } from "../storage/servers";
|
import { getDefaultServer, getServer } from "../storage/servers";
|
||||||
import { getUser } from "../storage/user";
|
import { getUser } from "../storage/user";
|
||||||
|
import {
|
||||||
|
getDeviceDisplayName,
|
||||||
|
getOrCreateDeviceId,
|
||||||
|
} from "../deviceIdentity";
|
||||||
|
|
||||||
// Initial custom axios client to use tauri's http module
|
// Initial custom axios client to use tauri's http module
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
@@ -29,11 +33,8 @@ export const axiosClient = axios.create({
|
|||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
});
|
});
|
||||||
|
|
||||||
const deviceId = localStorage.getItem("deviceId") || crypto.randomUUID();
|
const deviceId = getOrCreateDeviceId();
|
||||||
|
const deviceName = getDeviceDisplayName(deviceId);
|
||||||
if (!localStorage.getItem("deviceId")) {
|
|
||||||
localStorage.setItem("deviceId", deviceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const jellyfin = new Jellyfin({
|
export const jellyfin = new Jellyfin({
|
||||||
clientInfo: {
|
clientInfo: {
|
||||||
@@ -41,7 +42,7 @@ export const jellyfin = new Jellyfin({
|
|||||||
version: appVer,
|
version: appVer,
|
||||||
},
|
},
|
||||||
deviceInfo: {
|
deviceInfo: {
|
||||||
name: "Blink",
|
name: deviceName,
|
||||||
id: deviceId,
|
id: deviceId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|||||||
import type React from "react";
|
import type React from "react";
|
||||||
import { shallow } from "zustand/shallow";
|
import { shallow } from "zustand/shallow";
|
||||||
import { createWithEqualityFn } from "zustand/traditional";
|
import { createWithEqualityFn } from "zustand/traditional";
|
||||||
|
import { markLocalMediaSwitch } from "../methods/mediaSwitch";
|
||||||
import playbackProfile from "../playback-profiles";
|
import playbackProfile from "../playback-profiles";
|
||||||
import {
|
import {
|
||||||
getPlayerMuted,
|
getPlayerMuted,
|
||||||
@@ -59,6 +60,7 @@ export const playAudio = (
|
|||||||
playlistItemId?: string | undefined,
|
playlistItemId?: string | undefined,
|
||||||
startTimeTicks = 0,
|
startTimeTicks = 0,
|
||||||
): void => {
|
): void => {
|
||||||
|
markLocalMediaSwitch();
|
||||||
// Only one medium at a time: starting music stops video playback.
|
// Only one medium at a time: starting music stops video playback.
|
||||||
if (typeof document !== "undefined") {
|
if (typeof document !== "undefined") {
|
||||||
const video = (document
|
const video = (document
|
||||||
@@ -80,6 +82,10 @@ export const playAudio = (
|
|||||||
item,
|
item,
|
||||||
playlistItemId,
|
playlistItemId,
|
||||||
startTimeTicks,
|
startTimeTicks,
|
||||||
|
player: {
|
||||||
|
...useAudioPlayback.getState().player,
|
||||||
|
playing: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -143,6 +149,10 @@ export const setProgress = (ticks: number) => {
|
|||||||
updatePlayer({ currentTick: ticks });
|
updatePlayer({ currentTick: ticks });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setAudioPlaying = (playing: boolean) => {
|
||||||
|
updatePlayer({ playing });
|
||||||
|
};
|
||||||
|
|
||||||
export const setVolume = (volume: number) => {
|
export const setVolume = (volume: number) => {
|
||||||
updatePlayer({ volume });
|
updatePlayer({ volume });
|
||||||
setPlayerVolume("audio", 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 { secToTicks, ticksToSec } from "../date/time";
|
||||||
import getSubtitle from "../methods/getSubtitles";
|
import getSubtitle from "../methods/getSubtitles";
|
||||||
import { addSegmentsFromChapters } from "../methods/mediaSegments";
|
import { addSegmentsFromChapters } from "../methods/mediaSegments";
|
||||||
|
import { markLocalMediaSwitch } from "../methods/mediaSwitch";
|
||||||
import playbackProfile from "../playback-profiles";
|
import playbackProfile from "../playback-profiles";
|
||||||
import {
|
import {
|
||||||
getPlayerMuted,
|
getPlayerMuted,
|
||||||
@@ -29,7 +30,11 @@ import {
|
|||||||
} from "../storage/player";
|
} from "../storage/player";
|
||||||
import type audioPlaybackInfo from "../types/audioPlaybackInfo";
|
import type audioPlaybackInfo from "../types/audioPlaybackInfo";
|
||||||
import type subtitlePlaybackInfo from "../types/subtitlePlaybackInfo";
|
import type subtitlePlaybackInfo from "../types/subtitlePlaybackInfo";
|
||||||
import { generateAudioStreamUrl, playAudio, stopPlayback } from "./audioPlayback";
|
import {
|
||||||
|
generateAudioStreamUrl,
|
||||||
|
playAudio,
|
||||||
|
stopPlayback,
|
||||||
|
} from "./audioPlayback";
|
||||||
import useQueue, { setQueue } from "./queue";
|
import useQueue, { setQueue } from "./queue";
|
||||||
|
|
||||||
type PlaybackStoreState = {
|
type PlaybackStoreState = {
|
||||||
@@ -732,6 +737,7 @@ export const initializePlayback = async (args: {
|
|||||||
} = args;
|
} = args;
|
||||||
|
|
||||||
// Only one medium at a time: starting a video stops music playback.
|
// Only one medium at a time: starting a video stops music playback.
|
||||||
|
markLocalMediaSwitch();
|
||||||
stopPlayback();
|
stopPlayback();
|
||||||
|
|
||||||
if (!mediaSource.MediaSources?.[0]?.Id) {
|
if (!mediaSource.MediaSources?.[0]?.Id) {
|
||||||
|
|||||||
@@ -9,8 +9,14 @@ type SyncPlayState = {
|
|||||||
group: GroupInfoDto | null;
|
group: GroupInfoDto | null;
|
||||||
groups: GroupInfoDto[];
|
groups: GroupInfoDto[];
|
||||||
queue: PlayQueueUpdate | null;
|
queue: PlayQueueUpdate | null;
|
||||||
|
/** Local receipt time of the last group queue update. */
|
||||||
|
queueReceivedAt: number | null;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
error: string | null;
|
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. */
|
/** Navigation requested by a remote group start. */
|
||||||
pendingNavigation: "video" | "audio" | null;
|
pendingNavigation: "video" | "audio" | null;
|
||||||
setOpen: (open: boolean) => void;
|
setOpen: (open: boolean) => void;
|
||||||
@@ -19,17 +25,33 @@ type SyncPlayState = {
|
|||||||
setQueue: (queue: PlayQueueUpdate | null) => void;
|
setQueue: (queue: PlayQueueUpdate | null) => void;
|
||||||
setLoading: (loading: boolean) => void;
|
setLoading: (loading: boolean) => void;
|
||||||
setError: (error: string | null) => void;
|
setError: (error: string | null) => void;
|
||||||
|
setAutoJoin: (autoJoin: boolean) => void;
|
||||||
|
setPingMs: (pingMs: number | null) => void;
|
||||||
setPendingNavigation: (kind: "video" | "audio" | null) => void;
|
setPendingNavigation: (kind: "video" | "audio" | null) => void;
|
||||||
reset: () => 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 = {
|
const initialState = {
|
||||||
open: false,
|
open: false,
|
||||||
group: null as GroupInfoDto | null,
|
group: null as GroupInfoDto | null,
|
||||||
groups: [] as GroupInfoDto[],
|
groups: [] as GroupInfoDto[],
|
||||||
queue: null as PlayQueueUpdate | null,
|
queue: null as PlayQueueUpdate | null,
|
||||||
|
queueReceivedAt: null as number | null,
|
||||||
loading: false,
|
loading: false,
|
||||||
error: null as string | null,
|
error: null as string | null,
|
||||||
|
autoJoin: readAutoJoin(),
|
||||||
|
pingMs: null as number | null,
|
||||||
pendingNavigation: null as "video" | "audio" | null,
|
pendingNavigation: null as "video" | "audio" | null,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38,14 +60,28 @@ export const useSyncPlayStore = create<SyncPlayState>((set) => ({
|
|||||||
setOpen: (open) => set({ open }),
|
setOpen: (open) => set({ open }),
|
||||||
setGroup: (group) => set({ group }),
|
setGroup: (group) => set({ group }),
|
||||||
setGroups: (groups) => set({ groups }),
|
setGroups: (groups) => set({ groups }),
|
||||||
setQueue: (queue) => set({ queue }),
|
setQueue: (queue) =>
|
||||||
|
set({
|
||||||
|
queue,
|
||||||
|
queueReceivedAt: queue ? Date.now() : null,
|
||||||
|
}),
|
||||||
setLoading: (loading) => set({ loading }),
|
setLoading: (loading) => set({ loading }),
|
||||||
setError: (error) => set({ error }),
|
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 }),
|
setPendingNavigation: (pendingNavigation) => set({ pendingNavigation }),
|
||||||
reset: () =>
|
reset: () =>
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
...initialState,
|
...initialState,
|
||||||
open: state.open,
|
open: state.open,
|
||||||
|
autoJoin: state.autoJoin,
|
||||||
})),
|
})),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user