feat(player): match the floating bar to the reference
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

- charcoal glass capsule with a circular sleeve and minimal transport
- one seek line with current and total time
- monochrome like, shuffle, repeat and mute actions on the right;
  removed the extra queue/device/expand controls
This commit is contained in:
1xDed committed 2026-12-01 18:20:34 +03:00
1 parent 94decd674c
commit 5c773841f7
3 files changed
+295 -781

No files matched your search

@@ -1,196 +1,83 @@
/* Floating glass media bar — 2026 "liquid glass" treatment:
translucent saturated blur, cover-tinted ambient light, a thin specular rim
and an almost invisible grain layer so the surface reads as material rather
than as a flat translucent box. */
/* The full audio player is a route; keep the floating bar in the DOM until
the view transition has captured the old frame, then hide it. */
html.player-full-open .audio-player {
display: none !important;
}
/* Floating media bar, matched to the reference:
a single wide charcoal glass capsule, circular sleeve, minimal transport,
one long seek line and four monochrome actions. */
.audio-player {
--player-accent: #{$clr-accent-default};
--player-base: #1b0f2e;
--player-deep: #09040f;
position: fixed;
left: 0;
right: 0;
bottom: 0.9rem;
bottom: 0.85rem;
margin: 0 auto;
width: min(1460px, calc(100% - 2rem));
height: 84px;
width: min(1700px, calc(100% - 3rem));
height: 82px;
box-sizing: border-box;
z-index: 100;
isolation: isolate;
overflow: hidden;
display: grid;
grid-template-columns:
minmax(0, 1fr)
minmax(320px, 560px)
minmax(0, 1fr);
display: flex;
align-items: center;
gap: 1.1rem;
padding: 0 0.75rem 0 0.85rem;
gap: 1.35rem;
padding: 0 1.1rem 0 0.6rem;
color: #fff;
border-radius: 24px;
border: 1px solid rgb(255 255 255 / 0.14);
background-color: rgb(14 11 24 / 0.55);
background-image:
radial-gradient(
100% 190% at 0% 50%,
rgb(255 255 255 / 0.08),
transparent 62%
),
linear-gradient(
120deg,
rgb(255 255 255 / 0.11),
rgb(255 255 255 / 0.025) 38%,
rgb(7 5 14 / 0.38) 100%
);
background-image:
radial-gradient(
100% 190% at 0% 50%,
color-mix(in srgb, var(--player-accent) 20%, transparent),
transparent 62%
),
radial-gradient(
90% 160% at 100% 30%,
color-mix(in srgb, var(--player-deep) 42%, transparent),
transparent 68%
),
linear-gradient(
120deg,
rgb(255 255 255 / 0.11),
rgb(255 255 255 / 0.025) 38%,
rgb(7 5 14 / 0.38) 100%
);
-webkit-backdrop-filter: blur(24px) saturate(170%) brightness(1.06);
backdrop-filter: blur(24px) saturate(170%) brightness(1.06);
border-radius: 30px;
border: 1px solid rgb(255 255 255 / 0.065);
background: linear-gradient(
180deg,
rgb(47 47 50 / 0.92),
rgb(37 37 40 / 0.94)
);
-webkit-backdrop-filter: blur(22px) saturate(125%);
backdrop-filter: blur(22px) saturate(125%);
box-shadow:
0 28px 70px rgb(0 0 0 / 0.55),
0 6px 18px rgb(0 0 0 / 0.35),
inset 0 1px 0 rgb(255 255 255 / 0.18),
inset 0 -1px 0 rgb(0 0 0 / 0.22);
box-shadow:
0 28px 70px rgb(0 0 0 / 0.55),
0 6px 18px rgb(0 0 0 / 0.35),
0 0 55px color-mix(in srgb, var(--player-accent) 13%, transparent),
inset 0 1px 0 rgb(255 255 255 / 0.18),
inset 0 -1px 0 rgb(0 0 0 / 0.22);
0 20px 46px rgb(0 0 0 / 0.5),
0 4px 14px rgb(0 0 0 / 0.3),
inset 0 1px 0 rgb(255 255 255 / 0.07);
will-change: transform, opacity;
transform-origin: 50% 100%;
/* Grain, kept below the content. */
&::before {
content: "";
position: absolute;
inset: 0;
z-index: 0;
border-radius: inherit;
pointer-events: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
background-size: 140px 140px;
opacity: 0.035;
mix-blend-mode: soft-light;
}
/* Specular gradient rim. */
&::after {
content: "";
position: absolute;
inset: 0;
z-index: 1;
border-radius: inherit;
padding: 1px;
pointer-events: none;
background: linear-gradient(
135deg,
rgb(255 255 255 / 0.45),
rgb(255 255 255 / 0.06) 30%,
rgb(255 255 255 / 0.02) 62%,
rgb(255 255 255 / 0.25)
);
-webkit-mask:
linear-gradient(#000 0 0) content-box,
linear-gradient(#000 0 0);
-webkit-mask-composite: xor;
mask:
linear-gradient(#000 0 0) content-box,
linear-gradient(#000 0 0);
mask-composite: exclude;
opacity: 0.9;
}
> * {
position: relative;
z-index: 2;
}
}
.media-bar {
&-left {
display: flex;
align-items: center;
gap: 0.8rem;
width: 100%;
flex: 0 0 285px;
width: 285px;
gap: 0.9rem;
min-width: 0;
max-width: 380px;
}
&-cover {
position: relative;
width: 58px;
height: 58px;
flex: 0 0 58px;
width: 64px;
height: 64px;
flex: 0 0 64px;
padding: 0;
border: 1px solid rgb(255 255 255 / 0.16);
border-radius: 16px;
border: 2px solid #d9d9d9;
border-radius: 50%;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
background: rgb(255 255 255 / 0.08);
background: #111;
color: rgb(255 255 255 / 0.55);
cursor: pointer;
box-shadow:
0 8px 22px rgb(0 0 0 / 0.45),
inset 0 0 0 1px rgb(255 255 255 / 0.06);
box-shadow:
0 8px 22px rgb(0 0 0 / 0.45),
0 0 22px color-mix(in srgb, var(--player-accent) 22%, transparent),
inset 0 0 0 1px rgb(255 255 255 / 0.06);
0 0 0 3px rgb(0 0 0 / 0.28),
0 6px 16px rgb(0 0 0 / 0.4);
img {
width: 100%;
height: 100%;
display: block;
object-fit: cover;
transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
&::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;
background: linear-gradient(
180deg,
rgb(255 255 255 / 0.2),
transparent 34%,
rgb(0 0 0 / 0.2)
);
opacity: 0.55;
}
&:hover img,
&:focus-visible img {
transform: scale(1.06);
transform: scale(1.04);
}
img {
transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.material-symbols-rounded {
@@ -207,71 +94,38 @@ html.player-full-open .audio-player {
}
&-title {
font-size: 0.92rem !important;
font-weight: 650 !important;
font-size: 1.18rem !important;
font-weight: 600 !important;
line-height: 1.2 !important;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
text-shadow: 0 1px 10px rgb(0 0 0 / 0.25);
&:hover,
&:focus-visible {
text-decoration: underline;
text-decoration-color: rgb(255 255 255 / 0.35);
text-underline-offset: 3px;
}
}
&-subtitle {
font-size: 0.72rem !important;
font-size: 0.9rem !important;
line-height: 1.3 !important;
opacity: 0.55;
letter-spacing: 0.01em;
color: rgb(255 255 255 / 0.5) !important;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
&-more {
flex-shrink: 0;
color: rgb(255 255 255 / 0.55) !important;
transition:
color 0.15s ease,
background-color 0.15s ease;
&:hover {
color: #fff !important;
background: rgb(255 255 255 / 0.08) !important;
}
}
&-center {
display: flex;
flex: 1;
min-width: 0;
flex-direction: column;
align-items: stretch;
gap: 1px;
}
&-controls {
&-transport {
display: flex;
align-items: center;
align-self: center;
gap: 0.05rem;
padding: 3px;
border-radius: 999px;
background: rgb(255 255 255 / 0.045);
border: 1px solid rgb(255 255 255 / 0.07);
box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08);
flex: 0 0 auto;
gap: 0.7rem;
.MuiIconButton-root {
width: 34px;
height: 34px;
border-radius: 50%;
color: rgb(255 255 255 / 0.68);
color: rgb(255 255 255 / 0.92);
transition:
color 0.15s ease,
background-color 0.15s ease,
@@ -279,188 +133,134 @@ html.player-full-open .audio-player {
&:hover {
color: #fff;
background: rgb(255 255 255 / 0.09);
transform: translateY(-1px);
background: rgb(255 255 255 / 0.06);
}
&.active {
color: var(--player-accent);
background: color-mix(
in srgb,
var(--player-accent) 13%,
transparent
);
}
.material-symbols-rounded {
font-size: 1.2rem;
}
}
}
&-play {
width: 44px !important;
height: 44px !important;
margin: 0 0.3rem;
background: #fff !important;
color: #100a1b !important;
box-shadow:
0 8px 24px rgb(0 0 0 / 0.45),
0 0 0 1px rgb(255 255 255 / 0.25);
box-shadow:
0 8px 24px rgb(0 0 0 / 0.45),
0 0 0 1px rgb(255 255 255 / 0.25),
0 0 26px color-mix(in srgb, var(--player-accent) 24%, transparent);
transition:
transform 0.16s ease,
box-shadow 0.2s ease;
&:hover {
background: #fff !important;
transform: scale(1.06);
box-shadow:
0 10px 28px rgb(0 0 0 / 0.5),
0 0 0 1px rgb(255 255 255 / 0.35),
0 0 34px color-mix(
in srgb,
var(--player-accent) 34%,
transparent
);
}
.material-symbols-rounded {
font-size: 1.55rem !important;
font-size: 1.45rem;
font-variation-settings: "FILL" 1;
}
}
&-step {
width: 40px !important;
height: 40px !important;
}
&-play {
width: 48px !important;
height: 48px !important;
margin: 0 0.1rem;
background: #fff !important;
color: #161616 !important;
box-shadow: 0 4px 12px rgb(0 0 0 / 0.25);
&:hover {
background: #fff !important;
transform: scale(1.04);
}
.material-symbols-rounded {
font-size: 1.6rem !important;
font-variation-settings: "FILL" 1;
}
}
&-progress {
display: flex;
align-items: center;
flex: 1;
min-width: 140px;
min-width: 120px;
gap: 1rem;
padding-right: 0.2rem;
.MuiSlider-root {
padding: 7px 0;
color: var(--player-accent);
flex: 1;
padding: 8px 0;
color: #fff;
}
.MuiSlider-rail {
height: 4px;
height: 3px;
border-radius: 999px;
background: rgb(255 255 255 / 0.13);
background: rgb(255 255 255 / 0.28);
opacity: 1;
}
.MuiSlider-track {
height: 4px;
height: 3px;
border: 0;
border-radius: 999px;
background: linear-gradient(
90deg,
rgb(255 255 255 / 0.95),
var(--player-accent)
);
box-shadow: 0 0 12px
color-mix(in srgb, var(--player-accent) 45%, transparent);
background: #fff;
}
.MuiSlider-thumb {
width: 12px;
height: 12px;
width: 13px;
height: 13px;
background: #fff;
box-shadow:
0 0 0 4px color-mix(
in srgb,
var(--player-accent) 16%,
transparent
),
0 2px 8px rgb(0 0 0 / 0.5);
box-shadow: 0 0 0 3px rgb(255 255 255 / 0.12);
transition:
transform 0.15s ease,
box-shadow 0.2s ease;
box-shadow 0.15s ease;
&:hover,
&.Mui-focusVisible {
transform: scale(1.15);
box-shadow:
0 0 0 6px color-mix(
in srgb,
var(--player-accent) 20%,
transparent
),
0 2px 10px rgb(0 0 0 / 0.55);
transform: scale(1.12);
box-shadow: 0 0 0 5px rgb(255 255 255 / 0.14);
}
}
}
.MuiTypography-root {
min-width: 2.6em !important;
font-family: var(--font-mono);
font-size: 0.66rem;
opacity: 0.5 !important;
font-variant-numeric: tabular-nums;
}
&-time {
flex: 0 0 auto;
font-size: 0.8rem;
font-weight: 400;
color: rgb(255 255 255 / 0.48);
font-variant-numeric: tabular-nums;
letter-spacing: 0.01em;
white-space: nowrap;
}
&-right {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 0.05rem;
flex-shrink: 0;
padding: 3px 4px;
border-radius: 999px;
background: rgb(255 255 255 / 0.035);
border: 1px solid rgb(255 255 255 / 0.055);
box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
flex: 0 0 auto;
gap: 0.35rem;
.MuiIconButton-root {
width: 34px;
height: 34px;
width: 40px;
height: 40px;
border-radius: 50%;
color: rgb(255 255 255 / 0.62);
color: rgb(255 255 255 / 0.68);
transition:
color 0.15s ease,
background-color 0.15s ease;
&:hover {
color: #fff;
background: rgb(255 255 255 / 0.08);
background: rgb(255 255 255 / 0.06);
}
&.active {
color: #fff;
}
.material-symbols-rounded {
font-size: 1.2rem;
font-size: 1.3rem;
}
}
}
&-volume {
width: 92px !important;
margin: 0 0.25rem 0 0 !important;
color: var(--player-accent) !important;
&-like {
display: flex;
filter: grayscale(1);
.MuiSlider-rail {
height: 3px;
border-radius: 999px;
background: rgb(255 255 255 / 0.14);
opacity: 1;
}
.MuiSlider-track {
height: 3px;
border: 0;
border-radius: 999px;
background: linear-gradient(
90deg,
rgb(255 255 255 / 0.9),
var(--player-accent)
);
}
.MuiSlider-thumb {
width: 10px;
height: 10px;
background: #fff;
box-shadow: 0 0 0 3px
color-mix(in srgb, var(--player-accent) 16%, transparent);
.MuiIconButton-root {
width: 40px;
height: 40px;
border-radius: 50%;
color: rgb(255 255 255 / 0.68);
}
}
}
@@ -469,121 +269,123 @@ html.player-full-open .audio-player {
(backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))
) {
.audio-player {
background: rgb(14 11 24 / 0.96);
}
.audio-player::before {
display: none;
background: rgb(38 38 41 / 0.97);
}
}
@media (prefers-reduced-transparency: reduce) {
.audio-player {
background: rgb(14 11 24 / 0.96);
background: rgb(38 38 41 / 0.97);
-webkit-backdrop-filter: none;
backdrop-filter: none;
}
.audio-player::before {
display: none;
}
}
@media (max-width: 1100px) {
@media (max-width: 1200px) {
.audio-player {
gap: 0.8rem;
gap: 1rem;
}
.media-bar-left {
max-width: 320px;
flex: 0 0 240px;
width: 240px;
}
.media-bar-volume {
width: 72px !important;
.media-bar-title {
font-size: 1.06rem !important;
}
.media-bar-subtitle {
font-size: 0.82rem !important;
}
.media-bar-right {
gap: 0.1rem;
.MuiIconButton-root,
.media-bar-like .MuiIconButton-root {
width: 36px;
height: 36px;
}
}
}
@media (max-width: 900px) {
.audio-player {
width: calc(100% - 1.5rem);
gap: 0.7rem;
}
.media-bar-left {
min-width: 180px;
max-width: none;
flex: 0 0 210px;
width: 210px;
}
.media-bar-volume,
.media-bar-right .MuiSlider-root {
display: none;
.media-bar-cover {
width: 54px;
height: 54px;
flex: 0 0 54px;
}
.media-bar-time {
font-size: 0.72rem;
}
.media-bar-right .MuiIconButton-root,
.media-bar-like .MuiIconButton-root {
width: 34px;
height: 34px;
}
}
@media (max-width: 700px) {
.audio-player {
display: flex;
width: calc(100% - 1rem);
height: 68px;
bottom: 0.55rem;
height: 64px;
bottom: 0.5rem;
padding: 0 0.55rem;
gap: 0.45rem;
border-radius: 20px;
gap: 0.5rem;
border-radius: 22px;
}
.media-bar-left {
width: auto;
min-width: 0;
max-width: none;
flex: 1 1 auto;
width: auto;
gap: 0.55rem;
}
.media-bar-cover {
width: 46px;
height: 46px;
flex: 0 0 46px;
border-radius: 13px;
width: 44px;
height: 44px;
flex: 0 0 44px;
border-width: 1.5px;
}
.media-bar-more {
display: none;
.media-bar-title {
font-size: 0.92rem !important;
}
.media-bar-center {
.media-bar-subtitle {
font-size: 0.72rem !important;
}
.media-bar-transport {
flex: 0 0 auto;
gap: 0;
}
.media-bar-controls {
padding: 2px;
> :first-child,
> :last-child {
.media-bar-step {
display: none;
}
.MuiIconButton-root {
width: 32px;
height: 32px;
.media-bar-play {
width: 40px !important;
height: 40px !important;
margin: 0;
}
}
.media-bar-play {
width: 40px !important;
height: 40px !important;
margin: 0 0.15rem;
}
.media-bar-progress,
.media-bar-right {
display: none !important;
}
.media-bar-title {
font-size: 0.86rem !important;
}
.media-bar-subtitle {
font-size: 0.67rem !important;
}
}
+118 -398
View File
@@ -7,13 +7,7 @@ import {
PlaystateCommand,
} from "@jellyfin/sdk/lib/generated-client";
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
import Divider from "@mui/material/Divider";
import IconButton from "@mui/material/IconButton";
import ListItemIcon from "@mui/material/ListItemIcon";
import ListItemText from "@mui/material/ListItemText";
import Menu from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem";
import Slider from "@mui/material/Slider";
import Tooltip from "@mui/material/Tooltip";
import Typography from "@mui/material/Typography";
import { useQuery } from "@tanstack/react-query";
@@ -23,29 +17,19 @@ import { useSnackbar } from "notistack";
import React, {
type SyntheticEvent,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import QueueButton from "@/components/buttons/queueButton";
import LikeButton from "@/components/buttons/likeButton";
import { secToTicks, ticksToSec } from "@/utils/date/time";
import { getCoverPalette } from "@/utils/methods/coverColor";
import getImageUrlsApi, {
getPlayerCoverUrl,
} from "@/utils/methods/getImageUrlsApi";
import { startInstantMix } from "@/utils/methods/instantMix";
import { rememberAudioPlayerReturn } from "@/utils/methods/audioPlayerReturn";
import {
playOnSession,
queueStartingWith,
transferSessionToLocal,
} from "@/utils/methods/transferPlayback";
import { useApiInContext } from "@/utils/store/api";
import {
setAudioRef,
setIsMuted,
setVolume,
stopPlayback,
useAudioPlayback,
} from "@/utils/store/audioPlayback";
import { useCentralStore } from "@/utils/store/central";
@@ -56,12 +40,21 @@ import useQueue, {
shuffleUpcoming,
} from "@/utils/store/queue";
import useRemoteControlStore from "@/utils/store/remoteControl";
import useSyncPlayback from "@/utils/store/syncPlayback";
import DeviceMenu from "./components/DeviceMenu";
import PlayerProgress from "./components/PlayerProgress";
import "./audioPlayer.scss";
const formatPlayerTime = (ticks: number) => {
const total = Math.max(0, Math.round(ticks / 10_000_000));
const hours = Math.floor(total / 3600);
const minutes = Math.floor((total % 3600) / 60);
const seconds = total % 60;
const two = (value: number) => String(value).padStart(2, "0");
return hours > 0
? `${hours}:${two(minutes)}:${two(seconds)}`
: `${two(minutes)}:${two(seconds)}`;
};
const AudioPlayer = () => {
const api = useApiInContext((s) => s.api);
const user = useCentralStore((s) => s.currentUser);
@@ -95,16 +88,7 @@ const AudioPlayer = () => {
const [playing, setPlaying] = useState(false);
const [progress, setProgress] = useState(0);
const [selectedRemoteId, setSelectedRemoteId] = useState<string | null>(null);
const remoteActiveRef = useRef(false);
const [moreAnchor, setMoreAnchor] = useState<HTMLElement | null>(null);
const [remoteVolumeDraft, setRemoteVolumeDraft] = useState<number | null>(
null,
);
const remoteVolumeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(
null,
);
useEffect(() => setRemoteVolumeDraft(null), [selectedRemoteId]);
const sessions = useQuery({
queryKey: ["remoteSessions"],
@@ -134,33 +118,11 @@ const AudioPlayer = () => {
const playingRemote = remoteSessions.find(
(session: SessionInfoDto) => session.NowPlayingItem,
);
const selectedRemote = selectedRemoteId
? remoteSessions.find(
(session: SessionInfoDto) => session.Id === selectedRemoteId,
)
: undefined;
// Local playback takes precedence unless a remote device was selected.
const remote = selectedRemote?.NowPlayingItem
? selectedRemote
: !display
? playingRemote
: undefined;
// Local playback takes precedence; otherwise follow the active remote
// session (the bar is a compact remote as well).
const remote = !display ? playingRemote : undefined;
remoteActiveRef.current = Boolean(remote);
// Keep the picked remote volume until the target reports it back (progress
// updates can lag by seconds), then drop the optimistic value.
useEffect(() => {
if (remoteVolumeDraft == null) return;
const server = remote?.PlayState?.VolumeLevel;
if (server != null && Math.abs(server / 100 - remoteVolumeDraft) <= 0.02) {
setRemoteVolumeDraft(null);
if (remoteVolumeTimerRef.current) {
clearTimeout(remoteVolumeTimerRef.current);
remoteVolumeTimerRef.current = null;
}
}
}, [remote?.PlayState?.VolumeLevel, remoteVolumeDraft]);
const activeItem: BaseItemDto | undefined | null =
remote?.NowPlayingItem ?? item;
const artists = activeItem?.ArtistItems?.length
@@ -177,7 +139,6 @@ const AudioPlayer = () => {
: artistNames.join(", ") || activeItem?.Album || "";
const coverUrl = getPlayerCoverUrl(api, activeItem, 600);
const fullCoverUrl = getPlayerCoverUrl(api, item, 600);
const palette = useMemo(() => getCoverPalette(activeItem), [activeItem]);
useEffect(() => {
if (!fullCoverUrl) return;
const image = new Image();
@@ -190,10 +151,9 @@ const AudioPlayer = () => {
const remoteRepeat = remote?.PlayState?.RepeatMode ?? "RepeatNone";
const remoteShuffled = remote?.PlayState?.PlaybackOrder === "Shuffle";
const remoteVolume =
remoteVolumeDraft ??
(remote?.PlayState?.VolumeLevel != null
remote?.PlayState?.VolumeLevel != null
? remote.PlayState.VolumeLevel / 100
: 1);
: 1;
const remoteMuted = remote?.PlayState?.IsMuted ?? false;
const displayProgress = remote
? (remote.PlayState?.PositionTicks ?? 0)
@@ -201,29 +161,6 @@ const AudioPlayer = () => {
const displayDuration = activeItem?.RunTimeTicks ?? 1;
const barVisible = (display && item) || Boolean(remote);
const syncEnabled = useSyncPlayback((state) => state.enabled);
const syncMaster = useSyncPlayback((state) => state.master);
const startSync = useSyncPlayback((state) => state.start);
const stopSync = useSyncPlayback((state) => state.stop);
const canSync = Boolean(activeItem?.Id) && (display || Boolean(remote));
const syncForThisSession =
syncEnabled &&
(remote?.Id
? syncMaster?.sessionId === remote.Id
: display && syncMaster?.sessionId === null);
const toggleSync = () => {
if (syncForThisSession) {
stopSync();
return;
}
if (!activeItem?.Id) return;
startSync({ itemId: activeItem.Id, sessionId: remote?.Id ?? null });
};
useEffect(() => {
if (display) setSelectedRemoteId(null);
}, [display, item?.Id]);
// Layout hooks (home hero rail) reserve space for the bar. Use explicit
// visibility rather than the DOM: during the exit animation the element is
// still mounted but already off-screen.
@@ -367,18 +304,10 @@ const AudioPlayer = () => {
}
};
const handleVolumeChange = (newVolume: number) => {
setVolume(newVolume);
};
const handleMuteToggle = () => {
setIsMuted(!isMuted);
};
const handleClose = () => {
useAudioPlayback.setState(useAudioPlayback.getInitialState());
};
const handleNavigate = () => {
if (remote) {
openRemoteDialog(remote.NowPlayingItem);
@@ -422,70 +351,6 @@ const AudioPlayer = () => {
}
};
const transferToLocal = async () => {
if (!api || !user?.Id || !remote) {
setSelectedRemoteId(null);
return;
}
try {
const kind = await transferSessionToLocal(api, user.Id, remote);
setSelectedRemoteId(null);
await sessions.refetch();
if (kind === "video") navigate({ to: "/player" });
} catch (error) {
console.error("Transfer failed", error);
enqueueSnackbar("Не удалось перенести воспроизведение", { variant: "error" });
}
};
const selectRemote = async (session: SessionInfoDto) => {
if (!session.Id) return;
try {
// Moving local playback: send the queue/position to the target first.
if (display && item?.Id && api && user?.Id) {
const queue = useQueue.getState();
const ids = queueStartingWith(queue.tracks ?? [], item.Id);
await playOnSession(api, user.Id, session.Id, {
itemIds: ids.length > 0 ? ids : [item.Id],
startIndex: 0,
startPositionTicks: progress,
mediaSourceId: item.MediaSources?.[0]?.Id ?? undefined,
});
stopPlayback();
} else if (
remote?.Id &&
remote.Id !== session.Id &&
remote.NowPlayingItem?.Id &&
api &&
user?.Id
) {
// Moving playback from one remote device to another: hand over the
// queue and current position, then stop the old device.
const remoteItem = remote.NowPlayingItem;
const queueIds = queueStartingWith(
remote.NowPlayingQueue ?? [],
remoteItem.Id ?? undefined,
);
await playOnSession(api, user.Id, session.Id, {
itemIds: queueIds.length > 0 ? queueIds : [remoteItem.Id as string],
startIndex: 0,
startPositionTicks: remote.PlayState?.PositionTicks ?? 0,
mediaSourceId: remoteItem.MediaSources?.[0]?.Id ?? undefined,
});
await getSessionApi(api).sendPlaystateCommand({
sessionId: remote.Id,
command: "Stop",
controllingUserId: user.Id,
});
}
setSelectedRemoteId(session.Id);
await sessions.refetch();
} catch (error) {
console.error("Не удалось переключить устройство", error);
enqueueSnackbar("Не удалось переключить устройство", { variant: "error" });
}
};
const handleNext = () => {
if (remote) remoteCommand(PlaystateCommand.NextTrack);
else if (api && user?.Id) playItemFromQueue("next", user.Id, api);
@@ -552,37 +417,6 @@ const AudioPlayer = () => {
remoteCommand(PlaystateCommand.Seek, Math.round(ticks));
};
const handleMoreOpen = (event: React.MouseEvent<HTMLElement>) =>
setMoreAnchor(event.currentTarget);
const instantMix = async () => {
setMoreAnchor(null);
if (!api || !user?.Id || !activeItem) return;
try {
const { count } = await startInstantMix(api, user.Id, activeItem);
if (count === 0) {
enqueueSnackbar("Нет треков для микса", {
variant: "warning",
});
}
} catch (error) {
console.error(error);
enqueueSnackbar("Не удалось запустить микс", { variant: "error" });
}
};
const openCastForLocal = () => {
setMoreAnchor(null);
if (!item) return;
openRemoteDialog({
item,
kind: "audio",
positionTicks: progress,
queue: tracks ?? [],
startIndex: currentTrack,
});
};
const audioElement = display ? (
<audio
autoPlay
@@ -630,13 +464,6 @@ const AudioPlayer = () => {
? { duration: 0 }
: { type: "spring", stiffness: 420, damping: 38, mass: 0.9 }
}
style={
{
"--player-accent": palette.accent,
"--player-base": palette.base,
"--player-deep": palette.deep,
} as React.CSSProperties
}
className="audio-player"
>
<div className="media-bar-left">
@@ -665,115 +492,120 @@ const AudioPlayer = () => {
{subtitle || "Blink"}
</Typography>
</div>
<IconButton
size="small"
aria-label="Ещё"
className="media-bar-more"
onClick={handleMoreOpen}
>
<span className="material-symbols-rounded">more_horiz</span>
</IconButton>
</div>
<div className="media-bar-center">
<div className="media-bar-controls">
<Tooltip title="Перемешать">
<IconButton
size="small"
onClick={handleShuffle}
className={(remote ? remoteShuffled : false) ? "active" : ""}
>
<span className="material-symbols-rounded">shuffle</span>
</IconButton>
</Tooltip>
<Tooltip title="Предыдущий">
<IconButton
size="small"
onClick={handlePrevious}
aria-label="Предыдущий"
>
<span className="material-symbols-rounded">
skip_previous
</span>
</IconButton>
</Tooltip>
<Tooltip title={isPlaying ? "Пауза" : "Слушать"}>
<IconButton
className="media-bar-play"
aria-label={isPlaying ? "Пауза" : "Слушать"}
onClick={() =>
remote
? remoteCommand(PlaystateCommand.PlayPause)
: handlePlayPause()
}
>
<span className="material-symbols-rounded">
{isPlaying ? "pause" : "play_arrow"}
</span>
</IconButton>
</Tooltip>
<Tooltip title="Следующий">
<IconButton size="small" onClick={handleNext} aria-label="Следующий">
<span className="material-symbols-rounded">skip_next</span>
</IconButton>
</Tooltip>
<Tooltip
title={
<div className="media-bar-transport">
<Tooltip title="Предыдущий">
<IconButton
onClick={handlePrevious}
aria-label="Предыдущий"
className="media-bar-step"
>
<span className="material-symbols-rounded">skip_previous</span>
</IconButton>
</Tooltip>
<Tooltip title={isPlaying ? "Пауза" : "Слушать"}>
<IconButton
className="media-bar-play"
aria-label={isPlaying ? "Пауза" : "Слушать"}
onClick={() =>
remote
? remoteRepeat === "RepeatNone"
? "Повтор выкл."
: remoteRepeat === "RepeatAll"
? "Повтор всех"
: "Повтор одного"
: repeatMode === "off"
? "Повтор выкл."
: repeatMode === "all"
? "Повтор всех"
: "Повтор одного"
? remoteCommand(PlaystateCommand.PlayPause)
: handlePlayPause()
}
>
<IconButton
size="small"
onClick={handleRepeat}
className={
(remote ? remoteRepeat !== "RepeatNone" : repeatMode !== "off")
? "active"
: ""
}
>
<span className="material-symbols-rounded">
{(remote ? remoteRepeat === "RepeatOne" : repeatMode === "one")
? "repeat_one"
: "repeat"}
</span>
</IconButton>
</Tooltip>
</div>
<span className="material-symbols-rounded">
{isPlaying ? "pause" : "play_arrow"}
</span>
</IconButton>
</Tooltip>
<Tooltip title="Следующий">
<IconButton
onClick={handleNext}
aria-label="Следующий"
className="media-bar-step"
>
<span className="material-symbols-rounded">skip_next</span>
</IconButton>
</Tooltip>
</div>
<div className="media-bar-progress">
<PlayerProgress
className="media-bar-progress"
layout="bare"
className="media-bar-slider"
progress={displayProgress}
duration={displayDuration}
onSeekCommit={remote ? handleRemoteSeek : handleSeekCommit}
/>
<span className="media-bar-time">
{formatPlayerTime(displayProgress)} /{" "}
{formatPlayerTime(displayDuration)}
</span>
</div>
<div className="media-bar-right">
{remote && (
<Tooltip title="Перенести на это устройство">
<IconButton
size="small"
aria-label="Перенести на это устройство"
onClick={transferToLocal}
>
<span className="material-symbols-rounded">
system_update_alt
</span>
</IconButton>
</Tooltip>
)}
{!remote && <QueueButton />}
<Tooltip title={remote ? (remoteMuted ? "Включить звук" : "Выключить звук") : (isMuted ? "Включить звук" : "Выключить звук")}>
<IconButton size="small" onClick={handleMute}>
<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>
<Tooltip title="Перемешать">
<IconButton
onClick={handleShuffle}
aria-label="Перемешать"
className={(remote ? remoteShuffled : false) ? "active" : ""}
>
<span className="material-symbols-rounded">shuffle</span>
</IconButton>
</Tooltip>
<Tooltip
title={
remote
? remoteRepeat === "RepeatNone"
? "Повтор выкл."
: remoteRepeat === "RepeatAll"
? "Повтор всех"
: "Повтор одного"
: repeatMode === "off"
? "Повтор выкл."
: repeatMode === "all"
? "Повтор всех"
: "Повтор одного"
}
>
<IconButton
onClick={handleRepeat}
aria-label="Повтор"
className={
(remote ? remoteRepeat !== "RepeatNone" : repeatMode !== "off")
? "active"
: ""
}
>
<span className="material-symbols-rounded">
{(remote ? remoteRepeat === "RepeatOne" : repeatMode === "one")
? "repeat_one"
: "repeat"}
</span>
</IconButton>
</Tooltip>
<Tooltip
title={
remote
? remoteMuted
? "Включить звук"
: "Выключить звук"
: isMuted
? "Включить звук"
: "Выключить звук"
}
>
<IconButton onClick={handleMute} aria-label="Звук">
<span className="material-symbols-rounded">
{remote
? remoteMuted || remoteVolume === 0
@@ -785,120 +617,8 @@ const AudioPlayer = () => {
</span>
</IconButton>
</Tooltip>
<Slider
size="small"
className="media-bar-volume"
value={remote ? (remoteMuted ? 0 : remoteVolume) : isMuted ? 0 : volume}
min={0}
max={1}
step={0.01}
aria-label="Громкость"
onChange={(_, value) => {
const next = Array.isArray(value) ? value[0] : value;
if (remote) {
setRemoteVolumeDraft(next);
} else {
handleVolumeChange(next);
}
}}
onChangeCommitted={(_, value) => {
if (!remote) return;
const next = Array.isArray(value) ? value[0] : value;
setRemoteVolumeDraft(next);
if (remoteVolumeTimerRef.current) {
clearTimeout(remoteVolumeTimerRef.current);
}
remoteVolumeTimerRef.current = setTimeout(() => {
setRemoteVolumeDraft(null);
}, 12000);
sendGeneral(GeneralCommandType.SetVolume, {
Volume: String(Math.round(next * 100)),
});
}}
/>
<DeviceMenu
sessions={remoteSessions}
activeRemoteId={remote?.Id ?? null}
localActive={display && Boolean(item)}
localItem={item}
onSelectLocal={transferToLocal}
onSelectRemote={selectRemote}
onOpenRemoteControl={() => openRemoteDialog()}
syncEnabled={syncForThisSession}
canSync={canSync}
onToggleSync={toggleSync}
/>
<Tooltip title="Открыть плеер">
<IconButton size="small" onClick={handleNavigate}>
<span className="material-symbols-rounded">open_in_full</span>
</IconButton>
</Tooltip>
</div>
<Menu
anchorEl={moreAnchor}
open={Boolean(moreAnchor)}
onClose={() => setMoreAnchor(null)}
slotProps={{ paper: { className: "glass-menu-paper" } }}
>
<MenuItem onClick={instantMix} disabled={!activeItem}>
<ListItemIcon>
<span className="material-symbols-rounded">radio</span>
</ListItemIcon>
<ListItemText primary="Микс" />
</MenuItem>
{remote ? (
<MenuItem
onClick={() => {
setMoreAnchor(null);
transferToLocal();
}}
>
<ListItemIcon>
<span className="material-symbols-rounded">
system_update_alt
</span>
</ListItemIcon>
<ListItemText primary="Перенести на это устройство" />
</MenuItem>
) : (
<MenuItem onClick={openCastForLocal}>
<ListItemIcon>
<span className="material-symbols-rounded">cast</span>
</ListItemIcon>
<ListItemText primary="Воспроизвести на другом устройстве…" />
</MenuItem>
)}
<MenuItem
onClick={() => {
setMoreAnchor(null);
navigate({ to: "/remote" });
}}
>
<ListItemIcon>
<span className="material-symbols-rounded">settings_remote</span>
</ListItemIcon>
<ListItemText primary="Удалённый пульт" />
</MenuItem>
<Divider />
<MenuItem
onClick={() => {
setMoreAnchor(null);
if (remote) {
remoteCommand(PlaystateCommand.Stop);
setSelectedRemoteId(null);
} else {
handleClose();
}
}}
>
<ListItemIcon>
<span className="material-symbols-rounded">stop</span>
</ListItemIcon>
<ListItemText primary="Остановить" />
</MenuItem>
</Menu>
</motion.div>
);
-8
View File
@@ -6,14 +6,11 @@ type Palette = {
base: string;
/** Darker end of the vertical gradient. */
deep: string;
/** Saturated cover hue used for glass highlights and controls. */
accent: string;
};
const FALLBACK: Palette = {
base: "hsl(266 32% 22%)",
deep: "hsl(266 40% 9%)",
accent: "hsl(337 96% 64%)",
};
const clamp = (value: number, min: number, max: number) =>
@@ -83,11 +80,6 @@ export const getCoverPalette = (item?: BaseItemDto | null): Palette => {
return {
base: hsl(h, wallSaturation, wallLightness),
deep: hsl(h, wallSaturation, clamp(wallLightness * 0.45, 0.05, 0.12)),
accent: hsl(
h,
clamp(s + 0.4, 0.55, 0.9),
clamp(l + 0.28, 0.56, 0.7),
),
};
} catch {
return FALLBACK;