feat(player): restyle the floating media bar as liquid glass
Continuous Integration / build_web (push) Failing after 1s
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

- cover-tinted translucent surface with a specular rim, grain and glow
- centered transport dock and right-hand control capsule
- adaptive accent colour, glass cover treatment and shared artwork
  between the bar and the full player
This commit is contained in:
1xDed committed 2026-12-01 18:06:36 +03:00
1 parent 72909fd3b2
commit 94decd674c
7 files changed
+694 -450

No files matched your search

@@ -1,499 +1,589 @@
$art-size: 48px; /* 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;
}
.audio-player { .audio-player {
--player-accent: #{$clr-accent-default};
--player-base: #1b0f2e;
--player-deep: #09040f;
position: fixed; position: fixed;
bottom: 0.75rem; left: 0;
left: 50%; right: 0;
transform: translateX(-50%); bottom: 0.9rem;
width: min(1100px, calc(100% - 1.5rem)); margin: 0 auto;
height: 80px; width: min(1460px, calc(100% - 2rem));
height: 84px;
box-sizing: border-box; box-sizing: border-box;
z-index: 100; z-index: 100;
isolation: isolate;
overflow: hidden;
display: grid; display: grid;
// Equal side columns keep the transport truly centred grid-template-columns:
grid-template-columns: minmax(0, 1fr) minmax(0, 540px) minmax(0, 1fr); minmax(0, 1fr)
minmax(320px, 560px)
minmax(0, 1fr);
align-items: center; align-items: center;
gap: 1.5rem; gap: 1.1rem;
padding: 0 0.75rem 0 1rem; padding: 0 0.75rem 0 0.85rem;
color: #fff;
border-radius: 24px;
border: 1px solid rgb(255 255 255 / 0.14);
color: white; background-color: rgb(14 11 24 / 0.55);
// Opaque bar: backdrop-filter over the virtualized grid caused constant background-image:
// compositing/shifting on WebKit. radial-gradient(
background: rgb(18 18 24 / 0.98); 100% 190% at 0% 50%,
border: 1px solid rgb(255 255 255 / 0.08); rgb(255 255 255 / 0.08),
border-radius: 14px; transparent 62%
box-shadow: 0 12px 40px rgb(0 0 0 / 0.45); ),
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);
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);
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%;
min-width: 0;
max-width: 380px;
}
&-cover {
position: relative;
width: 58px;
height: 58px;
flex: 0 0 58px;
padding: 0;
border: 1px solid rgb(255 255 255 / 0.16);
border-radius: 16px;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
background: rgb(255 255 255 / 0.08);
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);
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);
}
.material-symbols-rounded {
font-size: 1.5rem;
}
}
&-info { &-info {
display: flex; display: flex;
align-items: center; flex-direction: column;
gap: 0.75rem;
min-width: 0; min-width: 0;
flex: 1;
gap: 3px;
}
> .MuiIconButton-root { &-title {
flex-shrink: 0; font-size: 0.92rem !important;
color: rgb(255 255 255 / 0.75); font-weight: 650 !important;
.material-symbols-rounded { line-height: 1.2 !important;
font-size: 1.25rem; white-space: nowrap;
} overflow: hidden;
} text-overflow: ellipsis;
cursor: pointer;
text-shadow: 0 1px 10px rgb(0 0 0 / 0.25);
&-text { &:hover,
display: flex; &:focus-visible {
flex-direction: column; text-decoration: underline;
min-width: 0; text-decoration-color: rgb(255 255 255 / 0.35);
} text-underline-offset: 3px;
&-title {
all: unset;
cursor: pointer;
font-weight: 600 !important;
line-height: 1.25 !important;
// Wrap long titles onto a second line before truncating
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
overflow-wrap: anywhere;
&:hover,
&:focus-visible {
text-decoration: underline;
}
}
&-artist {
opacity: 0.6;
a {
color: inherit;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
} }
} }
&-image { &-subtitle {
position: absolute; font-size: 0.72rem !important;
inset: 0; line-height: 1.3 !important;
width: 100%; opacity: 0.55;
height: 100%; letter-spacing: 0.01em;
object-fit: cover; white-space: nowrap;
z-index: 1; overflow: hidden;
text-overflow: ellipsis;
}
&-container { &-more {
all: unset; flex-shrink: 0;
position: relative; color: rgb(255 255 255 / 0.55) !important;
flex-shrink: 0; transition:
width: $art-size; color 0.15s ease,
height: $art-size; background-color 0.15s ease;
border-radius: 8px;
overflow: hidden;
cursor: pointer;
background: rgb(255 255 255 / 0.08);
&:hover .audio-player-image-expand, &:hover {
&:focus-visible .audio-player-image-expand { color: #fff !important;
opacity: 1; background: rgb(255 255 255 / 0.08) !important;
}
}
&-icon,
&-expand {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
&-icon {
font-size: 1.5rem !important;
opacity: 0.5;
}
// "Open player" affordance shown over the art on hover
&-expand {
z-index: 2;
inset: 0;
transform: none;
display: flex;
align-items: center;
justify-content: center;
background: rgb(0 0 0 / 0.5);
opacity: 0;
transition: opacity 0.15s ease;
} }
} }
// Transport on top, compact seek row underneath
&-center { &-center {
display: flex; display: flex;
flex-direction: column; flex: 1;
align-items: center;
gap: 2px;
min-width: 0; min-width: 0;
flex-direction: column;
align-items: stretch;
gap: 1px;
}
.player-controls { &-controls {
gap: 0.5rem !important; 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);
.MuiFab-root { .MuiIconButton-root {
width: 36px; width: 34px;
height: 36px; height: 34px;
min-height: 36px; border-radius: 50%;
box-shadow: none; color: rgb(255 255 255 / 0.68);
transition:
color 0.15s ease,
background-color 0.15s ease,
transform 0.15s ease;
.material-symbols-rounded { &:hover {
font-size: 1.6rem !important; color: #fff;
} background: rgb(255 255 255 / 0.09);
transform: translateY(-1px);
} }
&.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-variation-settings: "FILL" 1;
} }
} }
&-progress { &-progress {
gap: 0.6rem !important; flex: 1;
min-width: 140px;
.MuiTypography-root {
min-width: 2.75em !important;
font-size: 0.7rem;
opacity: 0.6 !important;
}
.MuiSlider-root { .MuiSlider-root {
padding: 8px 0; padding: 7px 0;
color: var(--player-accent);
} }
.MuiSlider-thumb {
width: 10px; .MuiSlider-rail {
height: 10px; height: 4px;
opacity: 0; border-radius: 999px;
transition: opacity 0.15s ease; background: rgb(255 255 255 / 0.13);
}
&:hover .MuiSlider-thumb,
.MuiSlider-root.Mui-active .MuiSlider-thumb {
opacity: 1; opacity: 1;
} }
.MuiSlider-track {
height: 4px;
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);
}
.MuiSlider-thumb {
width: 12px;
height: 12px;
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);
transition:
transform 0.15s ease,
box-shadow 0.2s 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);
}
}
.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;
}
} }
&-actions { &-right {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-end; justify-content: flex-end;
gap: 0.25rem; gap: 0.05rem;
min-width: 0; 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);
.MuiIconButton-root { .MuiIconButton-root {
color: rgb(255 255 255 / 0.75); width: 34px;
height: 34px;
border-radius: 50%;
color: rgb(255 255 255 / 0.62);
transition:
color 0.15s ease,
background-color 0.15s ease;
&:hover { &:hover {
color: white; color: #fff;
background: rgb(255 255 255 / 0.08);
}
.material-symbols-rounded {
font-size: 1.2rem;
} }
} }
} }
&-volume { &-volume {
display: flex; width: 92px !important;
align-items: center; margin: 0 0.25rem 0 0 !important;
min-width: 0; color: var(--player-accent) !important;
// Secondary control: neutral and compact .MuiSlider-rail {
.MuiSlider-root { height: 3px;
width: 5.5rem !important; border-radius: 999px;
color: rgb(255 255 255 / 0.85); background: rgb(255 255 255 / 0.14);
opacity: 1;
} }
}
@media (max-width: 900px) { .MuiSlider-track {
.audio-player-volume, height: 3px;
.audio-player-progress .MuiTypography-root { border: 0;
display: none; border-radius: 999px;
background: linear-gradient(
90deg,
rgb(255 255 255 / 0.9),
var(--player-accent)
);
} }
}
@media (max-width: 640px) { .MuiSlider-thumb {
grid-template-columns: minmax(0, 1fr) auto auto; width: 10px;
gap: 0.5rem; height: 10px;
bottom: 0.5rem; background: #fff;
width: calc(100% - 1rem); box-shadow: 0 0 0 3px
height: 64px; color-mix(in srgb, var(--player-accent) 16%, transparent);
.audio-player-center .player-controls > :not(:has(.MuiFab-root)),
.audio-player-progress {
display: none;
}
.audio-player-actions > :not(:last-child) {
display: none;
} }
} }
} }
/* Unified, minimal media bar (local playback + remote device control). */ @supports not (
.audio-player { (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))
display: flex; ) {
align-items: center; .audio-player {
width: min(1440px, calc(100% - 1.5rem)); background: rgb(14 11 24 / 0.96);
height: 82px; }
gap: 1.25rem;
padding: 0 0.9rem;
background: #0b0816;
border: 1px solid rgb(255 255 255 / 0.08);
border-radius: 18px;
.media-bar { .audio-player::before {
&-left { display: none;
display: flex; }
align-items: center; }
gap: 0.75rem;
width: 30%;
min-width: 220px;
max-width: 360px;
}
&-cover { @media (prefers-reduced-transparency: reduce) {
width: 52px; .audio-player {
height: 52px; background: rgb(14 11 24 / 0.96);
flex: 0 0 52px; -webkit-backdrop-filter: none;
padding: 0; backdrop-filter: none;
border: 0; }
border-radius: 6px;
overflow: hidden;
background: rgb(255 255 255 / 0.06);
color: rgb(255 255 255 / 0.5);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
img { .audio-player::before {
width: 100%; display: none;
height: 100%; }
object-fit: cover; }
display: block;
}
}
&-info { @media (max-width: 1100px) {
display: flex; .audio-player {
flex-direction: column; gap: 0.8rem;
min-width: 0; }
flex: 1;
}
&-title { .media-bar-left {
font-weight: 600 !important; max-width: 320px;
line-height: 1.2 !important; }
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
&:hover {
text-decoration: underline;
}
}
&-subtitle { .media-bar-volume {
opacity: 0.55; width: 72px !important;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
&-more {
flex-shrink: 0;
color: rgb(255 255 255 / 0.6);
}
&-center {
display: flex;
align-items: center;
gap: 1.25rem;
flex: 1;
min-width: 0;
}
&-controls {
display: flex;
align-items: center;
gap: 0.15rem;
flex-shrink: 0;
.MuiIconButton-root {
color: rgb(255 255 255 / 0.7);
transition: color 0.15s ease, transform 0.15s ease;
&:hover {
color: #fff;
background: rgb(255 255 255 / 0.06);
}
&.active {
color: $clr-accent-default;
}
.material-symbols-rounded {
font-size: 1.25rem;
}
}
}
&-play {
width: 46px !important;
height: 46px !important;
margin: 0 0.5rem;
background: #fff !important;
border: 0;
color: #0b0417 !important;
box-shadow: 0 6px 18px rgb(0 0 0 / 0.35);
transition: transform 0.15s ease;
&:hover {
background: #fff !important;
transform: scale(1.04);
}
.material-symbols-rounded {
font-size: 1.6rem !important;
}
}
&-progress {
flex: 1;
min-width: 140px;
.MuiSlider-root {
padding: 10px 0;
color: $clr-accent-default;
}
.MuiSlider-rail {
background: rgb(255 255 255 / 0.16);
opacity: 1;
}
.MuiSlider-track {
border: 0;
}
.MuiSlider-thumb {
width: 12px;
height: 12px;
background: #fff;
box-shadow: none;
&:hover,
&.Mui-focusVisible {
box-shadow: 0 0 0 6px rgb(124 199 255 / 0.16);
}
}
.MuiTypography-root {
opacity: 0.55;
font-variant-numeric: tabular-nums;
font-weight: 400;
}
}
&-right {
display: flex;
align-items: center;
gap: 0.1rem;
flex-shrink: 0;
.MuiIconButton-root {
color: rgb(255 255 255 / 0.65);
&:hover {
color: #fff;
background: rgb(255 255 255 / 0.06);
}
.material-symbols-rounded {
font-size: 1.3rem;
}
}
}
&-volume {
width: 84px !important;
margin: 0 0.35rem 0 0 !important;
color: $clr-accent-default !important;
.MuiSlider-rail {
background: rgb(255 255 255 / 0.16);
opacity: 1;
}
.MuiSlider-thumb {
width: 10px;
height: 10px;
background: #fff;
box-shadow: none;
}
}
} }
} }
@media (max-width: 900px) { @media (max-width: 900px) {
.audio-player { .audio-player {
.media-bar-left { width: calc(100% - 1.5rem);
min-width: 160px; }
}
.media-bar-volume, .media-bar-left {
.media-bar-right .MuiSlider-root { min-width: 180px;
display: none; max-width: none;
} }
.media-bar-volume,
.media-bar-right .MuiSlider-root {
display: none;
} }
} }
@media (max-width: 700px) { @media (max-width: 700px) {
.audio-player { .audio-player {
display: flex;
width: calc(100% - 1rem); width: calc(100% - 1rem);
height: 66px; height: 68px;
bottom: 0.5rem; bottom: 0.55rem;
padding: 0 0.55rem; padding: 0 0.55rem;
gap: 0.5rem; gap: 0.45rem;
border-radius: 14px; border-radius: 20px;
box-sizing: border-box; }
.media-bar-left { .media-bar-left {
width: auto; width: auto;
min-width: 0; min-width: 0;
max-width: none; max-width: none;
flex: 1 1 auto; flex: 1 1 auto;
gap: 0.55rem; gap: 0.55rem;
} }
.media-bar-cover { .media-bar-cover {
width: 44px; width: 46px;
height: 44px; height: 46px;
flex: 0 0 44px; flex: 0 0 46px;
} border-radius: 13px;
}
.media-bar-more { .media-bar-more {
display: none;
}
.media-bar-center {
flex: 0 0 auto;
gap: 0;
}
.media-bar-controls {
padding: 2px;
> :first-child,
> :last-child {
display: none; display: none;
} }
.media-bar-center { .MuiIconButton-root {
flex: 0 0 auto; width: 32px;
gap: 0; height: 32px;
}
.media-bar-controls {
gap: 0;
> :first-child,
> :last-child {
display: none;
}
.MuiIconButton-root {
width: 36px;
height: 36px;
}
}
.media-bar-play {
width: 40px !important;
height: 40px !important;
margin: 0 0.1rem;
}
.media-bar-progress,
.media-bar-right {
display: none !important;
}
.media-bar-title {
font-size: 0.9rem;
} }
} }
.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;
}
} }
+76 -25
View File
@@ -18,13 +18,23 @@ 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 { useQuery } from "@tanstack/react-query";
import { useLocation, useNavigate } from "@tanstack/react-router"; import { useLocation, useNavigate } from "@tanstack/react-router";
import { AnimatePresence, motion } from "motion/react"; import { AnimatePresence, motion, useReducedMotion } from "motion/react";
import { useSnackbar } from "notistack"; import { useSnackbar } from "notistack";
import React, { type SyntheticEvent, useEffect, useRef, useState } from "react"; import React, {
type SyntheticEvent,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import QueueButton from "@/components/buttons/queueButton"; import QueueButton from "@/components/buttons/queueButton";
import { secToTicks, ticksToSec } from "@/utils/date/time"; import { secToTicks, ticksToSec } from "@/utils/date/time";
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi"; import { getCoverPalette } from "@/utils/methods/coverColor";
import getImageUrlsApi, {
getPlayerCoverUrl,
} from "@/utils/methods/getImageUrlsApi";
import { startInstantMix } from "@/utils/methods/instantMix"; import { startInstantMix } from "@/utils/methods/instantMix";
import { rememberAudioPlayerReturn } from "@/utils/methods/audioPlayerReturn";
import { import {
playOnSession, playOnSession,
queueStartingWith, queueStartingWith,
@@ -57,6 +67,8 @@ const AudioPlayer = () => {
const user = useCentralStore((s) => s.currentUser); const user = useCentralStore((s) => s.currentUser);
const navigate = useNavigate(); const navigate = useNavigate();
const location = useLocation(); const location = useLocation();
const reduceMotion = useReducedMotion();
const previousPathRef = useRef(location.pathname);
const { enqueueSnackbar } = useSnackbar(); const { enqueueSnackbar } = useSnackbar();
const openRemoteDialog = useRemoteControlStore((s) => s.openDialog); const openRemoteDialog = useRemoteControlStore((s) => s.openDialog);
@@ -163,14 +175,15 @@ const AudioPlayer = () => {
? `${artistNames.join(", ")} · ${remoteDevice}` ? `${artistNames.join(", ")} · ${remoteDevice}`
: `Идёт на ${remoteDevice}` : `Идёт на ${remoteDevice}`
: artistNames.join(", ") || activeItem?.Album || ""; : artistNames.join(", ") || activeItem?.Album || "";
const coverUrl = const coverUrl = getPlayerCoverUrl(api, activeItem, 600);
api && activeItem?.Id const fullCoverUrl = getPlayerCoverUrl(api, item, 600);
? getImageUrlsApi(api).getItemImageUrlById( const palette = useMemo(() => getCoverPalette(activeItem), [activeItem]);
activeItem.AlbumId ?? activeItem.Id, useEffect(() => {
"Primary", if (!fullCoverUrl) return;
{ quality: 85, fillHeight: 120, fillWidth: 120 }, const image = new Image();
) image.src = fullCoverUrl;
: undefined; void image.decode?.().catch(() => undefined);
}, [fullCoverUrl]);
const isPlaying = remote const isPlaying = remote
? !remote.PlayState?.IsPaused ? !remote.PlayState?.IsPaused
: playing; : playing;
@@ -218,6 +231,22 @@ const AudioPlayer = () => {
location.pathname === "/player" || location.pathname === "/player" ||
location.pathname === "/player/audio" || location.pathname === "/player/audio" ||
location.pathname === "/remote"; location.pathname === "/remote";
// The audio route keeps the floating bar mounted (hidden by the
// `player-full-open` class) until the view transition has captured the old
// frame. Other full-screen pages can remove it immediately.
const hideBarForFullPage =
isFullPlayer && location.pathname !== "/player/audio";
// Returning from the full audio player: the bar must already be in its
// final place when the view-transition snapshot is taken, otherwise the
// cover would morph towards an off-screen/transparent target.
const cameFromFullPlayer =
previousPathRef.current === "/player/audio" && !isFullPlayer;
useEffect(() => {
previousPathRef.current = location.pathname;
}, [location.pathname]);
useEffect(() => { useEffect(() => {
const visible = barVisible && !isFullPlayer; const visible = barVisible && !isFullPlayer;
document.body.classList.toggle("has-player-bar", visible); document.body.classList.toggle("has-player-bar", visible);
@@ -354,6 +383,7 @@ const AudioPlayer = () => {
if (remote) { if (remote) {
openRemoteDialog(remote.NowPlayingItem); openRemoteDialog(remote.NowPlayingItem);
} else { } else {
rememberAudioPlayerReturn();
navigate({ to: "/player/audio" }); navigate({ to: "/player/audio" });
} }
}; };
@@ -576,19 +606,39 @@ const AudioPlayer = () => {
/> />
) : null; ) : null;
if (!barVisible && !display) {
return null;
}
const bar = ( const bar = (
<AnimatePresence mode="sync"> <motion.div
<motion.div key="audio-player-bar"
initial={{ transform: "translate(-50%, 150%)" }} initial={
animate={{ transform: "translate(-50%, 0%)" }} reduceMotion || cameFromFullPlayer
exit={{ transform: "translate(-50%, 150%)" }} ? false
transition={{ duration: 0.25, ease: "circOut" }} : { opacity: 0, y: 90, scale: 0.96 }
className="audio-player" }
> animate={{ opacity: 1, y: 0, scale: 1 }}
exit={
reduceMotion
? { opacity: 0, transition: { duration: 0 } }
: {
opacity: 0,
y: 90,
scale: 0.96,
transition: { duration: 0.2, ease: [0.4, 0, 1, 1] },
}
}
transition={
reduceMotion
? { 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"> <div className="media-bar-left">
<button <button
type="button" type="button"
@@ -850,13 +900,14 @@ const AudioPlayer = () => {
</Menu> </Menu>
</motion.div> </motion.div>
</AnimatePresence>
); );
return ( return (
<> <>
{audioElement} {audioElement}
{barVisible && !isFullPlayer && bar} {!hideBarForFullPage && (
<AnimatePresence>{barVisible && bar}</AnimatePresence>
)}
</> </>
); );
}; };
+35 -13
View File
@@ -11,9 +11,15 @@ import {
Tooltip, Tooltip,
} from "@mui/material"; } from "@mui/material";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { createFileRoute, Link, useNavigate } from "@tanstack/react-router"; import { createFileRoute, Link, useNavigate, useRouter } from "@tanstack/react-router";
import { AnimatePresence, motion } from "motion/react"; import { AnimatePresence, motion } from "motion/react";
import React, { useEffect, useMemo, useRef, useState } from "react"; import React, {
useEffect,
useLayoutEffect,
useMemo,
useRef,
useState,
} from "react";
import CastButton from "@/components/buttons/castButton"; import CastButton from "@/components/buttons/castButton";
import LikeButton from "@/components/buttons/likeButton"; import LikeButton from "@/components/buttons/likeButton";
import LyricsPanel, { import LyricsPanel, {
@@ -23,8 +29,11 @@ import PlayerVolume from "@/components/playback/audioPlayer/components/PlayerVol
import StatsPanel from "@/components/playback/audioPlayer/components/StatsPanel"; import StatsPanel from "@/components/playback/audioPlayer/components/StatsPanel";
import WindowControls from "@/components/windowControls"; import WindowControls from "@/components/windowControls";
import { getRuntimeMusic, secToTicks, ticksToSec } from "@/utils/date/time"; import { getRuntimeMusic, secToTicks, ticksToSec } from "@/utils/date/time";
import { consumeAudioPlayerReturn } from "@/utils/methods/audioPlayerReturn";
import { getCoverPalette } from "@/utils/methods/coverColor"; import { getCoverPalette } from "@/utils/methods/coverColor";
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi"; import getImageUrlsApi, {
getPlayerCoverUrl,
} from "@/utils/methods/getImageUrlsApi";
import { getItemQueryOptions } from "@/utils/queries/items"; import { getItemQueryOptions } from "@/utils/queries/items";
import { useApiInContext } from "@/utils/store/api"; import { useApiInContext } from "@/utils/store/api";
import { import {
@@ -133,7 +142,7 @@ const CoverArt = ({ src, alt }: { src?: string; alt: string }) => {
const [current, setCurrent] = useState<string | undefined>(src); const [current, setCurrent] = useState<string | undefined>(src);
const [previous, setPrevious] = useState<string | undefined>(); const [previous, setPrevious] = useState<string | undefined>();
const currentRef = useRef<string | undefined>(src); const currentRef = useRef<string | undefined>(src);
const hasSwappedRef = useRef(false); const hasSwappedRef = useRef(true);
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null); const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
useEffect(() => { useEffect(() => {
@@ -204,6 +213,7 @@ function AudioPlayerRoute() {
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 navigate = useNavigate(); const navigate = useNavigate();
const router = useRouter();
const [queue, currentTrack, repeatMode] = useQueue((s) => [ const [queue, currentTrack, repeatMode] = useQueue((s) => [
s.tracks, s.tracks,
s.currentItemIndex, s.currentItemIndex,
@@ -223,6 +233,15 @@ function AudioPlayerRoute() {
const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null); const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);
const [statsOpen, setStatsOpen] = useState(false); const [statsOpen, setStatsOpen] = useState(false);
// Hide the floating bar only after this route has committed, so the view
// transition still has it in the old frame and can morph its cover.
useLayoutEffect(() => {
document.documentElement.classList.add("player-full-open");
return () => {
document.documentElement.classList.remove("player-full-open");
};
}, []);
useEffect(() => { useEffect(() => {
const player = audioPlayerRef?.current; const player = audioPlayerRef?.current;
if (!player) return; if (!player) return;
@@ -274,14 +293,8 @@ function AudioPlayerRoute() {
}; };
const imageUrl = useMemo( const imageUrl = useMemo(
() => () => getPlayerCoverUrl(api, item, 600),
item?.ImageTags?.Primary [api, item?.Id, item?.AlbumId, item?.ImageTags?.Primary],
? api &&
getImageUrlsApi(api).getItemImageUrlById(item.Id ?? "", "Primary", {
tag: item.ImageTags.Primary,
})
: undefined,
[item?.Id, item?.ImageTags?.Primary, api],
); );
const coverFor = (track: BaseItemDto) => const coverFor = (track: BaseItemDto) =>
@@ -309,6 +322,15 @@ function AudioPlayerRoute() {
setPanelOpen(true); setPanelOpen(true);
}; };
const collapsePlayer = () => {
const returnTo = consumeAudioPlayerReturn();
if (returnTo) {
void router.navigate({ href: returnTo });
} else {
void router.navigate({ to: "/home" });
}
};
return ( return (
<> <>
<div <div
@@ -340,7 +362,7 @@ function AudioPlayerRoute() {
<button <button
type="button" type="button"
className="music-player-collapse" className="music-player-collapse"
onClick={() => window.history.back()} onClick={collapsePlayer}
aria-label="Свернуть плеер" aria-label="Свернуть плеер"
> >
<span className="material-symbols-rounded">expand_more</span> <span className="material-symbols-rounded">expand_more</span>
+23
View File
@@ -135,6 +135,29 @@ body {
opacity: 0.35; opacity: 0.35;
} }
// Shared cover morph between the floating bar and the full player.
.media-bar-cover {
view-transition-name: player-cover;
}
.music-player-art {
view-transition-name: player-cover;
}
@supports (view-transition-name: none) {
::view-transition-group(player-cover) {
animation-duration: 420ms;
animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}
::view-transition-old(player-cover),
::view-transition-new(player-cover) {
animation-duration: 420ms;
animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
mix-blend-mode: normal;
}
}
/* Page transitions: a short, soft crossfade with a gentle lift. The whole /* Page transitions: a short, soft crossfade with a gentle lift. The whole
root is snapshotted, so the app bar and player stay in place visually while root is snapshotted, so the app bar and player stay in place visually while
the content changes underneath them. */ the content changes underneath them. */
+19
View File
@@ -0,0 +1,19 @@
const RETURN_KEY = "blink:audio-player-return";
/**
* The full player is a route, so reconstructing the exact page to return to
* keeps the SPA navigation (and its view transition) instead of using
* `history.back()`, which TanStack Router does not wrap in a view transition.
*/
export const rememberAudioPlayerReturn = () => {
sessionStorage.setItem(
RETURN_KEY,
`${window.location.pathname}${window.location.search}${window.location.hash}`,
);
};
export const consumeAudioPlayerReturn = () => {
const value = sessionStorage.getItem(RETURN_KEY);
sessionStorage.removeItem(RETURN_KEY);
return value;
};
+12 -1
View File
@@ -6,9 +6,15 @@ type Palette = {
base: string; base: string;
/** Darker end of the vertical gradient. */ /** Darker end of the vertical gradient. */
deep: string; 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%)" }; 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) => const clamp = (value: number, min: number, max: number) =>
Math.min(max, Math.max(min, value)); Math.min(max, Math.max(min, value));
@@ -77,6 +83,11 @@ export const getCoverPalette = (item?: BaseItemDto | null): Palette => {
return { return {
base: hsl(h, wallSaturation, wallLightness), base: hsl(h, wallSaturation, wallLightness),
deep: hsl(h, wallSaturation, clamp(wallLightness * 0.45, 0.05, 0.12)), 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 { } catch {
return FALLBACK; return FALLBACK;
+28
View File
@@ -3,4 +3,32 @@ import { ImageUrlsApi } from "@jellyfin/sdk/lib/utils/api/image-urls-api";
const getImageUrlsApi = (api: Api) => new ImageUrlsApi(api.configuration); const getImageUrlsApi = (api: Api) => new ImageUrlsApi(api.configuration);
type CoverItem = {
Id?: string | null;
AlbumId?: string | null;
ImageTags?: { Primary?: string | null } | null;
};
/**
* Shared cover URL for the floating bar and the full player, so the
* view-transition morph always blends the same artwork.
*/
export const getPlayerCoverUrl = (
api: Api | undefined,
item: CoverItem | null | undefined,
size = 600,
) => {
if (!api || !item?.Id) return undefined;
return getImageUrlsApi(api).getItemImageUrlById(
item.AlbumId ?? item.Id,
"Primary",
{
quality: 90,
fillHeight: size,
fillWidth: size,
...(item.AlbumId ? {} : { tag: item.ImageTags?.Primary ?? undefined }),
},
);
};
export default getImageUrlsApi; export default getImageUrlsApi;